def test_status_db_jobs_request_lookup_nacked_initialized( self, id_platform, guess_effective_cloud_mock, fake_db): class FakeRequest(object): def __init__(self, doc): self.request_doc = json.dumps({'payload': doc}) class FakeDB(object): def get_all_complete(self): return [] def get_all_reply(self): return [] def get_all_rejected(self): return [] def get_all_ack(self): return [] def get_all_reply_nacked(self): return [FakeRequest({'command': 'initialize'})] fake_db.return_value = FakeDB() id_platform.return_value = ("ubuntu", "14.04") guess_effective_cloud_mock.return_value = "Other" rc = dcmagent.main( args=["dcm-agent", "-c", self.test_conf_path, "status"]) self.assertEqual(rc, 1)
def test_effective_cloud_base_report(self, id_platform, guess_effective_cloud_mock): id_platform.return_value = ("ubuntu", "14.04") guess_effective_cloud_mock.return_value = "Other" rc = dcmagent.main( args=["dcm-agent", "-c", self.test_conf_path, "--report"]) self.assertEqual(rc, 0) self.assertTrue(os.path.exists("/tmp/agent_info.tar.gz"))
def test_real_pid_status(self, id_platform, guess_effective_cloud_mock): id_platform.return_value = ("ubuntu", "14.04") guess_effective_cloud_mock.return_value = "Other" pid_file = os.path.join(self.test_base_path, "dcm-agent.pid") with open(pid_file, "w") as fptr: fptr.write(str(os.getpid())) try: rc = dcmagent.main( args=["dcm-agent", "-c", self.test_conf_path, "status"]) self.assertEqual(rc, 0) finally: os.remove(pid_file)
def test_used_pid_status(self, id_platform, guess_effective_cloud_mock): id_platform.return_value = ("ubuntu", "14.04") guess_effective_cloud_mock.return_value = "Other" pid_file = os.path.join(self.test_base_path, "dcm-agent.pid") pid_val = None pid_list = psutil.pids() for i in range(10, 2 ^ 15): if i not in pid_list: pid_val = i break if pid_val is None: warn("No free pid found... huh") raise unittest.SkipTest("No free pid found") with open(pid_file, "w") as fptr: fptr.write(str(pid_val)) try: rc = dcmagent.main( args=["dcm-agent", "-c", self.test_conf_path, "status"]) self.assertEqual(rc, 1) finally: os.remove(pid_file)
def test_agent_status(self): # we need a way to parse the output to verify tests rc = service.main(args=["dcm-agent", "-c", self.test_conf_path, "status"]) self.assertEqual(rc, 1)
def test_simple_tar(self, id_platform): id_platform.return_value = ("ubuntu", "14.04") rc = dcmagent.main( args=["dcm-agent", "-c", self.test_conf_path, "--report"]) self.assertEqual(rc, 0) self.assertTrue(os.path.exists("/tmp/agent_info.tar.gz"))
def test_simple_status(self, id_platform, sql_obj): id_platform.return_value = ("ubuntu", "14.04") rc = dcmagent.main(args=["dcm-agent", "status"]) print(rc) self.assertEqual(rc, 1)
def test_agent_status(self): # we need a way to parse the output to verify tests rc = service.main( args=["dcm-agent", "-c", self.test_conf_path, "status"]) self.assertEqual(rc, 1)