code
stringlengths
3
6.57k
self.assertEqual(1, agent.error.failure_count)
self.assertTrue(agent.error.was_fatal)
self.assertTrue(agent.is_blacklisted)
self.assertEqual(0, mock_download.call_count)
self.assertEqual(0, mock_unpack.call_count)
TestUpdate(UpdateTestCase)
setUp(self)
UpdateTestCase.setUp(self)
patch('azurelinuxagent.common.event.add_event')
get_update_handler()
Mock()
Mock(return_value=(Mock()
Mock()
Mock()
Mock(return_value=protocol)
clear_singleton_instances(ProtocolUtil)
test_creation(self)
self.assertEqual(None, self.update_handler.last_attempt_time)
self.assertEqual(0, len(self.update_handler.agents)
self.assertEqual(None, self.update_handler.child_agent)
self.assertEqual(None, self.update_handler.child_launch_time)
self.assertEqual(0, self.update_handler.child_launch_attempts)
self.assertEqual(None, self.update_handler.child_process)
self.assertEqual(None, self.update_handler.signal_handler)
test_emit_restart_event_emits_event_if_not_clean_start(self)
self.event_patch.start()
self.update_handler._set_sentinel()
self.update_handler._emit_restart_event()
self.assertEqual(1, mock_event.call_count)
self.event_patch.stop()
_create_protocol(self, count=20, versions=None)
self.prepare_agents(count=count)
len(versions)
ProtocolMock(versions=versions)
_test_ensure_no_orphans(self, invocations=3, interval=ORPHAN_WAIT_INTERVAL, pid_count=0)
patch.object(self.update_handler, 'osutil')
iterator(*args, **kwargs)
Mock(side_effect=iterator)
self.update_handler._get_pid_files()
self.assertEqual(pid_count, len(pid_files)
patch('os.getpid', return_value=42)
patch('time.sleep', return_value=None)
self.update_handler._ensure_no_orphans(orphan_wait_interval=interval)
self.assertFalse(os.path.exists(pid_file)
test_ensure_no_orphans(self)
fileutil.write_file(os.path.join(self.tmp_dir, "0_waagent.pid")
ustr(41)
self._test_ensure_no_orphans(invocations=3, pid_count=1)
self.assertEqual(3, calls)
self.assertEqual(2, sleeps)
test_ensure_no_orphans_skips_if_no_orphans(self)
self._test_ensure_no_orphans(invocations=3)
self.assertEqual(0, calls)
self.assertEqual(0, sleeps)
test_ensure_no_orphans_ignores_exceptions(self)
patch('azurelinuxagent.common.utils.fileutil.read_file', side_effect=Exception)
self._test_ensure_no_orphans(invocations=3)
self.assertEqual(0, calls)
self.assertEqual(0, sleeps)
test_ensure_no_orphans_kills_after_interval(self)
fileutil.write_file(os.path.join(self.tmp_dir, "0_waagent.pid")
ustr(41)
patch('os.kill')
self.assertEqual(3, calls)
self.assertEqual(2, sleeps)
self.assertEqual(1, mock_kill.call_count)
patch('azurelinuxagent.ga.update.datetime')
test_ensure_partition_assigned(self, mock_time)
os.path.join(conf.get_lib_dir()
Mock()
self.assertFalse(os.path.exists(path)
range(0, 99)
Mock(microsecond=n * 10000)
self.update_handler._ensure_partition_assigned()
self.assertTrue(os.path.exists(path)
fileutil.read_file(path)
self.assertEqual(n, int(s)
os.remove(path)
test_ensure_readonly_sets_readonly(self)
os.path.join(conf.get_lib_dir()
os.path.join(conf.get_lib_dir()
os.path.join(conf.get_lib_dir()
os.path.join(conf.get_lib_dir()
os.path.join(conf.get_lib_dir()
fileutil.write_file(path, "Faux content")
self.update_handler._ensure_readonly_files()
os.stat(path)
self.assertEqual(0, mode ^ stat.S_IRUSR)
test_ensure_readonly_leaves_unmodified(self)
os.path.join(conf.get_lib_dir()
os.path.join(conf.get_lib_dir()
os.path.join(conf.get_lib_dir()
os.path.join(conf.get_lib_dir()
fileutil.write_file(path, "Faux content")
self.update_handler._ensure_readonly_files()
os.stat(path)
_test_evaluate_agent_health(self, child_agent_index=0)
self.prepare_agents()
self.update_handler.get_latest_agent()
self.assertTrue(latest_agent.is_available)