Zfilipin has uploaded a new change for review. https://gerrit.wikimedia.org/r/86838
Change subject: Updated ULS repository to the latest version of shared test files ...................................................................... Updated ULS repository to the latest version of shared test files Bug: 53579 Change-Id: I9828866f3a3db24a95324bb82942f2c59382f2c9 --- D tests/browser/.gitignore M tests/browser/features/step_definitions/accept_language_steps.rb M tests/browser/features/step_definitions/common_steps.rb M tests/browser/features/support/env.rb 4 files changed, 19 insertions(+), 38 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UniversalLanguageSelector refs/changes/38/86838/1 diff --git a/tests/browser/.gitignore b/tests/browser/.gitignore deleted file mode 100644 index 9fc7a0c..0000000 --- a/tests/browser/.gitignore +++ /dev/null @@ -1 +0,0 @@ -config/secret.yml diff --git a/tests/browser/features/step_definitions/accept_language_steps.rb b/tests/browser/features/step_definitions/accept_language_steps.rb index b13422f..41a6183 100644 --- a/tests/browser/features/step_definitions/accept_language_steps.rb +++ b/tests/browser/features/step_definitions/accept_language_steps.rb @@ -1,5 +1,5 @@ Given(/^that my browser's accept language is (.+)$/) do |language| - @browser = browser(environment, test_name(@scenario), @saucelabs_username, @saucelabs_key, language) + @browser = browser(environment, test_name(@scenario), ENV['SAUCE_ONDEMAND_USERNAME'], ENV['SAUCE_ONDEMAND_ACCESS_KEY'], language) $session_id = @browser.driver.instance_variable_get(:@bridge).session_id end diff --git a/tests/browser/features/step_definitions/common_steps.rb b/tests/browser/features/step_definitions/common_steps.rb index f5a092d..a879835 100644 --- a/tests/browser/features/step_definitions/common_steps.rb +++ b/tests/browser/features/step_definitions/common_steps.rb @@ -6,7 +6,7 @@ end Given(/^I am logged in$/) do - visit(LoginPage).login_with(@mediawiki_username, @mediawiki_password) + visit(LoginPage).login_with(@mediawiki_username, ENV['MEDIAWIKI_PASSWORD']) # Assert that login worked loggedin = !@browser.execute_script( "return mw.user.isAnon();" ) loggedin.should be_true diff --git a/tests/browser/features/support/env.rb b/tests/browser/features/support/env.rb index 75f62b5..ca56ddb 100644 --- a/tests/browser/features/support/env.rb +++ b/tests/browser/features/support/env.rb @@ -7,16 +7,16 @@ World(PageObject::PageFactory) -def browser(environment, test_name, saucelabs_username, saucelabs_key, language) - if environment == :cloudbees - sauce_browser(test_name, saucelabs_username, saucelabs_key, language) +def browser(environment, test_name, language) + if environment == :saucelabs + sauce_browser(test_name, language) else local_browser(language) end end def environment - if ENV['ENVIRONMENT'] == 'cloudbees' - :cloudbees + if ENV['BROWSER_LABEL'] and ENV['SAUCE_ONDEMAND_USERNAME'] and ENV['SAUCE_ONDEMAND_ACCESS_KEY'] + :saucelabs else :local end @@ -42,10 +42,10 @@ Watir::Browser.new browser_label, :profile => profile end end -def sauce_api(json, saucelabs_username, saucelabs_key) - %x{curl -H 'Content-Type:text/json' -s -X PUT -d '#{json}' http://#{saucelabs_username}:#{saucelabs_key}@saucelabs.com/rest/v1/#{saucelabs_username}/jobs/#{$session_id}} +def sauce_api(json) + %x{curl -H 'Content-Type:text/json' -s -X PUT -d '#{json}' http://#{ENV['SAUCE_ONDEMAND_USERNAME']}:#{ENV['SAUCE_ONDEMAND_ACCESS_KEY']}@saucelabs.com/rest/v1/#{ENV['SAUCE_ONDEMAND_USERNAME']}/jobs/#{$session_id}} end -def sauce_browser(test_name, saucelabs_username, saucelabs_key, language) +def sauce_browser(test_name, language) config = YAML.load_file('config/config.yml') browser_label = config[ENV['BROWSER_LABEL']] @@ -69,7 +69,7 @@ browser = Watir::Browser.new( :remote, http_client: Selenium::WebDriver::Remote::Http::Persistent.new, - url: "http://#{saucelabs_username}:#{saucelabs_key}@ondemand.saucelabs.com:80/wd/hub", + url: "http://#{ENV['SAUCE_ONDEMAND_USERNAME']}:#{ENV['SAUCE_ONDEMAND_ACCESS_KEY']}@ondemand.saucelabs.com:80/wd/hub", desired_capabilities: caps) browser.wd.file_detector = lambda do |args| @@ -80,13 +80,7 @@ browser end -def secret_yml_location - secret_yml_locations = ['/private/wmf/', 'config/'] - secret_yml_locations.each do |secret_yml_location| - return secret_yml_location if File.exists?("#{secret_yml_location}secret.yml") - end - nil -end + def test_name(scenario) if scenario.respond_to? :feature "#{scenario.feature.name}: #{scenario.name}" @@ -98,41 +92,29 @@ config = YAML.load_file('config/config.yml') mediawiki_username = config['mediawiki_username'] -unless secret_yml_location == nil - secret = YAML.load_file("#{secret_yml_location}secret.yml") - mediawiki_password = secret['mediawiki_password'] -end - -if ENV['ENVIRONMENT'] == 'cloudbees' - saucelabs_username = secret['saucelabs_username'] - saucelabs_key = secret['saucelabs_key'] +Before('@login') do + puts "MEDIAWIKI_PASSWORD environment variable is not defined! Please export a value for that variable before proceeding." unless ENV['MEDIAWIKI_PASSWORD'] end Before('@language') do |scenario| @language = true - @saucelabs_username = saucelabs_username - @saucelabs_key = saucelabs_key @scenario = scenario -end -Before('@login') do - puts "secret.yml file at /private/wmf/ or config/ is required for tests tagged @login" if secret_yml_location == nil end Before do |scenario| @config = config - @does_not_exist_page_name = Random.new.rand.to_s + @random_string = Random.new.rand.to_s @mediawiki_username = mediawiki_username - @mediawiki_password = mediawiki_password unless @language - @browser = browser(environment, test_name(scenario), saucelabs_username, saucelabs_key, 'default') + @browser = browser(environment, test_name(scenario), 'default') $session_id = @browser.driver.instance_variable_get(:@bridge).session_id end end After do |scenario| - if environment == :cloudbees - sauce_api(%Q{{"passed": #{scenario.passed?}}}, saucelabs_username, saucelabs_key) - sauce_api(%Q{{"public": true}}, saucelabs_username, saucelabs_key) + if environment == :saucelabs + sauce_api(%Q{{"passed": #{scenario.passed?}}}) + sauce_api(%Q{{"public": true}}) end @browser.close unless ENV['KEEP_BROWSER_OPEN'] == 'true' end -- To view, visit https://gerrit.wikimedia.org/r/86838 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9828866f3a3db24a95324bb82942f2c59382f2c9 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector Gerrit-Branch: master Gerrit-Owner: Zfilipin <zfili...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits