class ApplicationTests(unittest.TestCase): def setUp(self) -> None: self.app = Application("sample_app") # client --> comp1 --> comp2 --> comp3 self.client = Component(self.app, "client", "client", ComponentType.UNMANAGED) self.comp1 = Component(self.app, "comp1", "comp1", ComponentType.MANAGED) self.comp2 = Component(self.app, "comp2", "comp2", ComponentType.MANAGED) self.comp3 = Component(self.app, "comp3", "comp3", ComponentType.MANAGED) self.client.add_dependency(self.comp1) self.comp1.add_dependency(self.comp2) self.comp2.add_dependency(self.comp3) self.managed_components = [self.comp1, self.comp2, self.comp3] self.unmanaged_components = [self.client] self.app.add_components( [self.client, self.comp1, self.comp2, self.comp3]) def test_list_managed_components(self): for managed_component in self.app.list_managed_components(): self.assertTrue(managed_component in self.managed_components) def test_list_unmanaged_components(self): for unmanaged_component in self.app.list_unmanaged_components(): self.assertTrue(unmanaged_component in self.unmanaged_components)
class ComponentTests(unittest.TestCase): def setUp(self) -> None: self.app = Application("sample_app") # client --> comp1 --> comp1-1 --> comp1-1-1 # \ # -> comp1-2 self.client = Component(self.app, "client", "client", ComponentType.UNMANAGED) self.comp1 = Component(self.app, "comp1", "comp1", ComponentType.MANAGED) self.comp1_1 = Component(self.app, "comp1-1", "comp1-1", ComponentType.MANAGED) self.comp1_2 = Component(self.app, "comp1-2", "comp1-2", ComponentType.MANAGED) self.comp1_1_1 = Component(self.app, "comp1-1-1", "comp1-1-1", ComponentType.MANAGED) self._managed_components = [ self.comp1, self.comp1_1, self.comp1_2, self.comp1_1_1 ] self.client.add_dependency(self.comp1) self.comp1.add_dependency(self.comp1_1) self.comp1.add_dependency(self.comp1_2) self.comp1_1.add_dependency(self.comp1_1_1) # Dependencies for client. self._dependencies_in_levels = [[self.comp1], [self.comp1_1, self.comp1_2], [self.comp1_1_1]] self._dependency_chains = [[self.comp1, self.comp1_1, self.comp1_1_1], [self.comp1, self.comp1_2]] self.app.add_components([self.client] + self._managed_components) def test_list_managed_components(self): managed_comps = list(self.app.list_managed_components()) self.assertEqual(len(managed_comps), len(self._managed_components)) found_ids = (component.id for component in managed_comps) for expected_id in (component.id for component in self._managed_components): self.assertIn(expected_id, found_ids) def test_get_all_dependencies_in_levels(self): deps_in_levels = self.client.get_all_dependencies_in_levels() expected_deps_in_levels = self._dependencies_in_levels for level, expected_level in zip(deps_in_levels, expected_deps_in_levels): for component, expected_component in zip(level, expected_level): self.assertEqual(component, expected_component) def test_get_dependency_chains(self): dep_chains = self.client.get_dependency_chains() expected_dep_chains = self._dependency_chains for chain, expected_chain in zip(dep_chains, expected_dep_chains): for component, expected_component in zip(chain, expected_chain): self.assertEqual(component, expected_component)
def register_app(self, app: Application) -> None: logger.info("App %s registered" % app.name) for component in app.list_managed_components(): for probe in component.probes: with self._lock: self._plan.append( Scenario(controlled_probe=probe, background_probes=[], hw_id=self._default_hw_id))
def register_app(self, app: Application) -> None: with self._lock: for ctl_component in app.list_managed_components(): for ctl_probe in ctl_component.probes: # Test all components alone self._probes.append(ctl_probe) for hw_config in self._hw_ids: scenario = Scenario(ctl_probe, [], hw_config) self._plan.append(scenario) # Test all pairs of components for background_probe in self._probes: for hw_config in self._hw_ids: scenario = Scenario(ctl_probe, [background_probe], hw_config) self._plan.append(scenario)