Skip to content

Commit

Permalink
Merge pull request #5813 from os-autoinst/revert-4928-feature/shared_…
Browse files Browse the repository at this point in the history
…plugin_gru_uncovered

Revert "Remove unused 'dsn' function and its usage"
  • Loading branch information
baierjan authored Aug 1, 2024
2 parents 6e1262d + b34ad05 commit 4389076
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/OpenQA/Schema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ sub disconnect_db () {
$SINGLETON = undef;
}

sub dsn {
my $self = shift;
return $self->storage->connect_info->[0]->{dsn};
}

sub deploy ($self, $force_overwrite = 0) {
# lock config file to ensure only one thing will deploy/upgrade DB at once
# we use a file in prjdir/db as the lock file as the install process and
Expand Down
10 changes: 8 additions & 2 deletions lib/OpenQA/Shared/Plugin/Gru.pm
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,14 @@ sub register ($self, $app, $config) {
my $schema = $app->schema;

my $conn = Mojo::Pg->new;
my $connect_info = $schema->storage->connect_info->[0];
$self->dsn($connect_info);
if (ref $schema->storage->connect_info->[0] eq 'HASH') {
$self->dsn($schema->dsn);
$conn->username($schema->storage->connect_info->[0]->{user});
$conn->password($schema->storage->connect_info->[0]->{password});
}
else {
$self->dsn($schema->storage->connect_info->[0]);
}
$conn->dsn($self->dsn());

# set the search path in accordance with the test setup done in OpenQA::Test::Database
Expand Down

0 comments on commit 4389076

Please sign in to comment.