Skip to content

Commit 4f560ba

Browse files
authored
Clean up data (drop created table) after running E2E tests (#269)
* Clean up data (drop created table) after running E2E tests. I remove a separate function that drops the table which was executed before starting the tests. Since the generated table name includes a second-based timestamp, this should only be necessary if the previous execution was *started* within 1 second of the current execution, including the time it took to create the table. As surprising as that might be (even if it failed immediately after creating the table and was then reexecuted), the function must've been added when this or some other situation that made this necessary was encountered. Adding randomness to the table's name should solve the same issue, but faster to reduce the E2E's already long runtime. * Make black happy
1 parent 66f7b31 commit 4f560ba

File tree

1 file changed

+4
-11
lines changed
  • azure-kusto-ingest/tests

1 file changed

+4
-11
lines changed

azure-kusto-ingest/tests/e2e.py

+4-11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import datetime
44
import io
55
import os
6+
import random
67
import sys
78
import time
89
import uuid
@@ -30,9 +31,6 @@
3031
class TestData:
3132
"""A class to define mappings to deft table."""
3233

33-
def __init__(self):
34-
pass
35-
3634
@staticmethod
3735
def test_table_csv_mappings():
3836
"""A method to define csv mappings to test table."""
@@ -126,8 +124,8 @@ def dm_kcsb_from_env() -> KustoConnectionStringBuilder:
126124
return KustoConnectionStringBuilder.with_aad_application_key_authentication(dm_cs, app_id, app_key, auth_id)
127125

128126

129-
def clean_previous_tests(engine_client, database, table):
130-
engine_client.execute(database, ".drop table {0} ifexists".format(table))
127+
def teardown_module():
128+
client.execute(test_db, ".drop table {} ifexists".format(test_table))
131129

132130

133131
def get_file_path() -> str:
@@ -144,14 +142,13 @@ def get_file_path() -> str:
144142
test_db = os.environ.get("TEST_DATABASE")
145143

146144
python_version = "_".join([str(v) for v in sys.version_info[:3]])
147-
test_table = "python_test_{0}_{1}".format(python_version, str(int(time.time())))
145+
test_table = "python_test_{0}_{1}_{2}".format(python_version, str(int(time.time())), random.randint(1, 100000))
148146
client = KustoClient(engine_kcsb_from_env())
149147
ingest_client = KustoIngestClient(dm_kcsb_from_env())
150148
streaming_ingest_client = KustoStreamingIngestClient(engine_kcsb_from_env())
151149

152150
start_time = datetime.datetime.now(datetime.timezone.utc)
153151

154-
clean_previous_tests(client, test_db, test_table)
155152
input_folder_path = get_file_path()
156153

157154
csv_file_path = os.path.join(input_folder_path, "dataset.csv")
@@ -391,7 +388,3 @@ def test_streaming_ingest_from_dataframe():
391388
ingest_client.ingest_from_dataframe(df, ingestion_properties)
392389

393390
assert_rows_added(1, timeout=120)
394-
395-
396-
def pytest_sessionfinish(session, exitstatus):
397-
client.execute(test_db, ".drop table {} ifexists".format(test_table))

0 commit comments

Comments
 (0)