def foreach_test(): print("Setup before test") """ Test Environment Setup for each test case """ Config.setDbPath(os.path.join(basedir, "src/sharkradar/Util")) Config.setAlgorithm("wpmc") sharkradarDbutils.createTableIfNotExists() Health.health(TEST_PARAMS["health_object_1"]) Health.health(TEST_PARAMS["health_object_2"]) Health.health(TEST_PARAMS["health_object_3"]) app.testing = True client = app.test_client() yield client print("Teardown after test") """ Test Environment Clean up for each test case """ sharkradarDbutils.deleteServiceByNameAndIpAndPort( TEST_PARAMS["health_object_1"]["service_name"], TEST_PARAMS["health_object_1"]["ip"], TEST_PARAMS["health_object_1"]["port"]) sharkradarDbutils.deleteServiceByNameAndIpAndPort( TEST_PARAMS["health_object_2"]["service_name"], TEST_PARAMS["health_object_2"]["ip"], TEST_PARAMS["health_object_2"]["port"]) sharkradarDbutils.deleteServiceByNameAndIpAndPort( TEST_PARAMS["health_object_3"]["service_name"], TEST_PARAMS["health_object_3"]["ip"], TEST_PARAMS["health_object_3"]["port"]) sharkradarDbutils.deleteServiceByNameAndIpAndPort( TEST_PARAMS["health_object_4"]["service_name"], TEST_PARAMS["health_object_4"]["ip"], TEST_PARAMS["health_object_4"]["port"]) conn = sqlite3.connect(Config.getDbPath()) conn.execute("""DELETE FROM SERVICE_LOGS WHERE 1 = 1""") conn.execute("""DELETE FROM DISCOVERY_LOGS WHERE 1 = 1""") conn.commit() conn.close()
def test_002_health_status_deregister(foreach_test): """ Deregister service """ conn = sqlite3.connect(Config.getDbPath()) service_instances = conn.execute( """SELECT * from SERVICE_RD WHERE SERVICE_NAME = ?""", (TEST_PARAMS["health_object_2"]["service_name"], )).fetchall() conn.close() assert len(service_instances) > 0 Health.health(TEST_PARAMS["health_object_2_down"]) conn = sqlite3.connect(Config.getDbPath()) service_instances = conn.execute( """SELECT * from SERVICE_RD WHERE SERVICE_NAME = ?""", (TEST_PARAMS["health_object_2"]["service_name"], )).fetchall() conn.close() assert len(service_instances) == 0
def test_003_health_status_update(foreach_test): """ Update service health data""" conn = sqlite3.connect(Config.getDbPath()) service_instances = conn.execute( """SELECT * from SERVICE_RD WHERE SERVICE_NAME = ?""", (TEST_PARAMS["health_object_2"]["service_name"], )).fetchall() conn.close() assert service_instances[0][3] == 41.2 Health.health(TEST_PARAMS["health_object_2_updated"]) conn = sqlite3.connect(Config.getDbPath()) service_instances = conn.execute( """SELECT * from SERVICE_RD WHERE SERVICE_NAME = ?""", (TEST_PARAMS["health_object_2"]["service_name"], )).fetchall() conn.close() assert service_instances[0][3] == 61.2
def insertDiscoveryPersist( service_name, ip, port, current_time_stamp, status, retryid): """ Insert discovery details persistant @params:service_name: A string, representing the service name @params:ip: IP address of the service @params:port : Port number of the service @params:current_time_stamp: Current time stamp @params:status: Status of the service @params:retryid: Retry ID for the discovery log """ DB_PATH = Config.getDbPath() conn = sqlite3.connect(DB_PATH) conn.execute( """INSERT INTO DISCOVERY_LOGS (SERVICE_NAME, IP, PORT, TIME_STAMP, STATUS, RETRY_ID) \ VALUES (?, ?, ?, ?, ?, ?)""", (service_name, ip, port, current_time_stamp, status, retryid)) conn.commit() conn.close()
def createTableIfNotExists(): """ Creates the SERVICE_RD, SERVICE_LOGS table in SQLite3 file mode, if table doesn't exist Columns of Table KEYS: VALUES: --------- ------------- i) ip ip address associated with micro-service ii) port port associated with micro-service iii) service_name unique name of the micro-service iv) status status (up/down) sent from the micro-service v) mem_usage Current memory usage vi) cpu_usage Current CPU usage vii) network_throughput Current network throughput viii) req_active No. of requests currently being processed by the instance ix) success_rate Fraction of requests successfully served x) health_interval The time interval specified by the micro-service at which it will send health report to service R/D continuously xi) status Status of the discovery log xii) retry_id Retry ID in discovery log """ DB_PATH = Config.getDbPath() conn = sqlite3.connect(DB_PATH) conn.execute('''CREATE TABLE IF NOT EXISTS SERVICE_RD (SERVICE_NAME TEXT NOT NULL, IP TEXT NOT NULL, PORT TEXT NOT NULL, MEM_USAGE REAL NOT NULL, CPU_USAGE REAL NOT NULL, NW_TPUT_BW_RATIO REAL NOT NULL, REQ_ACTIVE_RATIO REAL NOT NULL, SUCCESS_RATE REAL NOT NULL, TIME_STAMP BIGINT NOT NULL, HEALTH_INTERVAL BIGINT NOT NULL);''') conn.execute('''CREATE TABLE IF NOT EXISTS SERVICE_LOGS (SERVICE_NAME TEXT NOT NULL, IP TEXT NOT NULL, PORT TEXT NOT NULL, MEM_USAGE REAL NOT NULL, CPU_USAGE REAL NOT NULL, NW_TPUT_BW_RATIO REAL NOT NULL, REQ_ACTIVE_RATIO REAL NOT NULL, SUCCESS_RATE REAL NOT NULL, TIME_STAMP BIGINT NOT NULL, HEALTH_INTERVAL BIGINT NOT NULL);''') conn.execute('''CREATE TABLE IF NOT EXISTS DISCOVERY_LOGS (SERVICE_NAME TEXT NOT NULL, IP TEXT NOT NULL, PORT TEXT NOT NULL, TIME_STAMP BIGINT NOT NULL, STATUS TEXT NOT NULL, RETRY_ID TEXT NOT NULL);''') conn.commit() conn.close()
def test_007_discover_service_remove_dead(foreach_test): """ Remove dead service while discovering""" conn = sqlite3.connect(Config.getDbPath()) service_instances = conn.execute( """SELECT * from SERVICE_RD WHERE SERVICE_NAME = ?""", (TEST_PARAMS["health_object_5_a"]["service_name"], )).fetchall() conn.close() assert len(service_instances) == 2 time.sleep(6) result = Discovery.discovery( TEST_PARAMS["health_object_5_a"]["service_name"], "start") conn = sqlite3.connect(Config.getDbPath()) service_instance = conn.execute( """SELECT * from SERVICE_RD WHERE SERVICE_NAME = ?""", (TEST_PARAMS["health_object_5_a"]["service_name"], )).fetchall() conn.close() assert len(service_instance) == 1 assert result[0] == TEST_PARAMS["health_object_5_b"]["ip"] assert result[1] == TEST_PARAMS["health_object_5_b"]["port"] assert result[2] != "start"
def getAllService(): """ Find all services at current time @return: List of the query results from DB """ DB_PATH = Config.getDbPath() conn = sqlite3.connect(DB_PATH) service_instances = conn.execute( """SELECT * from SERVICE_RD""").fetchall() conn.close() return service_instances
def test_009_health_status_register_check_logs(foreach_test): """ Register service and check service logs""" Health.health(TEST_PARAMS["health_object_1"]) time.sleep(2) Health.health(TEST_PARAMS["health_object_1"]) time.sleep(2) Health.health(TEST_PARAMS["health_object_1"]) conn = sqlite3.connect(Config.getDbPath()) service_instance = conn.execute( """SELECT * from SERVICE_LOGS""").fetchall() conn.close() assert len(service_instance) == 3
def test_005_discover_service_retry(foreach_test): """ Discover service retry""" result = Discovery.discovery( TEST_PARAMS["health_object_4"]["service_name"], "start") assert TEST_PARAMS["health_object_4"]["ip"] == result[0] assert TEST_PARAMS["health_object_4"]["port"] == result[1] assert result[2] != "start" conn = sqlite3.connect(Config.getDbPath()) service_instances = conn.execute( """SELECT * from DISCOVERY_LOGS WHERE SERVICE_NAME = ? AND IP = ? AND PORT = ?""", (TEST_PARAMS["health_object_4"]["service_name"], TEST_PARAMS["health_object_4"]["ip"], TEST_PARAMS["health_object_4"]["port"])).fetchall() conn.close() assert service_instances[0][4] == "SUCCESS" Discovery.discovery(TEST_PARAMS["health_object_4"]["service_name"], result[2]) conn = sqlite3.connect(Config.getDbPath()) service_instances = conn.execute( """SELECT * from DISCOVERY_LOGS WHERE RETRY_ID = ?""", (result[2], )).fetchall() conn.close() assert service_instances[0][4] == "FAIL"
def getDiscoveryPersist(limit=250): """ Fetch service log records by limit @params:limit: latest n records @return: List of the query results from DB """ DB_PATH = Config.getDbPath() conn = sqlite3.connect(DB_PATH) service_instances = conn.execute( """SELECT * from DISCOVERY_LOGS ORDER BY TIME_STAMP DESC LIMIT ?""", (limit,)).fetchall() conn.close() return service_instances
def discovery(service_name, retryid): """ Function to fetch details of a micro-services from Service R/D @params: service_name: Unique service name of the micro-service @param: retryid : Retry id - start = first try , else retry @return: A tuple containing ip and port of the active micro-service instance """ sharkradarDbutils.deleteServiceByNameAndTimestampDifferenceWithHealthInterval( service_name) service_instances = sharkradarDbutils.findServiceByName(service_name) if retryid != "start": sharkradarDbutils.updateDiscoveryPersist("FAIL", retryid) retryid = str(int(time.time())) + str(random.randint(10000, 99999)) if len(service_instances) > 0: if Config.getAlgorithm() == "wpmc": ip, port = sharkradarAlgorithmutils.weightedPriorityMemAndCPU( service_instances) sharkradarDbutils.insertDiscoveryPersist( service_name, ip, port, int(time.time()), "SUCCESS", retryid) return (ip, port, retryid) if Config.getAlgorithm() == "wprs": ip, port = sharkradarAlgorithmutils.weightedPriorityReqActiveAndSuccessRate( service_instances) sharkradarDbutils.insertDiscoveryPersist( service_name, ip, port, int(time.time()), "SUCCESS", retryid) return (ip, port, retryid) if Config.getAlgorithm() == "wrel": ip, port = sharkradarAlgorithmutils.weightedPriorityReliabilityScore( service_instances, Config.getLastRecords()) sharkradarDbutils.insertDiscoveryPersist( service_name, ip, port, int(time.time()), "SUCCESS", retryid) return (ip, port, retryid) return ("", "", "")
def findServiceByName(service_name): """ Find services by service name @params:service_name: A string, representing the service name @return: List of the query results from DB """ DB_PATH = Config.getDbPath() conn = sqlite3.connect(DB_PATH) service_instances = conn.execute( """SELECT * from SERVICE_RD WHERE SERVICE_NAME = ?""", (service_name, )).fetchall() conn.close() return service_instances
def deleteServiceByNameAndTimestampDifferenceWithHealthInterval(service_name): """ Find services by service name, based on services who are declared dead Dead -> Services who haven't sent health status post their health interval @params:service_name: A string, representing the service name """ DB_PATH = Config.getDbPath() conn = sqlite3.connect(DB_PATH) current_time_epoch = time.time() conn.execute( """DELETE FROM SERVICE_RD WHERE SERVICE_NAME = ? AND ? - TIME_STAMP > HEALTH_INTERVAL""", (service_name, current_time_epoch)) conn.commit() conn.close()
def deleteServiceByNameAndIpAndPort(service_name, ip, port): """ Delete services by service name, Ip and port @params:service_name: A string, representing the service name @params:ip: IP Address of the service @params:port: Port number of the service """ DB_PATH = Config.getDbPath() conn = sqlite3.connect(DB_PATH) conn.execute( """DELETE FROM SERVICE_RD WHERE SERVICE_NAME = ? AND IP = ? AND PORT = ?""", (service_name, ip, port)) conn.commit() conn.close()
def updateServiceByAll( current_time_stamp, health_interval, mem_usage, cpu_usage, nw_tput_bw_ratio, req_active_ratio, success_rate, service_name, ip, port): """ Update services details @params:current_time_stamp: Current time stamp @params:health_interval: Health interval frequency in secs, the maximum threshold after which if health status is not received, the service will be de-registered @params:mem_usage: Memory usage in % of service @params:cpu_usage: CPU usage in % of service @params:nw_tput_bw_ratio: Ratio of current network throughput with maximum capacity (bandwidth) in % @params:req_active_ratio: Ratio of current requests being handled with maximum requests limit in % @param:success_rate: Ratio of successful response by total requests in % @params:service_name: A string, representing the service name @params:ip: IP address of the service @params:port : Port number of the service @return: Total number of rows updated """ DB_PATH = Config.getDbPath() conn = sqlite3.connect(DB_PATH) conn.execute( """UPDATE SERVICE_RD SET TIME_STAMP = ?, HEALTH_INTERVAL = ?, MEM_USAGE = ?, CPU_USAGE = ?, NW_TPUT_BW_RATIO = ?, REQ_ACTIVE_RATIO = ?, SUCCESS_RATE = ? WHERE SERVICE_NAME = ? AND IP = ? AND PORT = ?""", (current_time_stamp, health_interval, mem_usage, cpu_usage, nw_tput_bw_ratio, req_active_ratio, success_rate, service_name, ip, port)) conn.commit() total_changes = conn.total_changes conn.close() return total_changes
def findServiceByNameAndIpAndPort(service_name, ip, port): """ Find services by service name, IP address and port number @params:service_name: A string, representing the service name @params:ip: IP address of the service @params:port : Port number of the service @return: List of the query results from DB """ DB_PATH = Config.getDbPath() conn = sqlite3.connect(DB_PATH) response = conn.execute( """SELECT * FROM SERVICE_RD WHERE SERVICE_NAME = ? AND IP = ? AND PORT = ?""", (service_name, ip, port)).fetchall() conn.close() return response
def insertServiceByAllPersist( service_name, ip, port, current_time_stamp, health_interval, mem_usage, cpu_usage, nw_tput_bw_ratio, req_active_ratio, success_rate): """ Insert services details persistant @params:service_name: A string, representing the service name @params:ip: IP address of the service @params:port : Port number of the service @params:current_time_stamp: Current time stamp @params:health_interval: Health interval frequency in secs, the maximum threshold after which if health status is not received, the service will be de-registered @params:mem_usage: Memory usage in % of service @params:cpu_usage: CPU usage in % of service @params:nw_tput_bw_ratio: Ratio of current network throughput with maximum capacity (bandwidth) in % @params:req_active_ratio: Ratio of current requests being handled with maximum requests limit in % @param:success_rate: Ratio of successful response by total requests in % """ DB_PATH = Config.getDbPath() conn = sqlite3.connect(DB_PATH) conn.execute( """INSERT INTO SERVICE_LOGS (SERVICE_NAME, IP, PORT, TIME_STAMP, HEALTH_INTERVAL, MEM_USAGE, CPU_USAGE, NW_TPUT_BW_RATIO, REQ_ACTIVE_RATIO, SUCCESS_RATE) \ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""", (service_name, ip, port, current_time_stamp, health_interval, mem_usage, cpu_usage, nw_tput_bw_ratio, req_active_ratio, success_rate)) conn.commit() conn.close()
def getLatestRecordsDiscoveryLogs(service_name, ip, port, latest_records): """ Fetch latest n records from discovery logs corresponding to service name, IP and port @params:service_name: A string representing service name @params:ip: IP address @params:port: Port numbers @params:latest_records: Limit @return: List of records in ordered by desc timestamp """ DB_PATH = Config.getDbPath() conn = sqlite3.connect(DB_PATH) discovery_instances = conn.execute( """SELECT STATUS FROM DISCOVERY_LOGS WHERE SERVICE_NAME = ? AND IP = ? AND PORT = ? ORDER BY TIME_STAMP DESC LIMIT ?""", (service_name, ip, port, latest_records)).fetchall() conn.close() return discovery_instances
def updateDiscoveryPersist( status, retryid): """ Update discovery details persistant @params:service_name: A string, representing the service name @params:ip: IP address of the service @params:port : Port number of the service @params:current_time_stamp: Current time stamp @params:status: Status of the service @params:retryid: Retry ID for the discovery log """ DB_PATH = Config.getDbPath() conn = sqlite3.connect(DB_PATH) conn.execute( """UPDATE DISCOVERY_LOGS SET STATUS = ? WHERE RETRY_ID = ?""", (status, retryid)) conn.commit() conn.close()
def main(addr, port, dbpath, algorithm, last_records): """ Sharkradar - Command Line Interface (CLI) utility =================================================== Sharkradar is a lightweight service registry and discovery tool, developed keeping in mind the idea of compatibility with any HTTP microservice (service framework independent) """ cprint(figlet_format('SHARKRADAR', font='slant'), 'blue', attrs=['bold']) try: Config.setDbPath(dbpath) Config.setAlgorithm(algorithm) Config.setLastRecords(int(last_records)) from sharkradar.Controller.Controller import app serve(app, listen=addr + ":" + str(port)) except Exception as e: click.echo( "Exception occurred while starting sharkradar [{0}]\nRun 'sharkradar --help' for help" .format(str(e))) sys.exit(5)
def test_002_get_algo_without_set(): """ Test blank Algo """ assert Config.getAlgorithm() == ""
def test_002_get_dbpath_with_set(): """ Test blank DB Path """ Config.setDbPath("ABC") assert Config.getDbPath() == "ABC/sharkradar_service.db"
def test_002_get_algo_with_set(): """ Test blank Algo """ Config.setAlgorithm("ABC") assert Config.getAlgorithm() == "ABC"
def test_001_get_dbpath_without_set(): """ Test blank DB Path """ assert Config.getDbPath() == ""
def foreach_test(): print("Setup before test") """ Test Environment Setup for each test case """ Config.setDbPath(os.path.join(basedir, "src/sharkradar/Util")) Config.setAlgorithm("wpmc") sharkradarDbutils.createTableIfNotExists() conn = sqlite3.connect(Config.getDbPath()) conn.execute( """INSERT INTO SERVICE_RD (SERVICE_NAME, IP, PORT, TIME_STAMP, HEALTH_INTERVAL, MEM_USAGE, CPU_USAGE, NW_TPUT_BW_RATIO, REQ_ACTIVE_RATIO, SUCCESS_RATE) \ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""", (TEST_PARAMS["health_object_2"]["service_name"], TEST_PARAMS["health_object_2"]["ip"], TEST_PARAMS["health_object_2"]["port"], TEST_PARAMS["health_object_2"]["current_timestamp"], TEST_PARAMS["health_object_2"]["health_interval"], TEST_PARAMS["health_object_2"]["mem_usage"], TEST_PARAMS["health_object_2"]["cpu_usage"], TEST_PARAMS["health_object_2"]["nw_tput_bw_ratio"], TEST_PARAMS["health_object_2"]["req_active_ratio"], TEST_PARAMS["health_object_2"]["success_rate"])) conn.commit() conn.execute( """INSERT INTO SERVICE_RD (SERVICE_NAME, IP, PORT, TIME_STAMP, HEALTH_INTERVAL, MEM_USAGE, CPU_USAGE, NW_TPUT_BW_RATIO, REQ_ACTIVE_RATIO, SUCCESS_RATE) \ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""", (TEST_PARAMS["health_object_4"]["service_name"], TEST_PARAMS["health_object_4"]["ip"], TEST_PARAMS["health_object_4"]["port"], TEST_PARAMS["health_object_4"]["current_timestamp"], TEST_PARAMS["health_object_4"]["health_interval"], TEST_PARAMS["health_object_4"]["mem_usage"], TEST_PARAMS["health_object_4"]["cpu_usage"], TEST_PARAMS["health_object_4"]["nw_tput_bw_ratio"], TEST_PARAMS["health_object_4"]["req_active_ratio"], TEST_PARAMS["health_object_4"]["success_rate"])) conn.commit() conn.execute( """INSERT INTO SERVICE_RD (SERVICE_NAME, IP, PORT, TIME_STAMP, HEALTH_INTERVAL, MEM_USAGE, CPU_USAGE, NW_TPUT_BW_RATIO, REQ_ACTIVE_RATIO, SUCCESS_RATE) \ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""", (TEST_PARAMS["health_object_3_a"]["service_name"], TEST_PARAMS["health_object_3_a"]["ip"], TEST_PARAMS["health_object_3_a"]["port"], TEST_PARAMS["health_object_3_a"]["current_timestamp"], TEST_PARAMS["health_object_3_a"]["health_interval"], TEST_PARAMS["health_object_3_a"]["mem_usage"], TEST_PARAMS["health_object_3_a"]["cpu_usage"], TEST_PARAMS["health_object_3_a"]["nw_tput_bw_ratio"], TEST_PARAMS["health_object_3_a"]["req_active_ratio"], TEST_PARAMS["health_object_3_a"]["success_rate"])) conn.commit() conn.execute( """INSERT INTO SERVICE_RD (SERVICE_NAME, IP, PORT, TIME_STAMP, HEALTH_INTERVAL, MEM_USAGE, CPU_USAGE, NW_TPUT_BW_RATIO, REQ_ACTIVE_RATIO, SUCCESS_RATE) \ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""", (TEST_PARAMS["health_object_3_b"]["service_name"], TEST_PARAMS["health_object_3_b"]["ip"], TEST_PARAMS["health_object_3_b"]["port"], TEST_PARAMS["health_object_3_b"]["current_timestamp"], TEST_PARAMS["health_object_3_b"]["health_interval"], TEST_PARAMS["health_object_3_b"]["mem_usage"], TEST_PARAMS["health_object_3_b"]["cpu_usage"], TEST_PARAMS["health_object_3_b"]["nw_tput_bw_ratio"], TEST_PARAMS["health_object_3_b"]["req_active_ratio"], TEST_PARAMS["health_object_3_b"]["success_rate"])) conn.commit() conn.execute( """INSERT INTO SERVICE_RD (SERVICE_NAME, IP, PORT, TIME_STAMP, HEALTH_INTERVAL, MEM_USAGE, CPU_USAGE, NW_TPUT_BW_RATIO, REQ_ACTIVE_RATIO, SUCCESS_RATE) \ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""", (TEST_PARAMS["health_object_5_a"]["service_name"], TEST_PARAMS["health_object_5_a"]["ip"], TEST_PARAMS["health_object_5_a"]["port"], TEST_PARAMS["health_object_5_a"]["current_timestamp"], TEST_PARAMS["health_object_5_a"]["health_interval"], TEST_PARAMS["health_object_5_a"]["mem_usage"], TEST_PARAMS["health_object_5_a"]["cpu_usage"], TEST_PARAMS["health_object_5_a"]["nw_tput_bw_ratio"], TEST_PARAMS["health_object_5_a"]["req_active_ratio"], TEST_PARAMS["health_object_5_a"]["success_rate"])) conn.commit() conn.execute( """INSERT INTO SERVICE_RD (SERVICE_NAME, IP, PORT, TIME_STAMP, HEALTH_INTERVAL, MEM_USAGE, CPU_USAGE, NW_TPUT_BW_RATIO, REQ_ACTIVE_RATIO, SUCCESS_RATE) \ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""", (TEST_PARAMS["health_object_5_b"]["service_name"], TEST_PARAMS["health_object_5_b"]["ip"], TEST_PARAMS["health_object_5_b"]["port"], TEST_PARAMS["health_object_5_b"]["current_timestamp"], TEST_PARAMS["health_object_5_b"]["health_interval"], TEST_PARAMS["health_object_5_b"]["mem_usage"], TEST_PARAMS["health_object_5_b"]["cpu_usage"], TEST_PARAMS["health_object_5_b"]["nw_tput_bw_ratio"], TEST_PARAMS["health_object_5_b"]["req_active_ratio"], TEST_PARAMS["health_object_5_b"]["success_rate"])) conn.commit() conn.close() yield "" print("Teardown after test") """ Test Environment Clean up for each test case """ conn = sqlite3.connect(Config.getDbPath()) conn.execute("""DELETE FROM SERVICE_RD WHERE SERVICE_NAME = ?""", (TEST_PARAMS["health_object_1"]["service_name"], )) conn.commit() conn.execute("""DELETE FROM SERVICE_RD WHERE SERVICE_NAME = ?""", (TEST_PARAMS["health_object_2"]["service_name"], )) conn.commit() conn.execute("""DELETE FROM SERVICE_RD WHERE SERVICE_NAME = ?""", (TEST_PARAMS["health_object_3_a"]["service_name"], )) conn.commit() conn.execute("""DELETE FROM SERVICE_RD WHERE SERVICE_NAME = ?""", (TEST_PARAMS["health_object_4"]["service_name"], )) conn.commit() conn.execute("""DELETE FROM SERVICE_RD WHERE SERVICE_NAME = ?""", (TEST_PARAMS["health_object_5_a"]["service_name"], )) conn.commit() conn.execute("""DELETE FROM SERVICE_LOGS WHERE 1 = 1""") conn.execute("""DELETE FROM DISCOVERY_LOGS WHERE 1 = 1""") conn.commit() conn.close()