def test_destroy_environment_with_missing_iaas_machine(self, mock_time): self.config.options.force = False self.setup_env() self.env.status.return_value = { 'machines': { '0': { 'dns-name': '10.0.1.23', 'instance-id': 'manual:ip_address' }, '1': { 'dns-name': '10.0.1.25', 'instance-id': 'manual:ip_address' }, '2': { 'dns-name': '10.0.1.27', 'instance-id': 'manual:ip_address' } } } self.provider.get_instances.return_value = [ Linode_instace.from_dict( dict(id=221, name="linode-123123", ip_address="10.0.1.23")), Linode_instace.from_dict( dict(id=258, name="docena-209123", ip_address="10.0.1.25")) ] # Destroy Env has a sleep / mock it out. mock_time.sleep.return_value = None self.cmd.run() self.assertEqual(self.provider.terminate_instance.call_args_list, [mock.call(258), mock.call(221)]) self.assertEqual(self.env.terminate_machines.call_args_list, [mock.call(['1']), mock.call(['2'])])
def test_destroy_environment_with_missing_iaas_machine(self, mock_time): self.config.options.force = False self.setup_env() self.env.status.return_value = { 'machines': { '0': { 'dns-name': '10.0.1.23', 'instance-id': 'manual:ip_address'}, '1': { 'dns-name': '10.0.1.25', 'instance-id': 'manual:ip_address'}, '2': { 'dns-name': '10.0.1.27', 'instance-id': 'manual:ip_address'} }} self.provider.get_instances.return_value = [ Linode_instace.from_dict(dict( id=221, name="linode-123123", ip_address="10.0.1.23")), Linode_instace.from_dict(dict( id=258, name="docena-209123", ip_address="10.0.1.25"))] # Destroy Env has a sleep / mock it out. mock_time.sleep.return_value = None self.cmd.run() self.assertEqual( self.provider.terminate_instance.call_args_list, [mock.call(258), mock.call(221)]) self.assertEqual( self.env.terminate_machines.call_args_list, [mock.call(['1']), mock.call(['2'])])
def test_terminate_machine(self): self.setup_env() self.env.status.return_value = { 'machines': { '1': { 'dns-name': '10.0.1.23', 'instance-id': 'manual:ip_address'} }} self.provider.get_instances.return_value = [ Linode_instace.from_dict(dict( id=221, name="linode-123123", ip_address="10.0.1.23")), Linode_instace.from_dict(dict( id=258, name="docena-209123", ip_address="10.0.1.103"))] self.config.options.machines = ["1"] self.cmd.run() self.provider.terminate_instance.assert_called_once_with(221)
def test_terminate_machine(self): self.setup_env() self.env.status.return_value = { 'machines': { '1': { 'dns-name': '10.0.1.23', 'instance-id': 'manual:ip_address' } } } self.provider.get_instances.return_value = [ Linode_instace.from_dict( dict(id=221, name="linode-123123", ip_address="10.0.1.23")), Linode_instace.from_dict( dict(id=258, name="docena-209123", ip_address="10.0.1.103")) ] self.config.options.machines = ["1"] self.cmd.run() self.provider.terminate_instance.assert_called_once_with(221)
def test_destroy_environment_force(self): self.config.options.force = True self.setup_env() self.provider.get_instances.return_value = [ Linode_instace.from_dict( dict(id=220, name="linodeabc", ip_address="10.0.1.19")), Linode_instace.from_dict( dict(id=221, name="linode-123123", ip_address="10.0.1.23")), Linode_instace.from_dict( dict(id=258, name="linode-209123", ip_address="10.0.1.25")), Linode_instace.from_dict( dict(id=233, name="mary", ip_address="10.0.1.32")), Linode_instace.from_dict( dict(id=234, name="loug", ip_address="10.0.1.18")) ] self.cmd.run() self.assertEqual(self.provider.terminate_instance.call_args_list, [mock.call(221), mock.call(258)]) self.env.destroy_environment_jenv.assert_called_once()
def test_destroy_environment_force(self): self.config.options.force = True self.setup_env() self.provider.get_instances.return_value = [ Linode_instace.from_dict(dict( id=220, name="linodeabc", ip_address="10.0.1.19")), Linode_instace.from_dict(dict( id=221, name="linode-123123", ip_address="10.0.1.23")), Linode_instace.from_dict(dict( id=258, name="linode-209123", ip_address="10.0.1.25")), Linode_instace.from_dict(dict( id=233, name="mary", ip_address="10.0.1.32")), Linode_instace.from_dict(dict( id=234, name="loug", ip_address="10.0.1.18"))] self.cmd.run() self.assertEqual( self.provider.terminate_instance.call_args_list, [mock.call(221), mock.call(258)]) self.env.destroy_environment_jenv.assert_called_once()
def test_bootstrap(self, mock_ssh, mock_get_images): mock_get_images.return_value = IMAGE_MAP self.setup_env() self.env.is_running.return_value = False self.config.series = "precise" mock_ssh.check_ssh.return_value = True mock_ssh.update_instance.return_value = True self.provider.get_instance.return_value = Linode_instace.from_dict( dict(id=2121, name='linode-13290123j13', ip_address="10.0.2.1")) self.cmd.run() mock_ssh.check_ssh.assert_called_once_with('10.0.2.1')
def test_bootstrap(self, mock_ssh, mock_get_images): mock_get_images.return_value = IMAGE_MAP self.setup_env() self.env.is_running.return_value = False self.config.series = "precise" mock_ssh.check_ssh.return_value = True mock_ssh.update_instance.return_value = True self.provider.get_instance.return_value = Linode_instace.from_dict(dict( id=2121, name='linode-13290123j13', ip_address="10.0.2.1")) self.cmd.run() mock_ssh.check_ssh.assert_called_once_with('10.0.2.1')