mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-09-24 10:49:40 +00:00
Test to compare the performance of MMV and the Commons File: page
- Runs combinations of cold/warm browser cache and average/large window size - Sends events with EventLogging that will allow us to generate limn graphs This should run separately from the other cucumber test we already have. This one needs different environment variables because it needs to run against production wikis instead of beta wikipedia Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/378 Change-Id: I53b521ca2759c493aae6fe6e59be8d448e0f15d7
This commit is contained in:
parent
e03b9345c2
commit
bf213ed978
|
@ -2,19 +2,19 @@ GEM
|
|||
remote: https://rubygems.org/
|
||||
specs:
|
||||
builder (3.2.2)
|
||||
childprocess (0.5.1)
|
||||
childprocess (0.5.2)
|
||||
ffi (~> 1.0, >= 1.0.11)
|
||||
cucumber (1.3.10)
|
||||
cucumber (1.3.14)
|
||||
builder (>= 2.1.2)
|
||||
diff-lcs (>= 1.1.3)
|
||||
gherkin (~> 2.12)
|
||||
multi_json (>= 1.7.5, < 2.0)
|
||||
multi_test (>= 0.0.2)
|
||||
data_magic (0.17)
|
||||
multi_test (>= 0.1.1)
|
||||
data_magic (0.18)
|
||||
faker (>= 1.1.2)
|
||||
yml_reader (>= 0.2)
|
||||
diff-lcs (1.2.5)
|
||||
faker (1.2.0)
|
||||
faker (1.3.0)
|
||||
i18n (~> 0.5)
|
||||
ffi (1.9.3)
|
||||
gherkin (2.12.2)
|
||||
|
@ -22,7 +22,7 @@ GEM
|
|||
headless (1.0.1)
|
||||
i18n (0.6.9)
|
||||
json (1.8.1)
|
||||
mediawiki_selenium (0.2.7)
|
||||
mediawiki_selenium (0.2.16)
|
||||
cucumber (~> 1.3, >= 1.3.10)
|
||||
headless (~> 1.0, >= 1.0.1)
|
||||
json (~> 1.8, >= 1.8.1)
|
||||
|
@ -31,22 +31,22 @@ GEM
|
|||
rest-client (~> 1.6, >= 1.6.7)
|
||||
rspec-expectations (~> 2.14, >= 2.14.4)
|
||||
syntax (~> 1.2, >= 1.2.0)
|
||||
mime-types (2.1)
|
||||
multi_json (1.8.4)
|
||||
multi_test (0.0.3)
|
||||
mime-types (2.2)
|
||||
multi_json (1.9.2)
|
||||
multi_test (0.1.1)
|
||||
net-http-persistent (2.9.4)
|
||||
page-object (0.9.6)
|
||||
page-object (0.9.8)
|
||||
page_navigation (>= 0.9)
|
||||
selenium-webdriver (>= 2.39.0)
|
||||
watir-webdriver (>= 0.6.7)
|
||||
selenium-webdriver (>= 2.40.0)
|
||||
watir-webdriver (>= 0.6.8)
|
||||
page_navigation (0.9)
|
||||
data_magic (>= 0.14)
|
||||
rest-client (1.6.7)
|
||||
mime-types (>= 1.16)
|
||||
rspec-expectations (2.14.5)
|
||||
diff-lcs (>= 1.1.3, < 2.0)
|
||||
rubyzip (1.1.0)
|
||||
selenium-webdriver (2.40.0)
|
||||
rubyzip (1.1.2)
|
||||
selenium-webdriver (2.41.0)
|
||||
childprocess (>= 0.5.0)
|
||||
multi_json (~> 1.0)
|
||||
rubyzip (~> 1.0)
|
||||
|
|
42
tests/browser/features/mmv_performance.feature
Normal file
42
tests/browser/features/mmv_performance.feature
Normal file
|
@ -0,0 +1,42 @@
|
|||
@login @mediawiki.org
|
||||
Feature: Multimedia Viewer performance
|
||||
|
||||
Background:
|
||||
Given I am logged in
|
||||
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
|
||||
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
|
||||
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
|
||||
Given I have an average browser window
|
||||
When I click on the first image in the article
|
||||
Then the MMV image is loaded in 210 percent of the time with a cold cache and an average browser window
|
||||
|
||||
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
|
||||
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
|
||||
Given I have a large browser window
|
||||
When I click on the first image in the article
|
||||
Then the MMV image is loaded in 240 percent of the time with a cold cache and a large browser window
|
||||
|
||||
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
|
|
@ -10,25 +10,25 @@ When(/^I click on the first image in the article$/) do
|
|||
@articleScrollTop = page.execute_script("return Math.round($('a[href=\"/wiki/File:Sunrise_over_fishing_boats_in_Kerala.jpg\"]').first().find('img').offset().top);")
|
||||
# Scrolls to the image and clicks on it
|
||||
page.image1_in_article
|
||||
# This is a global variable that can be used to measure performance
|
||||
@image_click_time = Time.now.getutc
|
||||
end
|
||||
end
|
||||
|
||||
When(/^I click on an unrelated image in the article to warm up the browser cache$/) do
|
||||
on(LightboxDemoPage).other_image_in_article
|
||||
end
|
||||
|
||||
When(/^I click the next arrow$/) do
|
||||
on(LightboxDemoPage) do |page|
|
||||
page.mmv_next_button_element.when_present.click
|
||||
end
|
||||
on(LightboxDemoPage).mmv_next_button_element.when_present.click
|
||||
end
|
||||
|
||||
When(/^I click the previous arrow$/) do
|
||||
on(LightboxDemoPage) do |page|
|
||||
page.mmv_previous_button_element.when_present.click
|
||||
end
|
||||
on(LightboxDemoPage).mmv_previous_button_element.when_present.click
|
||||
end
|
||||
|
||||
When(/^I close MMV$/) do
|
||||
on(LightboxDemoPage) do |page|
|
||||
page.mmv_close_button_element.when_present.click
|
||||
end
|
||||
on(LightboxDemoPage).mmv_close_button_element.when_present.click
|
||||
end
|
||||
|
||||
When(/^I press the browser back button$/) do
|
||||
|
@ -48,8 +48,7 @@ Then(/^the image and metadata of the next image should appear$/) do
|
|||
on(LightboxDemoPage) do |page|
|
||||
# MMV was launched, article is not visible yet
|
||||
page.image1_in_article_element.should_not be_visible
|
||||
|
||||
check_elements_in_viewer_for_image2(page)
|
||||
check_elements_in_viewer_for_image2 page
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -57,8 +56,7 @@ Then(/^the image metadata and the image itself should be there$/) do
|
|||
on(LightboxDemoPage) do |page|
|
||||
# MMV was launched, article is not visible now
|
||||
page.image1_in_article_element.should_not be_visible
|
||||
|
||||
check_elements_in_viewer_for_image1(page)
|
||||
check_elements_in_viewer_for_image1 page
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -66,8 +64,7 @@ Then(/^the image and metadata of the previous image should appear$/) do
|
|||
on(LightboxDemoPage) do |page|
|
||||
# MMV was launched, article is not visible yet
|
||||
page.image1_in_article_element.should_not be_visible
|
||||
|
||||
check_elements_in_viewer_for_image1(page)
|
||||
check_elements_in_viewer_for_image1 page
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -80,82 +77,82 @@ end
|
|||
# Helper function that verifies the presence of various elements in viewer
|
||||
# while looking at image1 (Kerala)
|
||||
def check_elements_in_viewer_for_image1(page)
|
||||
# Check basic MMV elements are present
|
||||
page.mmv_wrapper_element.should be_visible
|
||||
page.mmv_image_div_element.should be_visible
|
||||
# Check basic MMV elements are present
|
||||
page.mmv_wrapper_element.should be_visible
|
||||
page.mmv_image_div_element.should be_visible
|
||||
|
||||
# Check image content
|
||||
page.mmv_image_div_element.image_element.attribute('src').should match /Kerala/
|
||||
# Check image content
|
||||
page.mmv_image_div_element.image_element.attribute('src').should match /Kerala/
|
||||
|
||||
# Check basic metadata is present
|
||||
# Check basic metadata is present
|
||||
|
||||
# Title
|
||||
page.mmv_metadata_title_element.when_present.text.should match /Sunrise over fishing boats in Kerala/
|
||||
# License
|
||||
page.mmv_metadata_license_element.when_present.attribute('href').should match /boats_in_Kerala.jpg$/
|
||||
page.mmv_metadata_license_element.when_present.text.should match /CC BY-SA 3.0/
|
||||
# Credit
|
||||
page.mmv_metadata_credit_element.when_present.should be_visible
|
||||
page.mmv_metadata_source_element.when_present.text.should match /Own work/
|
||||
# Title
|
||||
page.mmv_metadata_title_element.when_present.text.should match /Sunrise over fishing boats in Kerala/
|
||||
# License
|
||||
page.mmv_metadata_license_element.when_present.attribute('href').should match /boats_in_Kerala.jpg$/
|
||||
page.mmv_metadata_license_element.when_present.text.should match /CC BY-SA 3.0/
|
||||
# Credit
|
||||
page.mmv_metadata_credit_element.when_present.should be_visible
|
||||
page.mmv_metadata_source_element.when_present.text.should match /Own work/
|
||||
|
||||
# Image metadata
|
||||
page.mmv_image_metadata_wrapper_element.when_present.should be_visible
|
||||
# Caption
|
||||
page.mmv_image_metadata_caption_element.when_present.text.should match /Sunrise over fishing boats/
|
||||
# Description
|
||||
page.mmv_image_metadata_desc_element.when_present.text.should match /Sunrise over fishing boats on the beach south of Kovalam/
|
||||
# Image metadata links
|
||||
page.mmv_image_metadata_links_wrapper_element.when_present.should be_visible
|
||||
# Repo link
|
||||
page.mmv_image_metadata_repo_link_element.when_present.text.should match /Learn more on Wikimedia Commons/
|
||||
page.mmv_image_metadata_repo_link_element.when_present.attribute('href').should match /boats_in_Kerala.jpg$/
|
||||
# Category links
|
||||
page.mmv_image_metadata_category_links_wrapper_element.when_present.should be_visible
|
||||
# File usage
|
||||
page.mmv_image_metadata_fileusage_wrapper_element.when_present.should be_visible
|
||||
page.mmv_image_metadata_fileusage_wrapper_element.when_present.h3_element.text.should match /Used in [0-9] page/
|
||||
page.mmv_image_metadata_fileusage_local_section_title_element.when_present.text.should match /On this site/
|
||||
# Image metadata
|
||||
page.mmv_image_metadata_wrapper_element.when_present.should be_visible
|
||||
# Caption
|
||||
page.mmv_image_metadata_caption_element.when_present.text.should match /Sunrise over fishing boats/
|
||||
# Description
|
||||
page.mmv_image_metadata_desc_element.when_present.text.should match /Sunrise over fishing boats on the beach south of Kovalam/
|
||||
# Image metadata links
|
||||
page.mmv_image_metadata_links_wrapper_element.when_present.should be_visible
|
||||
# Repo link
|
||||
page.mmv_image_metadata_repo_link_element.when_present.text.should match /Learn more on Wikimedia Commons/
|
||||
page.mmv_image_metadata_repo_link_element.when_present.attribute('href').should match /boats_in_Kerala.jpg$/
|
||||
# Category links
|
||||
page.mmv_image_metadata_category_links_wrapper_element.when_present.should be_visible
|
||||
# File usage
|
||||
page.mmv_image_metadata_fileusage_wrapper_element.when_present.should be_visible
|
||||
page.mmv_image_metadata_fileusage_wrapper_element.when_present.h3_element.text.should match /Used in [0-9] page/
|
||||
page.mmv_image_metadata_fileusage_local_section_title_element.when_present.text.should match /On this site/
|
||||
end
|
||||
|
||||
# Helper function that verifies the presence of various elements in viewer
|
||||
# while looking at image2 (Aquarium)
|
||||
def check_elements_in_viewer_for_image2(page)
|
||||
# MMV was launched, article is not visible
|
||||
page.image1_in_article_element.should_not be_visible
|
||||
# MMV was launched, article is not visible
|
||||
page.image1_in_article_element.should_not be_visible
|
||||
|
||||
# Check basic MMV elements are present
|
||||
page.mmv_wrapper_element.should be_visible
|
||||
page.mmv_image_div_element.should be_visible
|
||||
# Check basic MMV elements are present
|
||||
page.mmv_wrapper_element.should be_visible
|
||||
page.mmv_image_div_element.should be_visible
|
||||
|
||||
# Check image content
|
||||
page.mmv_image_div_element.image_element.attribute('src').should match /Offsite/
|
||||
# Check image content
|
||||
page.mmv_image_div_element.image_element.attribute('src').should match /Offsite/
|
||||
|
||||
# Check basic metadata is present
|
||||
# Check basic metadata is present
|
||||
|
||||
# Title
|
||||
page.mmv_metadata_title_element.when_present.text.should match /All Hands Offsite/
|
||||
# License
|
||||
page.mmv_metadata_license_element.when_present.attribute('href').should match /All_Hands_Offsite.*\.jpg$/
|
||||
page.mmv_metadata_license_element.when_present.text.should match /CC BY-SA 3.0/
|
||||
# Credit
|
||||
page.mmv_metadata_credit_element.when_present.should be_visible
|
||||
page.mmv_metadata_source_element.when_present.text.should match /Wikimedia Foundation/
|
||||
# Title
|
||||
page.mmv_metadata_title_element.when_present.text.should match /All Hands Offsite/
|
||||
# License
|
||||
page.mmv_metadata_license_element.when_present.attribute('href').should match /All_Hands_Offsite.*\.jpg$/
|
||||
page.mmv_metadata_license_element.when_present.text.should match /CC BY-SA 3.0/
|
||||
# Credit
|
||||
page.mmv_metadata_credit_element.when_present.should be_visible
|
||||
page.mmv_metadata_source_element.when_present.text.should match /Wikimedia Foundation/
|
||||
|
||||
# Image metadata
|
||||
page.mmv_image_metadata_wrapper_element.when_present.should be_visible
|
||||
# Caption
|
||||
page.mmv_image_metadata_caption_element.when_present.text.should match /Tropical Fish Aquarium/
|
||||
# Description
|
||||
page.mmv_image_metadata_desc_element.when_present.text.should match /Photo from Wikimedia Foundation/
|
||||
# Image metadata links
|
||||
page.mmv_image_metadata_links_wrapper_element.when_present.should be_visible
|
||||
# Repo link
|
||||
page.mmv_image_metadata_repo_link_element.when_present.text.should match /Learn more on Wikimedia Commons/
|
||||
page.mmv_image_metadata_repo_link_element.when_present.attribute('href').should match /All_Hands_Offsite.*\.jpg$/
|
||||
# Category links
|
||||
page.mmv_image_metadata_category_links_wrapper_element.when_present.should be_visible
|
||||
# File usage
|
||||
page.mmv_image_metadata_fileusage_wrapper_element.when_present.should be_visible
|
||||
page.mmv_image_metadata_fileusage_wrapper_element.when_present.h3_element.text.should match /Used in [0-9] page/
|
||||
page.mmv_image_metadata_fileusage_local_section_title_element.when_present.text.should match /On this site/
|
||||
# Image metadata
|
||||
page.mmv_image_metadata_wrapper_element.when_present.should be_visible
|
||||
# Caption
|
||||
page.mmv_image_metadata_caption_element.when_present.text.should match /Tropical Fish Aquarium/
|
||||
# Description
|
||||
page.mmv_image_metadata_desc_element.when_present.text.should match /Photo from Wikimedia Foundation/
|
||||
# Image metadata links
|
||||
page.mmv_image_metadata_links_wrapper_element.when_present.should be_visible
|
||||
# Repo link
|
||||
page.mmv_image_metadata_repo_link_element.when_present.text.should match /Learn more on Wikimedia Commons/
|
||||
page.mmv_image_metadata_repo_link_element.when_present.attribute('href').should match /All_Hands_Offsite.*\.jpg$/
|
||||
# Category links
|
||||
page.mmv_image_metadata_category_links_wrapper_element.when_present.should be_visible
|
||||
# File usage
|
||||
page.mmv_image_metadata_fileusage_wrapper_element.when_present.should be_visible
|
||||
page.mmv_image_metadata_fileusage_wrapper_element.when_present.h3_element.text.should match /Used in [0-9] page/
|
||||
page.mmv_image_metadata_fileusage_local_section_title_element.when_present.text.should match /On this site/
|
||||
end
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
Given /^I visit the Commons page$/ do
|
||||
@commons_open_time = Time.now.getutc
|
||||
@browser.goto "https://commons.wikimedia.org/wiki/File:Sunrise_over_fishing_boats_in_Kerala.jpg"
|
||||
end
|
||||
|
||||
Given /^I visit an unrelated Commons page to warm up the browser cache$/ do
|
||||
@browser.goto "https://commons.wikimedia.org/wiki/File:Wikimedia_Foundation_2013_All_Hands_Offsite_-_Day_2_-_Photo_16.jpg"
|
||||
end
|
||||
|
||||
Given /^I have a small browser window$/ do
|
||||
@browser.window.resize_to 900, 700
|
||||
end
|
||||
|
||||
Given /^I have an average browser window$/ do
|
||||
@browser.window.resize_to 1366, 768
|
||||
end
|
||||
|
||||
Given /^I have a large browser window$/ do
|
||||
@browser.window.resize_to 1920, 1080
|
||||
end
|
||||
|
||||
Then /^the File: page image is loaded$/ do
|
||||
on(CommonsPage) do |page|
|
||||
wait_for_image_load page, ".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, "", ""
|
||||
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(LightboxDemoPage) do |page|
|
||||
wait_for_image_load page, ".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
|
||||
|
||||
expected_time = $commons_time * ( percentage.to_f / 100.0 )
|
||||
mmv_time.should < 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
|
10
tests/browser/features/support/pages/commons_page.rb
Normal file
10
tests/browser/features/support/pages/commons_page.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
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
|
|
@ -1,7 +1,7 @@
|
|||
class LightboxDemoPage
|
||||
include PageObject
|
||||
|
||||
include URL
|
||||
|
||||
page_url URL.url("Lightbox_demo")
|
||||
|
||||
# Tag page elements that we will need.
|
||||
|
@ -9,6 +9,8 @@ class LightboxDemoPage
|
|||
# First image in lightbox demo page
|
||||
a(:image1_in_article, class: "image", href: /Kerala\.jpg$/)
|
||||
|
||||
a(:other_image_in_article, href: /Academy_of_Sciences\.jpg$/)
|
||||
|
||||
# Wrapper div for all mmv elements
|
||||
div(:mmv_wrapper, class: "mw-mmv-wrapper")
|
||||
|
||||
|
@ -37,4 +39,5 @@ class LightboxDemoPage
|
|||
div(:mmv_next_button, class: "mw-mmv-next-image")
|
||||
div(:mmv_previous_button, class: "mw-mmv-prev-image")
|
||||
div(:mmv_close_button, class: "mw-mmv-close")
|
||||
div(:mmv_image_loaded_cucumber, class: "mw-mmv-image-loaded-cucumber")
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue