def test_from_path_multiple_found(self): path = resource_filename( __name__, os.path.join("..", "..", "curie", "yaml")) with self.assertRaises(ValueError) as ar: scenario_parser.from_path(path) self.assertIn("Multiple configuration files found at '%s': [" % path, str(ar.exception))
def test_from_path_packaged_scenarios_small_large_clusters(self): three_node_cluster = mock_cluster(3) one_hundred_twenty_eight_node_cluster = mock_cluster(128) for path in Scenario.find_configuration_files(): scenario_parser.from_path( path, cluster=three_node_cluster) scenario_parser.from_path( path, cluster=one_hundred_twenty_eight_node_cluster)
def test_from_path_invalidyaml(self, m_isdir, m_split, m_splitext, m_open, m_from_yaml_str): with self.assertRaises(CurieTestException) as err: scenario_parser.from_path(sen.path) self.assertEqual("Unable to parse YAML at path sentinel.path, check " "syntax: %r" % str(sen.note), err.exception.message) m_from_yaml_str.assert_called_once_with( m_open.return_value.__enter__.return_value.read.return_value, source_directory=sen.dir, vars=None)
def test_from_path_none_found(self): # Create a directory that contains no YAML configurations. path = environment.test_output_dir(self) if os.path.isdir(path): os.rmdir(path) os.makedirs(path) with self.assertRaises(ValueError) as ar: scenario_parser.from_path(path) self.assertEqual("No configuration files found at '%s'" % path, str(ar.exception))
def test_from_path_packaged_scenarios(self): for path in Scenario.find_configuration_files(): scenario = scenario_parser.from_path(path) first_setup_step = scenario.steps[Phase.SETUP][0] self.assertIsInstance( first_setup_step, CleanUp, "The first step in the setup phase should be cluster.CleanUp " "(path: %s, found: %s)" % (path, first_setup_step))
def test_pickle_four_corners(self): four_corners_directory = os.path.join(environment.top, "curie", "yaml", "four_corners_microbenchmark") scenario = scenario_parser.from_path(four_corners_directory) scenario.cluster = mock_cluster() unfrozen_caveman_scenario = pickle.loads(pickle.dumps(scenario)) self.assertEqual(scenario.id, unfrozen_caveman_scenario.id) self.assertEqual(None, unfrozen_caveman_scenario.cluster)
def test_four_corners(self): scenario_directory = os.path.join( environment.top, "curie", "yaml", "four_corners_microbenchmark") scenario = scenario_parser.from_path( scenario_directory, cluster=self.cluster, output_directory=environment.test_output_dir(self), goldimages_directory=gflags.FLAGS.curie_vmdk_goldimages_dir) scenario.start() scenario.join() self.assertEqual(Status.SUCCEEDED, scenario.status(), msg=scenario.error_message())
def test_four_corners_save_state_load_state(self): four_corners_directory = os.path.join(environment.top, "curie", "yaml", "four_corners_microbenchmark") scenario = scenario_parser.from_path(four_corners_directory) scenario.cluster = mock_cluster() scenario.output_directory = environment.test_output_dir(self) scenario.save_state() unfrozen_caveman_scenario = scenario.load_state( environment.test_output_dir(self)) self.assertEqual(scenario.id, unfrozen_caveman_scenario.id) self.assertEqual(None, unfrozen_caveman_scenario.cluster) self.assertEqual(6, len(unfrozen_caveman_scenario.results_map))
def test_vdi_low_count(self): scenario_directory = os.path.join( environment.top, "curie", "yaml", "vdi_simulator_task_100") scenario = scenario_parser.from_path( scenario_directory, cluster=self.cluster, output_directory=environment.test_output_dir(self), goldimages_directory=gflags.FLAGS.curie_vmdk_goldimages_dir, vars={"vms_per_node": 1, "runtime_secs": 60} ) scenario.start() scenario.join() self.assertEqual(Status.SUCCEEDED, scenario.status(), msg=scenario.error_message())
def test_four_corners_save_state_load_state_experimental_metrics(self): four_corners_directory = os.path.join(environment.top, "curie", "yaml", "four_corners_microbenchmark") scenario = scenario_parser.from_path(four_corners_directory, enable_experimental_metrics=True) scenario.cluster = mock_cluster() scenario.output_directory = environment.test_output_dir(self) scenario.save_state() unfrozen_caveman_scenario = scenario.load_state( environment.test_output_dir(self)) self.assertEqual(scenario.id, unfrozen_caveman_scenario.id) self.assertEqual(None, unfrozen_caveman_scenario.cluster) self.assertEqual(7, len(unfrozen_caveman_scenario.results_map)) for result in unfrozen_caveman_scenario.results_map.itervalues(): if isinstance(result, ClusterResult): self.assertIsInstance(result.metric, CurieMetric)
def test_from_path_readonly(self): path = Scenario.find_configuration_files()[0] scenario = scenario_parser.from_path(path, readonly=True) self.assertTrue(scenario.readonly) scenario = scenario_parser.from_path(path, readonly=False) self.assertFalse(scenario.readonly)
def test_from_path_invalid_file_type(self): path = os.path.realpath(__file__) with self.assertRaises(ValueError) as ar: scenario_parser.from_path(path) self.assertEqual("Invalid file type '%s'" % path, str(ar.exception))