async def run(self, test_case, unit, idx): """Run tests.""" rows = [] async with Exporter(unit, self.named) as exporter: try: act = await unit.run(python3(exporter), timeout=10) results = load_output(act.data['results']) except Exception as exc: log.debug(exc) results = [] # print(results.keys()) if 'regex' in test_case: for condition in test_case['regex']: prog = re.compile(condition) mounts = '' for result in results: var = prog.search(result) if var: mounts = var.group(0) rows.append((idx, '{} == {}'.format( mounts if mounts else str(condition), 'mounted'), True if mounts else False), ) return rows
async def run(self, test_case, unit, idx): """Run tests.""" rows = [] async with Exporter(unit, self.named) as exporter: try: act = await unit.run(python3(exporter), timeout=10) results = load_output(act.data['results']) except Exception as exc: log.debug(exc) results = {'installed': []} # print(results['installed'].keys()) if 'installed' in test_case: for condition in test_case['installed']: rows.append((idx, '{} == {}'.format(condition, 'installed'), condition in results['installed']), ) return rows
async def run(self, test_case, unit, idx): """Run tests.""" rows = [] async with Exporter(unit, self.named) as exporter: try: act = await unit.run(python3(exporter), timeout=10) results = load_output(act.data['results']) except Exception as exc: log.debug(exc) results = {} # print(results) for condition, present in test_case.items(): status = 'present' if present else 'absent' rows.append((idx, '{} == {}'.format(condition, status), (condition in results) == present), ) return rows
async def run(self, test_data, unit, idx): """Run tests.""" rows = [] async with Exporter(unit, self.named) as exporter: files = test_data # print(test_data) for file, params in files.items(): try: act = await unit.run(python3(exporter, args=[file]), timeout=10) results = load_output(act.data['results']) except Exception as exc: log.debug(exc) results = {} # print('Expect: ', files[file]) # print(results) for param, value in params.items(): res = (param in results) and (results[param] == value) rows.append((idx, '{}.{} == {}'.format(file, param, value), res), ) return rows
async def run(self, test_case, unit, idx): """Run tests.""" rows = [] async with Exporter(unit, self.named) as exporter: try: act = await unit.run(python3(exporter), timeout=10) user_data = load_output(act.data['results']) except Exception as exc: log.debug(exc) user_data = {} # print(user_data) for condition, test_item in test_case.items(): test_res = False # if subitem in test_item.items(): if condition in user_data and all( user_data[condition][key] == value for key, value in test_item.items()): test_res = True rows.append( (idx, '{} == {}'.format(condition, 'present'), test_res), ) return rows
async def run(self, test_case, unit, idx): """Run tests.""" rows = [] async with Exporter(unit, self.named) as exporter: try: act = await unit.run(python3(exporter), timeout=10) results = load_output(act.data['results']) except Exception as exc: log.debug(exc) results = {'services': {}} # print(results['services']) # print(test_case) for service, condition in test_case.items(): for c, v in condition.items(): if c == 'exists': rows.append((idx, '{}.{} == {}'.format(service, c, v), (service in results['services']) == v), ) else: rows.append( (idx, '{}.{} == {}'.format( service, c, v), service in results['services'] and results['services'][service][c] == v), ) return rows
async def run(self, test_case, unit, idx): """Run tests.""" rows = [] async with Exporter(unit, self.named) as exporter: if 'port' in test_case: try: test_data = await unit.run(python3(exporter), timeout=10) results = load_output(test_data.data['results']) except Exception as exc: log.debug(exc) results = {'sockets': []} # print(results) local_ports = [ str(s['local_port']) for s in results['sockets'] ] for port, open in test_case['port'].items(): status = 'open' if open else 'closed' rows.append( (idx, '{}.{} == {}'.format('port', port, status), (str(port) in local_ports) == open), ) return rows