Skip to content

Commit

Permalink
Author-names (#80,#81,#82): fixed test runner issues
Browse files Browse the repository at this point in the history
Fixed syntax of pg_dump to ensure the initial state of database is saved and restored.
increased sleep time after terminating pg backend processes
Made the test runner logs visible in protected/runtime/
Moved the printCurrentUrl inside the try{} block as it blows up when a step fails and no web session has been started yet(with visit)
  • Loading branch information
Rija Menage committed Feb 6, 2018
1 parent 7a2d7f9 commit 796a0f5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/features/bootstrap/AffiliateLoginContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public static function initialize_database()
print_r("Initializing the database... ");
exec("vagrant ssh -c \"sudo -Hiu postgres /usr/bin/psql < /vagrant/sql/reset_user_table.sql\"",$kill_output);
// var_dump($kill_output);
sleep(5) ; # pad the adminstrative operations to cater for latency in order to avoid fatal error
sleep(8) ; # pad the adminstrative operations to cater for latency in order to avoid fatal error
}


Expand Down
2 changes: 1 addition & 1 deletion tests/features/bootstrap/DatasetViewContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function gigadbWebSiteIsLoadedWithProductionLikeData()
exec("vagrant ssh -c \"pg_restore -i -h localhost -p 5432 -U gigadb -d gigadb -v /vagrant/sql/author-names-80-81-82.pgdmp
\"",$output);
// var_dump($output);
sleep(5) ;
sleep(8) ;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/features/bootstrap/GigadbWebsiteContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public function getYii()
public function debugStep($event)
{
if ($event->getResult() == 4 ) {
$this->printCurrentUrl();
try { # take a snapshot of web page
$this->printCurrentUrl();
$content = $this->getSession()->getDriver()->getContent();
$file_and_path = sprintf('%s_%s_%s',"content", date('U'), uniqid('', true)) ;
file_put_contents("/tmp/".$file_and_path.".html", $content);
Expand Down
6 changes: 3 additions & 3 deletions tests/run
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
echo "About to run automated tests..."

echo "First, backup the main database..."
vagrant ssh -c 'pg_dump -U gigadb -h localhost -p 5432 -W vagrant -F custom -d gigadb -f /vagrant/sql/before-run.pgdmp > /tmp/pg_dump.log 2>&1'
vagrant ssh -c 'pg_dump gigadb -U gigadb -h localhost -p 5432 -w -F custom -f /vagrant/sql/before-run.pgdmp > /vagrant/protected/runtime/pg_dump.log 2>&1'

echo "Running acceptance tests"
Behat/bin/behat -v --stop-on-failure -c tests/behat.yml

echo "Preparing the test database..."
vagrant ssh -c 'sudo -Hiu postgres /usr/bin/psql < /vagrant/sql/gigadb_unit_tests.sql > /tmp/setup_test_database.log 2>&1'
vagrant ssh -c 'sudo -Hiu postgres /usr/bin/psql < /vagrant/sql/gigadb_unit_tests.sql > /vagrant/protected/runtime/setup_test_database.log 2>&1'


echo "Running unit tests"
Expand All @@ -16,4 +16,4 @@ vagrant ssh -c 'cd /vagrant/protected/tests && ./../../Behat/vendor/phpunit/phpu
echo "...all automated tests have run"

echo "Lastly, restoring the main database..."
vagrant ssh -c 'pg_restore -i -h localhost -p 5432 -U gigadb -d gigadb -c -v /vagrant/sql/before-run.pgdmp > /tmp/pg_restore.log 2>&1'
vagrant ssh -c 'pg_restore -i -h localhost -p 5432 -U gigadb -d gigadb -c -v /vagrant/sql/before-run.pgdmp > /vagrant/protected/runtime/pg_restore.log 2>&1'

0 comments on commit 796a0f5

Please sign in to comment.