Skip to content

Commit

Permalink
Merge pull request #572 from Bee-lee/dbily-fix-dvo-migration
Browse files Browse the repository at this point in the history
fix aggregator scenarios by running dvo migrations too
  • Loading branch information
Bee-lee authored Feb 6, 2024
2 parents 17f1ad0 + ebcb240 commit 9a344b3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
8 changes: 4 additions & 4 deletions config/insights_results_aggregator_wrong_db.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ type = "sql"

[dvo_recommendations_storage]
db_driver = "postgres"
pg_username = "postgres"
pg_password = "postgres"
pg_host = "database"
pg_username = "wrong-one"
pg_password = "wrong-one"
pg_host = "wrong-one"
pg_port = 5432
pg_db_name = "test"
pg_db_name = "wrong-one"
pg_params = "sslmode=disable"
log_sql_queries = true
type = "sql"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Feature: Checking Aggregator behaviour during starting the service
When I store current environment without Insights Results Aggregator variables
And I run the Insights Results Aggregator with the start-service command line flag and config file name set to config/insights_results_aggregator_wrong_db.toml
Then The process should finish with exit code 2
And I should see following message in service output: "Unable to initialize DB schema"
And I should see following message in service output: "dial tcp: lookup wrong-one: no such host"
And I should see following message in service output: "database preparation exited with error code 2"


Expand Down
13 changes: 13 additions & 0 deletions features/steps/insights_results_aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,28 @@ def check_actual_configuration_for_aggregator(context):
@when("I migrate aggregator database to version #{version:n}")
def perform_aggregator_database_migration(context, version):
"""Perform aggregator database migration to selected version."""
environ = os.environ.copy()
environ["INSIGHTS_RESULTS_AGGREGATOR__STORAGE_BACKEND__USE"] = "dvo_recommendations"
# run DVO migrations first to not mess with the OCP migrations output we're checking later
out = subprocess.Popen(
[INSIGHTS_RESULTS_AGGREGATOR_BINARY, "migrate", str(version)],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
env=environ,
)

# check if subprocess has been started and its output caught
assert out is not None

# run OCP migrations
out = subprocess.Popen(
[INSIGHTS_RESULTS_AGGREGATOR_BINARY, "migrate", str(version)],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)

assert out is not None

# it is expected that exit code will be 0 or 2
stdout_file = filepath_from_context(context, "logs/insights-results-aggregator/", "_stdout")
stderr_file = filepath_from_context(context, "logs/insights-results-aggregator/", "_stderr")
Expand Down

0 comments on commit 9a344b3

Please sign in to comment.