- Notifications
You must be signed in to change notification settings - Fork27
[PGPRO-3690] Tests for progress_bar.#41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
6 changes: 6 additions & 0 deletionsMakefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletionspg_query_state.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletionst/test_bad_progress_bar.pl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # pg_query_state/t/test_bad_progress_bar.pl | ||
| # | ||
| # Check uncorrect launches of functions progress_bar(pid) | ||
| # and progress_bar_visual(pid, delay) | ||
| use strict; | ||
| use warnings; | ||
| use PostgresNode; | ||
| use TestLib; | ||
| use Test::More tests => 2; | ||
| # List of checks for bad cases: | ||
| # 1) appealing to a bad pid | ||
| # ------- requires DBI and DBD::Pg modules ------- | ||
| # 2) extracting the state of the process itself | ||
| # Test whether we have both DBI and DBD::pg | ||
| my $dbdpg_rc = eval | ||
| { | ||
| require DBI; | ||
| require DBD::Pg; | ||
| DBD::Pg->import(':async'); | ||
| 1; | ||
| }; | ||
| # start backend for function progress_bar | ||
| my $node = PostgresNode->get_new_node('master'); | ||
| $node->init; | ||
| $node->start; | ||
| $node->append_conf('postgresql.conf', "shared_preload_libraries = 'pg_query_state'"); | ||
| $node->restart; | ||
| $node->psql('postgres', 'CREATE EXTENSION pg_query_state;'); | ||
| subtest 'Extracting from bad pid' => sub { | ||
| my $stderr; | ||
| $node->psql('postgres', 'SELECT * from progress_bar(-1)', stderr => \$stderr); | ||
| is ($stderr, 'psql:<stdin>:1: ERROR: backend with pid=-1 not found', "appealing to a bad pid for progress_bar"); | ||
| $node->psql('postgres', 'SELECT * from progress_bar(-1)_visual', stderr => \$stderr); | ||
| is ($stderr, 'psql:<stdin>:1: ERROR: backend with pid=-1 not found', "appealing to a bad pid for progress_bar_visual"); | ||
| }; | ||
| if ( not $dbdpg_rc) { | ||
| diag('DBI and DBD::Pg are not available, skip 2/3 tests'); | ||
| } | ||
| SKIP: { | ||
| skip "DBI and DBD::Pg are not available", 2 if not $dbdpg_rc; | ||
| my $dbh_status = DBI->connect('DBI:Pg:' . $node->connstr($_)); | ||
| if ( !defined $dbh_status ) | ||
| { | ||
| die "Cannot connect to database for dbh with progress_bar\n"; | ||
| } | ||
| my $pid_status = $dbh_status->{pg_pid}; | ||
| subtest 'Extracting your own status' => sub { | ||
| $dbh_status->do('SELECT * from progress_bar(' . $pid_status . ')'); | ||
| is($dbh_status->errstr, 'ERROR: attempt to extract state of current process', "extracting the state of the process itself for progress_bar"); | ||
| $dbh_status->do('SELECT * from progress_bar_visual(' . $pid_status . ')'); | ||
| is($dbh_status->errstr, 'ERROR: attempt to extract state of current process', "extracting the state of the process itself for progress_bar_visual"); | ||
| }; | ||
| $dbh_status->disconnect; | ||
| } | ||
| $node->stop('fast'); |
48 changes: 48 additions & 0 deletionstests/common.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletionstests/pg_qs_test_runner.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletionstests/test_cases.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.