diff --git a/tests/IntegrationTests/test_data_arrived.py b/tests/IntegrationTests/test_data_arrived.py deleted file mode 100644 index db80487..0000000 --- a/tests/IntegrationTests/test_data_arrived.py +++ /dev/null @@ -1,61 +0,0 @@ -import glob -import json -import os -from os.path import abspath, dirname -import requests -import unittest - - -def _search_data(query): - """ - Send given search query to logzio and returns the result. - :param query: - :return: - """ - # Search logs in account - url = "https://api.logz.io/v1/search" - headers = { - "X-API-TOKEN": os.environ["LOGZIO_API_TOKEN"], - "CONTENT-TYPE": "application/json", - "ACCEPT": "application/json" - } - body = { - "query": { - "query_string": { - "query": query - } - } - } - - r = requests.post(url=url, headers=headers, json=body) - if r: - data = json.loads(r.text) - hits = data.get("hits").get("hits") - return hits - return [] - - -def delete_temp_files(): - """ - delete the temp config that generated for the test - """ - curr_path = abspath(dirname(dirname(__file__))) - test_configs_path = f"{curr_path}/testConfigs/*_temp.yaml" - - for file in glob.glob(test_configs_path): - os.remove(file) - - -class TestDataArrived(unittest.TestCase): - """ - Test data arrived to logzio - """ - - @classmethod - def tearDownClass(cls): - # Clean up temp files that the test created - delete_temp_files() - - def test_data_in_logz(self): - azure_logs_in_acc = _search_data("type:azure_graph_shipping_test") - self.assertTrue(azure_logs_in_acc) # make sure we have results diff --git a/tests/IntegrationTests/test_shipping.py b/tests/IntegrationTests/test_shipping.py deleted file mode 100644 index 114111b..0000000 --- a/tests/IntegrationTests/test_shipping.py +++ /dev/null @@ -1,55 +0,0 @@ -import os -from os.path import abspath, dirname -import threading -import yaml - -from src.main import main - - -curr_path = abspath(dirname(dirname(__file__))) -temp_int_conf_path = f"{abspath(dirname(dirname(dirname(__file__))))}/src/shared/config.yaml" -test_config_paths = [f"{curr_path}/testConfigs/azure_api_conf.yaml"] - - -def _update_config_tokens(file_path): - """ - Updates the tokens in the given file. - """ - with open(file_path, "r") as conf: - content = yaml.safe_load(conf) - - content["apis"][0]["azure_ad_tenant_id"] = os.environ["AZURE_AD_TENANT_ID"] - content["apis"][0]["azure_ad_client_id"] = os.environ["AZURE_AD_CLIENT_ID"] - content["apis"][0]["azure_ad_secret_value"] = os.environ["AZURE_AD_SECRET_VALUE"] - content["logzio"]["token"] = os.environ["LOGZIO_SHIPPING_TOKEN"] - - path, ext = file_path.split(".") - temp_test_path = f"{path}_temp.{ext}" - - with open(temp_test_path, "w") as file: - yaml.dump(content, file) - - return temp_test_path - - -def integration_test(): - """ - Runs the integration to send real data - """ - threads = [] - - # in case we want to add more configs to the integration test in the future; - for file in test_config_paths: - temp_file = _update_config_tokens(file) - thread = threading.Thread(target=main, args=(temp_file, True,)) - threads.append(thread) - - for thread in threads: - thread.start() - - for thread in threads: - thread.join() - - -if __name__ == '__main__': - integration_test()