mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-11-24 08:13:38 +00:00
Merge "QA: Refactored performance tests"
This commit is contained in:
commit
1c56b23ff7
|
@ -3,4 +3,4 @@
|
|||
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "mediawiki_selenium"
|
||||
gem "mediawiki_selenium", "~> 0.4.0"
|
||||
|
|
|
@ -4,17 +4,17 @@ GEM
|
|||
builder (3.2.2)
|
||||
childprocess (0.5.3)
|
||||
ffi (~> 1.0, >= 1.0.11)
|
||||
cucumber (1.3.16)
|
||||
cucumber (1.3.17)
|
||||
builder (>= 2.1.2)
|
||||
diff-lcs (>= 1.1.3)
|
||||
gherkin (~> 2.12)
|
||||
multi_json (>= 1.7.5, < 2.0)
|
||||
multi_test (>= 0.1.1)
|
||||
data_magic (0.19)
|
||||
data_magic (0.20)
|
||||
faker (>= 1.1.2)
|
||||
yml_reader (>= 0.3)
|
||||
yml_reader (>= 0.4)
|
||||
diff-lcs (1.2.5)
|
||||
domain_name (0.5.20)
|
||||
domain_name (0.5.21)
|
||||
unf (>= 0.0.5, < 1.0.0)
|
||||
faker (1.4.3)
|
||||
i18n (~> 0.5)
|
||||
|
@ -34,7 +34,7 @@ GEM
|
|||
mediawiki_api (0.2.1)
|
||||
faraday (~> 0.9, >= 0.9.0)
|
||||
faraday-cookie_jar (~> 0.0, >= 0.0.6)
|
||||
mediawiki_selenium (0.3.2)
|
||||
mediawiki_selenium (0.4.0)
|
||||
cucumber (~> 1.3, >= 1.3.10)
|
||||
headless (~> 1.0, >= 1.0.1)
|
||||
json (~> 1.8, >= 1.8.1)
|
||||
|
@ -60,22 +60,22 @@ GEM
|
|||
rspec-expectations (2.99.2)
|
||||
diff-lcs (>= 1.1.3, < 2.0)
|
||||
rubyzip (1.1.6)
|
||||
selenium-webdriver (2.42.0)
|
||||
childprocess (>= 0.5.0)
|
||||
selenium-webdriver (2.43.0)
|
||||
childprocess (~> 0.5)
|
||||
multi_json (~> 1.0)
|
||||
rubyzip (~> 1.0)
|
||||
websocket (~> 1.0.4)
|
||||
websocket (~> 1.0)
|
||||
syntax (1.2.0)
|
||||
unf (0.1.4)
|
||||
unf_ext
|
||||
unf_ext (0.0.6)
|
||||
watir-webdriver (0.6.10)
|
||||
watir-webdriver (0.6.11)
|
||||
selenium-webdriver (>= 2.18.0)
|
||||
websocket (1.0.7)
|
||||
yml_reader (0.3)
|
||||
websocket (1.2.1)
|
||||
yml_reader (0.4)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
mediawiki_selenium
|
||||
mediawiki_selenium (~> 0.4.0)
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
@en.wikipedia.beta.wmflabs.org @mediawiki.org @firefox @internet_explorer_8 @internet_explorer_9 @internet_explorer_10 @internet_explorer_11 @test2.wikipedia.org
|
||||
@en.wikipedia.beta.wmflabs.org @custom-browser @mediawiki.org @firefox @internet_explorer_8 @internet_explorer_9 @internet_explorer_10 @internet_explorer_11 @test2.wikipedia.org
|
||||
Feature: Multimedia Viewer performance
|
||||
|
||||
Background:
|
||||
Given I am using a custom user agent
|
||||
And I am at a wiki article with at least two embedded pictures
|
||||
And I am at a wiki article with at least two embedded pictures
|
||||
|
||||
Scenario: Commons with warm cache
|
||||
Given I visit an unrelated Commons page to warm up the browser cache
|
||||
And I visit the Commons page
|
||||
And I visit the Commons page
|
||||
Then the File: page image is loaded
|
||||
|
||||
Scenario: MMV with warm cache and small browser window
|
||||
Given I have a small browser window
|
||||
When I click on an unrelated image in the article to warm up the browser cache
|
||||
When I close MMV
|
||||
When I click on the first image in the article
|
||||
And I close MMV
|
||||
And I click on the first image in the article
|
||||
Then the MMV image is loaded in 125 percent of the time with a warm cache and an average browser window
|
||||
|
||||
Scenario: MMV with cold cache and average browser window
|
||||
|
@ -25,8 +25,8 @@ Feature: Multimedia Viewer performance
|
|||
Scenario: MMV with warm cache and average browser window
|
||||
Given I have an average browser window
|
||||
When I click on an unrelated image in the article to warm up the browser cache
|
||||
When I close MMV
|
||||
When I click on the first image in the article
|
||||
And I close MMV
|
||||
And I click on the first image in the article
|
||||
Then the MMV image is loaded in 125 percent of the time with a warm cache and an average browser window
|
||||
|
||||
Scenario: MMV with cold cache and large browser window
|
||||
|
@ -37,6 +37,6 @@ Feature: Multimedia Viewer performance
|
|||
Scenario: MMV with warm cache and large browser window
|
||||
Given I have a large browser window
|
||||
When I click on an unrelated image in the article to warm up the browser cache
|
||||
When I close MMV
|
||||
When I click on the first image in the article
|
||||
Then the MMV image is loaded in 125 percent of the time with a warm cache and a large browser window
|
||||
And I close MMV
|
||||
And I click on the first image in the article
|
||||
Then the MMV image is loaded in 125 percent of the time with a warm cache and a large browser window
|
||||
|
|
|
@ -20,73 +20,26 @@ Given /^I have a large browser window$/ do
|
|||
end
|
||||
|
||||
Given /^I am using a custom user agent$/ do
|
||||
@browser = browser(test_name(@scenario), {user_agent: ENV["BROWSER_USERAGENT"]})
|
||||
@browser = browser(test_name(@scenario), user_agent: ENV["BROWSER_USERAGENT"])
|
||||
end
|
||||
|
||||
Then /^the File: page image is loaded$/ do
|
||||
on(CommonsPage) do |page|
|
||||
wait_for_image_load page, ".fullImageLink img"
|
||||
page.wait_for_image_load ".fullImageLink img"
|
||||
#Has to be a global variable, otherwise it doesn't survive between scenarios
|
||||
$commons_time = Time.now.getutc - @commons_open_time
|
||||
log_performance "file-page", ( $commons_time * 1000 ).to_i.to_s, "", ""
|
||||
page.log_performance type: "file-page", duration: $commons_time * 1000
|
||||
end
|
||||
end
|
||||
|
||||
Then /^the MMV image is loaded in (\d+) percent of the time with a (.*) cache and an? (.*) browser window$/ do |percentage, cache, window_size|
|
||||
on(E2ETestPage) do |page|
|
||||
wait_for_image_load page, ".mw-mmv-image img"
|
||||
page.wait_for_image_load ".mw-mmv-image img"
|
||||
mmv_time = Time.now.getutc - @image_click_time
|
||||
log_performance "mmv", (mmv_time * 1000).to_i.to_s, cache, window_size
|
||||
page.log_performance type: "mmv", duration: mmv_time * 1000, cache: cache, windowSize: window_size
|
||||
|
||||
expected_time = $commons_time * ( percentage.to_f / 100.0 )
|
||||
mmv_time.should < expected_time
|
||||
expected_time = $commons_time * (percentage.to_f / 100.0)
|
||||
expect(mmv_time).to be < expected_time
|
||||
end
|
||||
end
|
||||
|
||||
def wait_for_image_load ( page, css_class )
|
||||
@browser.execute_script("
|
||||
function wait_for_image() {
|
||||
var $img = $( '" + css_class + "' );
|
||||
if ( $img.length
|
||||
&& $img.attr( 'src' ).match(/Kerala/)
|
||||
&& !$img.attr( 'src' ).match(/\\/220px-/) // Blurry placeholder
|
||||
&& $img.prop( 'complete' ) ) {
|
||||
$( 'body' ).append( '<div class=\"mw-mmv-image-loaded-cucumber\"/>' );
|
||||
} else {
|
||||
setTimeout( wait_for_image, 10 );
|
||||
}
|
||||
}
|
||||
wait_for_image();
|
||||
")
|
||||
|
||||
Watir::Wait.until { page.mmv_image_loaded_cucumber_element.exists? }
|
||||
end
|
||||
|
||||
def log_performance ( type, duration, cache, window_size )
|
||||
@browser.execute_script("
|
||||
var stats = { type : '" + type + "', duration : " + duration + "};
|
||||
|
||||
if ( '" + cache + "'.length ) {
|
||||
stats.cache = '" + cache + "';
|
||||
}
|
||||
|
||||
if ( '" + window_size + "'.length ) {
|
||||
stats.windowSize = '" + window_size + "';
|
||||
}
|
||||
|
||||
mediaWiki.eventLog.declareSchema( 'MultimediaViewerVersusPageFilePerformance',
|
||||
{ schema:
|
||||
{ title: 'MultimediaViewerVersusPageFilePerformance',
|
||||
properties: {
|
||||
type: { type: 'string', required: true, enum: [ 'mmv', 'file-page' ] },
|
||||
duration: { type: 'integer', required: true },
|
||||
cache: { type: 'string', required: false, enum: [ 'cold', 'warm' ] },
|
||||
windowSize: { type: 'string', required: false, enum: [ 'average', 'large'] }
|
||||
}
|
||||
},
|
||||
revision: 7907636
|
||||
});
|
||||
|
||||
mw.eventLog.logEvent( 'MultimediaViewerVersusPageFilePerformance', stats );
|
||||
")
|
||||
end
|
|
@ -1 +1,4 @@
|
|||
require "mediawiki_selenium"
|
||||
require "rubygems"
|
||||
require "bundler/setup"
|
||||
|
||||
Bundler.require
|
||||
|
|
|
@ -1,10 +1,51 @@
|
|||
require "json"
|
||||
|
||||
class CommonsPage
|
||||
include PageObject
|
||||
|
||||
include URL
|
||||
page_url URL.url("File:Sunrise_over_fishing_boats_in_Kerala.jpg")
|
||||
|
||||
img(:commons_image, src: /Kerala\.jpg$/)
|
||||
|
||||
div(:mmv_image_loaded_cucumber, class: "mw-mmv-image-loaded-cucumber")
|
||||
end
|
||||
|
||||
def wait_for_image_load(selector)
|
||||
browser.execute_script <<-end_script
|
||||
function wait_for_image() {
|
||||
var $img = $( #{selector.to_json} );
|
||||
if ( $img.length
|
||||
&& $img.attr( 'src' ).match(/Kerala/)
|
||||
&& !$img.attr( 'src' ).match(/\\/220px-/) // Blurry placeholder
|
||||
&& $img.prop( 'complete' ) ) {
|
||||
$( 'body' ).append( '<div class=\"mw-mmv-image-loaded-cucumber\"/>' );
|
||||
} else {
|
||||
setTimeout( wait_for_image, 10 );
|
||||
}
|
||||
}
|
||||
wait_for_image();
|
||||
end_script
|
||||
|
||||
wait_until { mmv_image_loaded_cucumber_element.exists? }
|
||||
end
|
||||
|
||||
def log_performance(stats)
|
||||
stats = stats.reject { |name, value| value.nil? || value.to_s.empty? }
|
||||
stats[:duration] = stats[:duration].floor
|
||||
|
||||
browser.execute_script <<-end_script
|
||||
mediaWiki.eventLog.declareSchema( 'MultimediaViewerVersusPageFilePerformance',
|
||||
{ schema:
|
||||
{ title: 'MultimediaViewerVersusPageFilePerformance',
|
||||
properties: {
|
||||
type: { type: 'string', required: true, enum: [ 'mmv', 'file-page' ] },
|
||||
duration: { type: 'integer', required: true },
|
||||
cache: { type: 'string', required: false, enum: [ 'cold', 'warm' ] },
|
||||
windowSize: { type: 'string', required: false, enum: [ 'average', 'large'] }
|
||||
}
|
||||
},
|
||||
revision: 7907636
|
||||
});
|
||||
|
||||
mw.eventLog.logEvent( 'MultimediaViewerVersusPageFilePerformance', #{stats.to_json} );
|
||||
end_script
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
class E2ETestPage
|
||||
class E2ETestPage < CommonsPage
|
||||
include PageObject
|
||||
include URL
|
||||
|
||||
page_url URL.url("MediaViewerE2ETest")
|
||||
|
||||
|
|
Loading…
Reference in a new issue