def test_cfn_cluster_create_wait(self): template_url = setup_configurations() args = CreateClusterArgs(template_url, False) cfncluster.create(args) log = test_log_stream.getvalue() success_message = 'INFO:cfncluster.cfncluster:MasterPublicIP:' error_prefix = "CRITICAL:" self.assertTrue(success_message in log) self.assertFalse(error_prefix in log)
def test_cfn_cluster_create_nowait(self): template_url = setup_configurations() args = CreateClusterArgs(template_url, True) cfncluster.create(args) log = test_log_stream.getvalue() success_message = 'INFO:cfncluster.cfncluster:Status: CREATE_COMPLETE' error_prefix = "CRITICAL:" self.assertTrue(success_message in log) self.assertFalse(error_prefix in log)
def test_cfn_cluster_start(self): template_url = setup_configurations() args = CreateClusterArgs(template_url, True) cfncluster.create(args) cfncluster.start(args) log = test_log_stream.getvalue() error_prefix = "CRITICAL:" success_message = "Starting compute fleet" self.assertFalse(error_prefix in log) self.assertTrue(success_message in log)
def test_cfn_cluster_delete(self): template_url = setup_configurations() args = CreateClusterArgs(template_url, True) cfncluster.create(args) with self.assertRaises(SystemExit) as sys_ex: cfncluster.delete(args) self.assertEqual(sys_ex.exception.code, 0) success_message = "Cluster deleted successfully" log = test_log_stream.getvalue() self.assertTrue(success_message in log)
def test_cfn_cluster_update_with_reset(self): template_url = setup_configurations() args = UpdateClusterArgs(template_url, True, True) cfncluster.create(args) cfncluster.update(args) success_message = 'INFO:cfncluster.cfncluster:Status: UPDATE_COMPLETE' log = test_log_stream.getvalue() self.assertTrue(success_message in log) error_prefix = "CRITICAL:" self.assertFalse(error_prefix in log)
def test_cfn_cluster_create_fail(self): template_url = setup_configurations() args = CreateClusterArgs('', True) with self.assertRaises(SystemExit) as sys_ex: cfncluster.create(args) self.assertEqual(sys_ex.exception.code, 1) log = test_log_stream.getvalue() error_prefix = "CRITICAL:" self.assertTrue(error_prefix in log)
def test_cfn_cluster_list_nonempty(self): template_url = setup_configurations() args = CreateClusterArgs(template_url, False) cfncluster.create(args) # reset the logger self.tearDown() cfncluster.list(args) log = test_log_stream.getvalue() cluster_name = re.match(r"INFO:cfncluster.cfncluster:(\w+)", log).group(1) self.assertEqual(cluster_name, args.cluster_name)