diff options
author | Dylan William Hardison <dylan@hardison.net> | 2017-08-07 19:35:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-07 19:35:47 +0200 |
commit | 4663032035039cc642db9b3f82b289418d02c430 (patch) | |
tree | 553648b0cc683692cabcbc9ae45ef46f8af3b759 /qa | |
parent | 28a1de6319da8b481b9b5ec08f070bce65e17bb3 (diff) | |
download | bugzilla-4663032035039cc642db9b3f82b289418d02c430.tar.gz bugzilla-4663032035039cc642db9b3f82b289418d02c430.tar.xz |
Bug 1383355 - Migrate CI tests from taskcluster to CircleCI
Diffstat (limited to 'qa')
-rw-r--r-- | qa/config/generate_test_data.pl | 12 | ||||
-rw-r--r-- | qa/config/selenium_test.conf | 2 | ||||
-rw-r--r-- | qa/t/lib/QA/Util.pm | 26 | ||||
-rw-r--r-- | qa/t/test_flags.t | 8 | ||||
-rw-r--r-- | qa/t/test_flags2.t | 2 | ||||
-rw-r--r-- | qa/t/test_private_attachments.t | 6 | ||||
-rw-r--r-- | qa/t/test_security.t | 4 |
7 files changed, 47 insertions, 13 deletions
diff --git a/qa/config/generate_test_data.pl b/qa/config/generate_test_data.pl index 9ba851113..62daef772 100644 --- a/qa/config/generate_test_data.pl +++ b/qa/config/generate_test_data.pl @@ -12,6 +12,16 @@ use strict; use warnings; +use File::Basename; +use File::Spec; +BEGIN { + require lib; + my $dir = File::Spec->rel2abs( + File::Spec->catdir(dirname(__FILE__), "..", "..") + ); + lib->import($dir, File::Spec->catdir($dir, "lib"), File::Spec->catdir($dir, qw(local lib perl5))); +} + use Cwd; use File::Copy::Recursive qw(dircopy); @@ -20,7 +30,7 @@ my $config; BEGIN { print "reading the config file...\n"; - my $conf_file = "selenium_test.conf"; + my $conf_file = $ENV{BZ_QA_CONF_FILE} // "selenium_test.conf"; if (@ARGV) { $conf_file = shift @ARGV; } diff --git a/qa/config/selenium_test.conf b/qa/config/selenium_test.conf index b6a795b78..2a163d5f0 100644 --- a/qa/config/selenium_test.conf +++ b/qa/config/selenium_test.conf @@ -16,7 +16,7 @@ 'host' => 'localhost', 'port' => 4444, 'browser_url' => 'http://localhost', - 'attachment_file' => '/var/www/html/bmo/qa/config/patch.diff', + 'attachment_file' => 'https://raw.githubusercontent.com/mozilla-bteam/bmo/master/qa/config/patch.diff', 'bugzilla_installation' => 'bmo', 'bugzilla_path' => '/var/www/html/bmo', 'test_bug_1' => 1, diff --git a/qa/t/lib/QA/Util.pm b/qa/t/lib/QA/Util.pm index 1ff37a0d7..4999e6f3b 100644 --- a/qa/t/lib/QA/Util.pm +++ b/qa/t/lib/QA/Util.pm @@ -13,7 +13,11 @@ use strict; use Data::Dumper; use Test::More; use Test::WWW::Selenium; +use MIME::Base64 qw(decode_base64); +use Sys::Hostname qw(hostname); +use Socket qw(inet_ntoa); use WWW::Selenium::Util qw(server_is_running); +use URI; # Fixes wide character warnings BEGIN { @@ -42,6 +46,7 @@ use base qw(Exporter); add_product open_advanced_search_page set_parameters + screenshot_page get_selenium get_rpc_clients @@ -52,7 +57,7 @@ use base qw(Exporter); # How long we wait for pages to load. use constant WAIT_TIME => 60000; -use constant CONF_FILE => "../config/selenium_test.conf"; +use constant CONF_FILE => $ENV{BZ_QA_CONF_FILE} // "../config/selenium_test.conf"; use constant CHROME_MODE => 1; use constant NDASH => chr(0x2013); @@ -92,6 +97,16 @@ sub get_config { my $conf_file = CONF_FILE; my $config = do($conf_file) or die "can't read configuration '$conf_file': $!$@"; + my $uri = URI->new($config->{browser_url}); + if (my $ip_packed = gethostbyname($uri->host)) { + my $ip = inet_ntoa($ip_packed); + $uri->host($ip); + $config->{browser_ip_url} = "$uri"; + } + else { + die "unable to find ip for $config->{browser_url}\n"; + } + return $config; } sub get_selenium { @@ -148,9 +163,18 @@ sub get_rpc_clients { sub go_to_home { my ($sel, $config) = @_; $sel->open_ok("/$config->{bugzilla_installation}/", undef, "Go to the home page"); + $sel->set_speed(500); $sel->title_is("Bugzilla Main Page"); } +sub screenshot_page { + my ($sel, $filename) = @_; + open my $fh, '>:raw', $filename or die "unable to write $filename: $!"; + binmode $fh; + print $fh decode_base64($sel->capture_entire_page_screenshot_to_string()); + close $fh; +} + # Go to the home/login page and log in. sub log_in { my ($sel, $config, $user) = @_; diff --git a/qa/t/test_flags.t b/qa/t/test_flags.t index 8b7883bb5..e2ba621e6 100644 --- a/qa/t/test_flags.t +++ b/qa/t/test_flags.t @@ -299,7 +299,7 @@ $sel->title_like(qr/^$bug1_id /); $sel->click_ok("link=Add an attachment"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Create New Attachment for Bug #$bug1_id"); -$sel->type_ok("data", $config->{attachment_file}); +$sel->attach_file("data", $config->{attachment_file}); $sel->type_ok("description", "patch, v1"); $sel->check_ok("ispatch"); $sel->is_text_present_ok("SeleniumAttachmentFlag1Test"); @@ -326,7 +326,7 @@ my $attachment1_id = $1; $sel->click_ok("//a[contains(text(),'Create\n Another Attachment to Bug $bug1_id')]"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Create New Attachment for Bug #$bug1_id"); -$sel->type_ok("data", $config->{attachment_file}); +$sel->attach_file("data", $config->{attachment_file}); $sel->type_ok("description", "patch, v2"); $sel->check_ok("ispatch"); # Mark the previous attachment as obsolete. @@ -350,7 +350,7 @@ my $attachment2_id = $1; $sel->click_ok("//a[contains(text(),'Create\n Another Attachment to Bug $bug1_id')]"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Create New Attachment for Bug #$bug1_id"); -$sel->type_ok("data", $config->{attachment_file}); +$sel->attach_file("data", $config->{attachment_file}); $sel->type_ok("description", "patch, v3"); $sel->click_ok("list"); $sel->select_ok("contenttypeselection", "label=plain text (text/plain)"); @@ -423,7 +423,7 @@ $sel->title_like(qr/^$bug1_id/); $sel->click_ok("link=Add an attachment"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Create New Attachment for Bug #$bug1_id"); -$sel->type_ok("data", $config->{attachment_file}); +$sel->attach_file("data", $config->{attachment_file}); $sel->type_ok("description", "patch, v4"); $sel->value_is("ispatch", "on"); diff --git a/qa/t/test_flags2.t b/qa/t/test_flags2.t index cec9ee6ef..3d2d59db8 100644 --- a/qa/t/test_flags2.t +++ b/qa/t/test_flags2.t @@ -150,7 +150,7 @@ $sel->select_ok("flag_type-$flagtype1_id", "label=+"); $sel->type_ok("short_desc", "The selenium flag should be kept on product change"); $sel->type_ok("comment", "pom"); $sel->click_ok('//input[@value="Add an attachment"]'); -$sel->type_ok("data", $config->{attachment_file}); +$sel->attach_file("data", $config->{attachment_file}); $sel->type_ok("description", "small patch"); $sel->value_is("ispatch", "on"); ok(!$sel->is_element_present("flag_type-$aflagtype1_id"), "Flag type $aflagtype1_id not available in TestProduct"); diff --git a/qa/t/test_private_attachments.t b/qa/t/test_private_attachments.t index 6126974d7..c6b6df5a1 100644 --- a/qa/t/test_private_attachments.t +++ b/qa/t/test_private_attachments.t @@ -33,7 +33,7 @@ $sel->type_ok("short_desc", "Some comments are private"); $sel->type_ok("comment", "and some attachments too, like this one."); $sel->check_ok("comment_is_private"); $sel->click_ok('//input[@value="Add an attachment"]'); -$sel->type_ok("data", $config->{attachment_file}); +$sel->attach_file("data", $config->{attachment_file}); $sel->type_ok("description", "private attachment, v1"); $sel->check_ok("ispatch"); $sel->click_ok("commit"); @@ -49,7 +49,7 @@ $sel->is_checked_ok('//a[@id="comment_link_0"]/../..//div//input[@type="checkbox $sel->click_ok("link=Add an attachment"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Create New Attachment for Bug #$bug1_id"); -$sel->type_ok("data", $config->{attachment_file}); +$sel->attach_file("data", $config->{attachment_file}); $sel->type_ok("description", "public attachment, v2"); $sel->check_ok("ispatch"); # The existing attachment name must be displayed, to mark it as obsolete. @@ -109,7 +109,7 @@ $sel->is_text_present_ok("This attachment is not mine"); $sel->click_ok("link=Add an attachment"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Create New Attachment for Bug #$bug1_id"); -$sel->type_ok("data", $config->{attachment_file}); +$sel->attach_file("data", $config->{attachment_file}); $sel->check_ok("ispatch"); # The user doesn't have editbugs privs. $sel->is_text_present_ok("[no attachments can be made obsolete]"); diff --git a/qa/t/test_security.t b/qa/t/test_security.t index 6d545ffd5..56fba4b01 100644 --- a/qa/t/test_security.t +++ b/qa/t/test_security.t @@ -24,7 +24,7 @@ file_bug_in_product($sel, "TestProduct"); my $bug_summary = "Security checks"; $sel->type_ok("short_desc", $bug_summary); $sel->type_ok("comment", "This bug will be used to test security fixes."); -$sel->type_ok("data", $config->{attachment_file}); +$sel->attach_file("data", $config->{attachment_file}); $sel->type_ok("description", "simple patch, v1"); my $bug1_id = create_bug($sel, $bug_summary); @@ -54,7 +54,7 @@ $sel->title_like(qr/^$bug1_id /); # Alternate host for attachments; no cookie should be accessible. set_parameters($sel, { "Attachments" => {"attachment_base" => {type => "text", - value => "http://127.0.0.1/$urlbase/"}} }); + value => "$config->{browser_ip_url}/$urlbase/"}} }); go_to_bug($sel, $bug1_id); $sel->click_ok("link=simple patch, v1"); $sel->wait_for_page_to_load_ok(WAIT_TIME); |