def _create_harness(): config = ConfigManager() entity = 'mysut' config.set(SUT, [entity]) config.set(SUT_PROC_MEMORY_USAGE_MONITOR_IDS, ['mymonitor', 'myothermonitor'], entity=entity) config.set(PROC_MEMORY_USAGE_MONITOR_IDS, ['mymonitor', 'myothermonitor']) config.set(PROC_MEMORY_USAGE_MONITOR_PATTERNS, ['my_pattern'], entity='mymonitor') config.set(PROC_MEMORY_USAGE_MONITOR_PATTERNS, ['my_other_pattern'], entity='myothermonitor') exec = Mock() proc_pid_collector = Mock() create_series_metric = Mock() harness = ExtensionTestHarness(ProcMemoryUsageMonitor, config=config, endpoints_and_messages={ MONITOR_ENDPOINT: [PERFORM_MEASUREMENT], MOCK_ENDPOINT: [SUT_RESET_DONE] }, components=[ ComponentMock(name='Exec', mock=exec, can=['telnet']), ComponentMock(name='ProcPidCollector', mock=proc_pid_collector), ComponentMock(name='CreateSeriesMetric', mock=create_series_metric) ]) harness.exec = exec harness.proc_pid_collector = proc_pid_collector harness.create_series_metric = create_series_metric return harness
def create_harness(csv_enabled=True, csv_path='path/to/csv/report.csv', json_enabled=True, json_path='path/to/json/report.json', text_enabled=True, text_path='path/to/text/report.text'): metric_mock = Mock() config = ConfigManager() config.set(PROFILING_DIR, 'profiling') config.set(PROFILING_CSV, csv_enabled) config.set(PROFILING_CSV_PATH, csv_path) config.set(PROFILING_JSON, json_enabled) config.set(PROFILING_JSON_PATH, json_path) config.set(PROFILING_TEXT, text_enabled) config.set(PROFILING_TEXT_PATH, text_path) harness = ExtensionTestHarness( Profiling, endpoints_and_messages={ APPLICATION_ENDPOINT: [BEFORE_COMMAND, AFTER_COMMAND] }, config=config, components=[ ComponentMock(name='CreateSingleValueMetric', mock=metric_mock) ]) harness.metrics_mock = metric_mock return harness
def create_harness(docker_run=Mock()): config = ConfigManager() config.set(EXEC_COMMAND_WITH_ARGUMENTS, ('exec', 'with', 'args')) return ExtensionTestHarness( CacheExtension, config=config, components=[ComponentMock('DockerRun', docker_run)], )
def _create_harness(env=Mock()): config = ConfigManager() with patch('os.path.exists', return_value=True): config.set(ADOC_FILE, 'file.adoc') return ExtensionTestHarness( AsciidoctorExtension, endpoints_and_messages={OPTIONS_ENDPOINT: [GET_ASCIIDOCTOR_OPTIONS]}, config=config, components=[ComponentMock('Env', env)])
def _create_harness(config): sut = Mock() node = Mock() harness = ExtensionTestHarness(DockerExtension, entity='mysut', config=config, endpoints_and_messages={}, components=[ ComponentMock(name='Sut', mock=sut, can=['docker']), ComponentMock(name='Node', mock=node, can=['docker']), ]) harness.sut = sut harness.node = node return harness
def create_harness(docker_run=Mock(), image='abs.u16'): config = ConfigManager() config.set(MAKE_ARGUMENTS, ('arg1', '--opt2')) config.set(IMAGE_OPTION, image) return ExtensionTestHarness( MakeExtension, config=config, components=[ComponentMock('DockerRun', docker_run)], )
def create_component_harness(sut=['entity']): component_sut = Mock() component_sut.entity = sut[0] return ExtensionTestHarness( SutEventsComponentExtension, endpoints_and_messages={ MOCK_ENDPOINT: [LOG_LINE_RECEIVED, SUT_RESET_DONE], }, components=[ComponentMock(name='Sut', mock=component_sut), SutEvents])
def _create_harness(enabled=True): config = ConfigManager() entity = 'mysut' config.set(SUT, [entity]) config.set(SYSTEM_MEMORY_USAGE_MONITOR_ENABLED, enabled, entity=entity) exec = Mock() create_series_metric = Mock() harness = ExtensionTestHarness( SystemMemoryUsageMonitor, config=config, endpoints_and_messages={MONITOR_ENDPOINT: [PERFORM_MEASUREMENT]}, components=[ ComponentMock(name='Exec', mock=exec, can=['telnet']), ComponentMock(name='CreateSeriesMetric', mock=create_series_metric) ]) harness.exec = exec harness.create_series_metric = create_series_metric return harness
def _create_harness(enabled=True): config = ConfigManager() entity = 'mysut' config.set(SUT, [entity]) config.set(AVAILABLE_POWER_METERS, ['fake_power_meter']) config.set(POWER_CONSUMPTION_MONITOR_ENABLED, enabled, entity=entity) config.set(POWER_METER, 'fake_power_meter', entity=entity) powermeter = Mock() create_series_metric = Mock() harness = ExtensionTestHarness( PowerConsumptionMonitor, config=config, endpoints_and_messages={MONITOR_ENDPOINT: [PERFORM_MEASUREMENT]}, components=[ ComponentMock(name='PowerMeter', mock=powermeter), ComponentMock(name='CreateSeriesMetric', mock=create_series_metric) ]) harness.powermeter = powermeter harness.create_series_metric = create_series_metric return harness
def create_harness( znail_cc_enabled=True, znail_cc_required=True, sut=['entity'], component_mock=None): config = ConfigManager() entity = sut[0] config.set(SUT, sut) config.set(ZNAIL_IP, '1.2.3.4', entity=entity) config.set(ZNAIL_CONNECTION_CHECK_ENABLED, znail_cc_enabled, entity=entity) config.set(ZNAIL_CONNECTION_CHECK_REQUIRED, znail_cc_required, entity=entity) if component_mock is None: component_mock = Mock() return ExtensionTestHarness( ZnailConnectionCheck, config=config, components=[ComponentMock(name='Znail', mock=component_mock)])
def create_harness(extra_config=None): sut = Mock() sut.entity = 'mysut' config = ConfigManager() config.set(SUT, [sut.entity]) config.set(ZNAIL_IP, '1.2.3.4', entity=sut.entity) for id, value in extra_config.items() if extra_config else []: config.set(id, value, entity=sut.entity, priority=2) harness = ExtensionTestHarness(Znail, config=config, components=[ ComponentMock(name='Sut', mock=sut), ]) return harness
def _create_harness(source_series, target_value, type): config = ConfigManager() entity = 'myaggregator' config.set(SERIES_AGGREGATOR_IDS, [entity]) config.set(SOURCE_SERIES, source_series, entity=entity) config.set(TARGET_VALUE, target_value, entity=entity) config.set(SERIES_AGGREGATOR_TYPE, type, entity=entity) create_single_value_metric = Mock() harness = ExtensionTestHarness( MetricsSeriesAggregator, config=config, endpoints_and_messages={METRICS_ENDPOINT: [GENERATE_METRICS_AGGREGATE]}, components=[ ComponentMock(name='CreateSingleValueMetric', mock=create_single_value_metric), ]) harness.create_single_value_metric = create_single_value_metric return harness
def create_harness(parallel_runs=2, suts=('sut1', 'sut2'), ansible_nodes=('sut1', 'sut2'), ansible_node_mock=Mock()): config = ConfigManager() config.set(ANSIBLE_PARALLEL_RUNS, parallel_runs) config.set(SUT, suts) for node in ansible_nodes: config.set(SUT_ANSIBLE_TEST_NODE, True, entity=node) return ExtensionTestHarness( InitializeAnsibleSuts, endpoints_and_messages={ RUN_COMMAND_ENDPOINT: [INITIALIZE_SUT, POST_INITIALIZE_SUT] }, config=config, components=[ComponentMock(name='AnsibleNode', mock=ansible_node_mock)], )
def _create_harness(): config = ConfigManager() entity = 'mysut' config.set(SUT, [entity]) config.set(SUT_HEALTHCHECK_PROC_IDS, ['myhealthcheck'], entity=entity) config.set(HEALTHCHECK_PROC_IDS, ['myhealthcheck']) config.set(HEALTHCHECK_PROC_PATTERNS, ['my_pattern'], entity='myhealthcheck') proc_pid_collector = Mock() harness = ExtensionTestHarness( ProcMonitoringHealthCheck, config=config, endpoints_and_messages={ HEALTH_CHECK_ENDPOINT: [PERFORM_HEALTH_CHECK], }, components=[ ComponentMock(name='ProcPidCollector', mock=proc_pid_collector), ]) harness.proc_pid_collector = proc_pid_collector return harness
def create_harness(docker_run=Mock()): return ExtensionTestHarness( ShellExtension, components=[ComponentMock('DockerRun', docker_run)], )