Skip to content

Commit 9c20a6b

Browse files
author
ci bot
committed
Merge branch 'aarthy/test-execution' into 'enterprise'
feat(test-execution): add progress and error handling See merge request dkinternal/testgen/dataops-testgen!340
2 parents f787961 + bebfae5 commit 9c20a6b

94 files changed

Lines changed: 1177 additions & 1782 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

testgen/__main__.py

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
import subprocess
55
import sys
66
from dataclasses import dataclass, field
7+
from datetime import UTC, datetime, timedelta
78

89
import click
910
from click.core import Context
10-
from progress.spinner import MoonSpinner
1111

1212
from testgen import settings
13-
from testgen.commands.run_execute_tests import run_execution_steps
1413
from testgen.commands.run_generate_tests import run_test_gen_queries
1514
from testgen.commands.run_get_entities import (
1615
run_get_results,
@@ -31,6 +30,7 @@
3130
from testgen.commands.run_observability_exporter import run_observability_exporter
3231
from testgen.commands.run_profiling import run_profiling
3332
from testgen.commands.run_quick_start import run_quick_start, run_quick_start_increment
33+
from testgen.commands.run_test_execution import run_test_execution
3434
from testgen.commands.run_test_metadata_exporter import run_test_metadata_exporter
3535
from testgen.commands.run_upgrade_db_config import get_schema_revision, is_db_revision_up_to_date, run_upgrade_db_config
3636
from testgen.common import (
@@ -45,6 +45,7 @@
4545
from testgen.common.models import with_database_session
4646
from testgen.common.models.profiling_run import ProfilingRun
4747
from testgen.common.models.test_run import TestRun
48+
from testgen.common.models.test_suite import TestSuite
4849
from testgen.scheduler import register_scheduler_job, run_scheduler
4950
from testgen.utils import plugins
5051

@@ -159,28 +160,40 @@ def run_test_generation(configuration: Configuration, table_group_id: str, test_
159160

160161
@register_scheduler_job
161162
@cli.command("run-tests", help="Performs tests defined for a test suite.")
163+
@click.option(
164+
"-t",
165+
"--test-suite-id",
166+
required=False,
167+
type=click.STRING,
168+
help="ID of the test suite to run. Use a test_suite_id shown in list-test-suites.",
169+
)
162170
@click.option(
163171
"-pk",
164172
"--project-key",
165-
help="The identifier for a TestGen project. Use a project_key shown in list-projects.",
173+
help="DEPRECATED. Use --test-suite-id instead.",
166174
required=False,
167175
type=click.STRING,
168176
default=settings.PROJECT_KEY,
169177
)
170178
@click.option(
171179
"-ts",
172180
"--test-suite-key",
173-
help="The identifier for a test suite. Use a test_suite_key shown in list-test-suites.",
181+
help="DEPRECATED. Use --test-suite-id instead.",
174182
required=False,
175183
default=settings.DEFAULT_TEST_SUITE_KEY,
176184
)
177-
@pass_configuration
178-
def run_tests(configuration: Configuration, project_key: str, test_suite_key: str):
179-
click.echo(f"run-tests for suite: {test_suite_key}")
180-
spinner = None
181-
if not configuration.verbose:
182-
spinner = MoonSpinner("Processing ... ")
183-
message = run_execution_steps(project_key, test_suite_key, spinner=spinner)
185+
@with_database_session
186+
def run_tests(test_suite_id: str | None = None, project_key: str | None = None, test_suite_key: str | None = None):
187+
click.echo(f"run-tests for suite: {test_suite_id or test_suite_key}")
188+
# For backward compatibility
189+
if not test_suite_id:
190+
test_suites = TestSuite.select_minimal_where(
191+
TestSuite.project_code == project_key,
192+
TestSuite.test_suite == test_suite_key,
193+
)
194+
if test_suites:
195+
test_suite_id = test_suites[0].id
196+
message = run_test_execution(test_suite_id)
184197
click.echo("\n" + message)
185198

186199

@@ -366,24 +379,27 @@ def quick_start(
366379

367380
click.echo("loading initial data")
368381
run_quick_start_increment(0)
369-
minutes_offset = -30*24*60 # 1 month ago
370-
table_group_id="0ea85e17-acbe-47fe-8394-9970725ad37d"
382+
now_date = datetime.now(UTC)
383+
time_delta = timedelta(days=-30) # 1 month ago
384+
table_group_id = "0ea85e17-acbe-47fe-8394-9970725ad37d"
385+
test_suite_id = "9df7489d-92b3-49f9-95ca-512160d7896f"
371386

372387
click.echo(f"run-profile with table_group_id: {table_group_id}")
373-
message = run_profiling(table_group_id, minutes_offset=minutes_offset)
388+
message = run_profiling(table_group_id, run_date=now_date + time_delta)
374389
click.echo("\n" + message)
375390

376391
LOG.info(f"run-test-generation with table_group_id: {table_group_id} test_suite: {settings.DEFAULT_TEST_SUITE_KEY}")
377392
message = run_test_gen_queries(table_group_id, settings.DEFAULT_TEST_SUITE_KEY)
378393
click.echo("\n" + message)
379394

380-
run_execution_steps(settings.PROJECT_KEY, settings.DEFAULT_TEST_SUITE_KEY, minutes_offset=minutes_offset)
395+
run_test_execution(test_suite_id, run_date=now_date + time_delta)
381396

382-
for iteration in range(1, 4):
383-
click.echo(f"Running iteration: {iteration} / 3")
384-
minutes_offset = -10*24*60 * (3-iteration)
397+
total_iterations = 3
398+
for iteration in range(1, total_iterations + 1):
399+
click.echo(f"Running iteration: {iteration} / {total_iterations}")
400+
run_date = now_date + timedelta(days=-10 * (total_iterations - iteration)) # 10 day increments
385401
run_quick_start_increment(iteration)
386-
run_execution_steps(settings.PROJECT_KEY, settings.DEFAULT_TEST_SUITE_KEY, minutes_offset=minutes_offset)
402+
run_test_execution(test_suite_id, run_date=run_date)
387403

388404
click.echo("Quick start has successfully finished.")
389405

testgen/commands/queries/execute_cat_tests_query.py

Lines changed: 0 additions & 123 deletions
This file was deleted.

0 commit comments

Comments
 (0)