def testDetails(self): from ooni import __version__ as software_version input_file_hashes = [] for input_file in self.inputFiles: input_file_hashes.append(input_file['hash']) options = sanitize_options(self.options) test_details = { 'start_time': otime.epochToUTC(time.time()), 'probe_asn': config.probe_ip.geodata['asn'], 'probe_cc': config.probe_ip.geodata['countrycode'], 'probe_ip': config.probe_ip.geodata['ip'], 'probe_city': config.probe_ip.geodata['city'], 'test_name': self.testName, 'test_version': self.testVersion, 'software_name': 'ooniprobe', 'software_version': software_version, 'options': options, 'input_hashes': input_file_hashes, 'report_id': self.reportID, 'test_helpers': self.testHelpers, 'annotations': self.annotations } return test_details
def __init__(self, test_instance, test_method, test_input): """ test_class: is the class, subclass of NetTestCase, of the test to be run test_method: is a string representing the test method to be called to perform this measurement test_input: is the input to the test net_test: a reference to the net_test object such measurement belongs to. """ self.testInstance = test_instance self.testInstance.input = test_input self.testInstance._setUp() if not hasattr(self.testInstance, '_start_time'): self.testInstance._start_time = time.time() if 'input' not in self.testInstance.report.keys(): self.testInstance.report['input'] = test_input if 'test_start_time' not in self.testInstance.report.keys(): start_time = otime.epochToUTC(self.testInstance._start_time) self.testInstance.report['test_start_time'] = start_time self.testInstance.setUp() self.netTestMethod = getattr(self.testInstance, test_method) if 'timeout' in dir(test_instance): if isinstance(test_instance.timeout, int) or isinstance( test_instance.timeout, float): # If the test has a timeout option set we set the measurement # timeout to that value + 8 seconds to give it enough time to # trigger it's internal timeout before we start trigger the # measurement timeout. self.timeout = test_instance.timeout + 8 elif config.advanced.measurement_timeout: self.timeout = config.advanced.measurement_timeout TaskWithTimeout.__init__(self)
def __init__(self, test_instance, test_method, test_input): """ test_class: is the class, subclass of NetTestCase, of the test to be run test_method: is a string representing the test method to be called to perform this measurement test_input: is the input to the test net_test: a reference to the net_test object such measurement belongs to. """ self.testInstance = test_instance self.testInstance.input = test_input self.testInstance._setUp() if not hasattr(self.testInstance, '_start_time'): self.testInstance._start_time = time.time() if 'input' not in self.testInstance.report.keys(): self.testInstance.report['input'] = test_input if 'test_start_time' not in self.testInstance.report.keys(): start_time = otime.epochToUTC(self.testInstance._start_time) self.testInstance.report['test_start_time'] = start_time self.testInstance.setUp() self.netTestMethod = getattr(self.testInstance, test_method) if 'timeout' in dir(test_instance): if isinstance(test_instance.timeout, int) or isinstance(test_instance.timeout, float): # If the test has a timeout option set we set the measurement # timeout to that value + 8 seconds to give it enough time to # trigger it's internal timeout before we start trigger the # measurement timeout. self.timeout = test_instance.timeout + 8 elif config.advanced.measurement_timeout: self.timeout = config.advanced.measurement_timeout TaskWithTimeout.__init__(self)