def run_around_tests(): # Before test res = telemetry.elastic(server=server) res.index_name = "dummy" res.delete_index() yield # After test res = telemetry.elastic(server=server) res.index_name = "dummy" res.delete_index()
def test_add_entry(): res = telemetry.elastic(server=server) loc = os.path.dirname(__file__) loc = os.path.split(loc)[:-1] loc = os.path.join(loc[0], "telemetry", "resources", "evm_tests_el.json") s = res.import_schema(loc) res.create_db_from_schema(s) # Add entry import datetime entry = { "test_name": "EVM_1", "date": datetime.datetime.now(), "tx_device": "PlutoA", "rx_device": "PlutoA", "CARRIER_FREQUENCY": 1000000000, "tx_sample_rate": 1000000, "rx_sample_rate": 1000000, "standard": "LTE10_ETM3p1", "evm_db": 3.2, "iteration": 1, } res.add_entry(entry) time.sleep(2) results = res.search_all() res.delete_index() print(results) assert results["hits"]["total"]["value"] == 1
def test_db_create_delete(): res = telemetry.elastic(server=server) loc = os.path.dirname(__file__) loc = os.path.split(loc)[:-1] loc = os.path.join(loc[0], "telemetry", "resources", "evm_tests_el.json") s = res.import_schema(loc) res.create_db_from_schema(s) res.delete_index()
def test_db_connect(): telemetry.elastic(server=server) # Should complete without error assert True
def __init__(self, mode="elastic", server="alpine"): if mode == "elastic": self.db = telemetry.elastic(server=server)
import os import telemetry from random import random import datetime res = telemetry.elastic() # loc = os.path.dirname(__file__) # loc = os.path.split(loc)[:-1] # loc = os.path.join(loc[0], "resources", "evm_tests_el.json") # s = res.import_schema(loc) # res.create_db_from_schema(s) # Add entry los = range(1, 600) for lo in los: lo_full = lo * 10000000 print(lo_full) for iteration in range(1, 10): entry = { "test_name": "evm_1", "date": str(datetime.datetime.now()), "tx_device": "PlutoA", "rx_device": "PlutoA", "carrier_frequency": lo_full, "tx_sample_rate": 1000000, "rx_sample_rate": 1000000, "standard": "LTE10_ETM3p1", "evm_db": random() * lo, "iteration": iteration, }