Commit 4fc41b3a authored by dtu@chromium.org's avatar dtu@chromium.org

[telemetry] Ensure page sets reference the right WPR archives.

There are some page sets that point to the old src-internal tools/perf/data dir.
Also remove the back-pointer from the archive info file to the page set file. It's unused and confusing when the page set is generated by a script instead.
Slight behavior modification: new archives are now named based on the archive info file instead of the page set.


BUG=223667
TEST=tools/telemetry/run_tests PageSetArchiveInfo

Review URL: https://codereview.chromium.org/99483007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238903 0039d316-1c4b-4281-b951-d872f2087c98
parent d379b0c1
...@@ -27,7 +27,7 @@ class Jsgamebench(test.Test): ...@@ -27,7 +27,7 @@ class Jsgamebench(test.Test):
def CreatePageSet(self, options): def CreatePageSet(self, options):
return page_set.PageSet.FromDict({ return page_set.PageSet.FromDict({
'archive_data_file': '../data/jsgamebench.json', 'archive_data_file': '../page_sets/data/jsgamebench.json',
'pages': [ 'pages': [
{ 'url': 'http://localhost/' } { 'url': 'http://localhost/' }
] ]
......
...@@ -41,7 +41,7 @@ class Kraken(test.Test): ...@@ -41,7 +41,7 @@ class Kraken(test.Test):
def CreatePageSet(self, options): def CreatePageSet(self, options):
return page_set.PageSet.FromDict({ return page_set.PageSet.FromDict({
'archive_data_file': '../data/kraken.json', 'archive_data_file': '../page_sets/data/kraken.json',
'pages': [ 'pages': [
{ 'url': 'http://krakenbenchmark.mozilla.org/kraken-1.1/driver.html' } { 'url': 'http://krakenbenchmark.mozilla.org/kraken-1.1/driver.html' }
] ]
......
...@@ -26,7 +26,7 @@ class RobohornetPro(test.Test): ...@@ -26,7 +26,7 @@ class RobohornetPro(test.Test):
def CreatePageSet(self, options): def CreatePageSet(self, options):
return page_set.PageSet.FromDict({ return page_set.PageSet.FromDict({
'archive_data_file': '../data/robohornetpro.json', 'archive_data_file': '../page_sets/data/robohornet_pro.json',
# Measurement require use of real Date.now() for measurement. # Measurement require use of real Date.now() for measurement.
'make_javascript_deterministic': False, 'make_javascript_deterministic': False,
'pages': [ 'pages': [
......
{ {
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"page_set": "../2012Q3.json",
"archives": { "archives": {
"2012Q3_000.wpr" : [ "2012Q3_000.wpr" : [
"http://www.facebook.com/barackobama", "http://www.facebook.com/barackobama",
......
{ {
"page_set": "../../benchmarks/browsermark.py",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"browsermark_000.wpr": [ "browsermark_000.wpr": [
"http://browsermark.rightware.com/tests/" "http://browsermark.rightware.com/tests/"
] ]
} }
} }
\ No newline at end of file
{ {
"page_set": "../calendar_forward_backward.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"calendar_forward_backward_000.wpr": [ "calendar_forward_backward_000.wpr": [
......
{ {
"page_set": "../canvasmark.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"canvasmark_000.wpr": [ "canvasmark_000.wpr": [
......
{ {
"page_set": "../gmail_alt_threadlist_conversation.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"gmail_alt_threadlist_conversation_000.wpr": [ "gmail_alt_threadlist_conversation_000.wpr": [
......
{ {
"page_set": "../gmail_alt_two_labels.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"gmail_alt_two_labels_000.wpr": [ "gmail_alt_two_labels_000.wpr": [
......
{ {
"page_set": "../gmail_expand_collapse_conversation.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"gmail_expand_collapse_conversation_000.wpr": [ "gmail_expand_collapse_conversation_000.wpr": [
......
{ {
"page_set": "../html5gaming.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"html5gaming_000.wpr": [ "html5gaming_000.wpr": [
"http://html5-benchmark.com/" "http://html5-benchmark.com/"
] ]
} }
} }
\ No newline at end of file
{ {
"page_set": "../intl_ar_fa_he.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"intl_ar_fa_he_000.wpr": [ "intl_ar_fa_he_000.wpr": [
......
{ {
"page_set": "../intl_es_fr_pt-BR.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"intl_es_fr_pt-BR_000.wpr": [ "intl_es_fr_pt-BR_000.wpr": [
......
{ {
"page_set": "../intl_hi_ru.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"intl_hi_ru_000.wpr": [ "intl_hi_ru_000.wpr": [
......
{ {
"page_set": "../intl_ja_zh.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"intl_ja_zh_000.wpr": [ "intl_ja_zh_000.wpr": [
......
{ {
"page_set": "../intl_ko_th_vi.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"intl_ko_th_vi_000.wpr": [ "intl_ko_th_vi_000.wpr": [
......
{ {
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"page_set": "../jsgamebench.json",
"archives": { "archives": {
"jsgamebench_000.wpr" : [ "jsgamebench_000.wpr" : [
"http://localhost/" "http://localhost/"
......
{ {
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"page_set": "../key_desktop_sites.json",
"archives": { "archives": {
"key_desktop_sites_000.wpr" : [ "key_desktop_sites_000.wpr" : [
"http://facebook.com", "http://facebook.com",
......
{ {
"page_set": "../key_mobile_sites.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"key_mobile_sites_000.wpr": [ "key_mobile_sites_000.wpr": [
......
{ {
"page_set": "../key_silk_cases.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"key_silk_cases_000.wpr": [ "key_silk_cases_000.wpr": [
...@@ -15,4 +14,4 @@ ...@@ -15,4 +14,4 @@
"http://jsfiddle.net/3yDKh/3/show" "http://jsfiddle.net/3yDKh/3/show"
] ]
} }
} }
\ No newline at end of file
{ {
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"page_set": "../kraken.json",
"archives": { "archives": {
"kraken_000.wpr" : [ "kraken_000.wpr" : [
"http://krakenbenchmark.mozilla.org/kraken-1.1/driver.html" "http://krakenbenchmark.mozilla.org/kraken-1.1/driver.html"
......
{ {
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"page_set": "../maps_tests.json",
"archives": { "archives": {
"maps_001.wpr": [ "maps_001.wpr": [
"http://localhost:10020/tracker.html" "http://localhost:10020/tracker.html"
] ]
} }
} }
\ No newline at end of file
{ {
"page_set": "../octane.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"octane_000.wpr": [ "octane_000.wpr": [
"http://octane-benchmark.googlecode.com/svn/latest/index.html?auto=1" "http://octane-benchmark.googlecode.com/svn/latest/index.html?auto=1"
] ]
} }
} }
\ No newline at end of file
{ {
"page_set": "../peacekeeper_array.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"peacekeeper_array_000.wpr": [ "peacekeeper_array_000.wpr": [
...@@ -7,4 +6,4 @@ ...@@ -7,4 +6,4 @@
"http://peacekeeper.futuremark.com/run.action?debug=true&repeat=false&forceSuiteName=array&forceTestName=arrayWeighted" "http://peacekeeper.futuremark.com/run.action?debug=true&repeat=false&forceSuiteName=array&forceTestName=arrayWeighted"
] ]
} }
} }
\ No newline at end of file
{ {
"page_set": "../peacekeeper_dom.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"peacekeeper_dom_000.wpr": [ "peacekeeper_dom_000.wpr": [
...@@ -14,4 +13,4 @@ ...@@ -14,4 +13,4 @@
"http://peacekeeper.futuremark.com/run.action?debug=true&repeat=false&forceSuiteName=dom&forceTestName=domQueryselector" "http://peacekeeper.futuremark.com/run.action?debug=true&repeat=false&forceSuiteName=dom&forceTestName=domQueryselector"
] ]
} }
} }
\ No newline at end of file
{ {
"page_set": "../peacekeeper_experimental.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"peacekeeper_experimental_000.wpr": [ "peacekeeper_experimental_000.wpr": [
...@@ -7,4 +6,4 @@ ...@@ -7,4 +6,4 @@
"http://peacekeeper.futuremark.com/run.action?debug=true&repeat=false&forceSuiteName=experimental&forceTestName=experimentalRipple02" "http://peacekeeper.futuremark.com/run.action?debug=true&repeat=false&forceSuiteName=experimental&forceTestName=experimentalRipple02"
] ]
} }
} }
\ No newline at end of file
{ {
"page_set": "../peacekeeper_html5.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"peacekeeper_html5_000.wpr": [ "peacekeeper_html5_000.wpr": [
...@@ -13,4 +12,4 @@ ...@@ -13,4 +12,4 @@
"http://peacekeeper.futuremark.com/run.action?debug=true&repeat=false&forceSuiteName=html5&forceTestName=workerContrast02" "http://peacekeeper.futuremark.com/run.action?debug=true&repeat=false&forceSuiteName=html5&forceTestName=workerContrast02"
] ]
} }
} }
\ No newline at end of file
{ {
"page_set": "../peacekeeper_render.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"peacekeeper_render_000.wpr": [ "peacekeeper_render_000.wpr": [
...@@ -9,4 +8,4 @@ ...@@ -9,4 +8,4 @@
"http://peacekeeper.futuremark.com/run.action?debug=true&repeat=false&forceSuiteName=render&forceTestName=renderPhysics" "http://peacekeeper.futuremark.com/run.action?debug=true&repeat=false&forceSuiteName=render&forceTestName=renderPhysics"
] ]
} }
} }
\ No newline at end of file
{ {
"page_set": "../peacekeeper_string.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"peacekeeper_string_000.wpr": [ "peacekeeper_string_000.wpr": [
...@@ -10,4 +9,4 @@ ...@@ -10,4 +9,4 @@
"http://peacekeeper.futuremark.com/run.action?debug=true&repeat=false&forceSuiteName=string&forceTestName=stringValidateForm" "http://peacekeeper.futuremark.com/run.action?debug=true&repeat=false&forceSuiteName=string&forceTestName=stringValidateForm"
] ]
} }
} }
\ No newline at end of file
{ {
"page_set": "../pica.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"pica_002.wpr": [ "pica_002.wpr": [
"http://localhost/polymer/projects/pica/" "http://localhost/polymer/projects/pica/"
] ]
} }
} }
\ No newline at end of file
{ {
"page_set": "../plus_alt_posts_photos.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"plus_alt_posts_photos_000.wpr": [ "plus_alt_posts_photos_000.wpr": [
......
{ {
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"page_set": "../robohornetpro.json",
"archives": { "archives": {
"robohornetpro_000.wpr" : [ "robohornet_pro_000.wpr" : [
"http://ie.microsoft.com/testdrive/performance/robohornetpro/" "http://ie.microsoft.com/testdrive/performance/robohornetpro/"
] ]
} }
......
{ {
"page_set": "../scirra.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"scirra_000.wpr": [ "scirra_000.wpr": [
...@@ -8,4 +7,4 @@ ...@@ -8,4 +7,4 @@
"http://www.scirra.com/labs/renderperf3/" "http://www.scirra.com/labs/renderperf3/"
] ]
} }
} }
\ No newline at end of file
{ {
"page_set": "../../benchmarks/sunspider.py",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"sunspider_000.wpr": [ "sunspider_000.wpr": [
"http://www.webkit.org/perf/sunspider-1.0.2/sunspider-1.0.2/driver.html" "http://www.webkit.org/perf/sunspider-1.0.2/sunspider-1.0.2/driver.html"
] ]
} }
} }
\ No newline at end of file
{ {
"page_set": "../test.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"test_000.wpr": [ "test_000.wpr": [
......
{ {
"page_set": "../top_10.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"top_10_000.wpr": [ "top_10_000.wpr": [
......
{ {
"page_set": "../top_10_mobile.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"top_10_mobile_002.wpr": [ "top_10_mobile_002.wpr": [
...@@ -18,4 +17,4 @@ ...@@ -18,4 +17,4 @@
"https://mobile.twitter.com/justinbieber&" "https://mobile.twitter.com/justinbieber&"
] ]
} }
} }
\ No newline at end of file
{ {
"page_set": "../top_25.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"top_25_001.wpr": [ "top_25_001.wpr": [
...@@ -35,4 +34,4 @@ ...@@ -35,4 +34,4 @@
"http://techcrunch.com" "http://techcrunch.com"
] ]
} }
} }
\ No newline at end of file
{ {
"page_set": "../tough_canvas_cases.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"tough_canvas_cases_001.wpr": [ "tough_canvas_cases_001.wpr": [
......
{ {
"page_set": "../tough_layout_cases.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"tough_layout_cases_001.wpr": [ "tough_layout_cases_001.wpr": [
......
{ {
"page_set": "../typical_25.json",
"description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a page set. Don't edit by hand! Use record_wpr for updating.",
"archives": { "archives": {
"typical_25_000.wpr": [ "typical_25_000.wpr": [
......
{ {
"description": "Mobile sites for exercising multi-tab memory issues", "description": "Mobile sites for exercising multi-tab memory issues",
"archive_data_file": "../data/key_mobile_sites.json", "archive_data_file": "data/key_mobile_sites.json",
"credentials_path": "../data/credentials.json", "credentials_path": "data/credentials.json",
"user_agent_type": "mobile", "user_agent_type": "mobile",
"pages": [ "pages": [
{ "url": "https://www.google.com/#hl=en&q=barack+obama" }, { "url": "https://www.google.com/#hl=en&q=barack+obama" },
......
...@@ -30,7 +30,7 @@ class PageSet(object): ...@@ -30,7 +30,7 @@ class PageSet(object):
# Create a PageSetArchiveInfo object. # Create a PageSetArchiveInfo object.
if self.archive_data_file: if self.archive_data_file:
self.wpr_archive_info = page_set_archive_info.PageSetArchiveInfo.FromFile( self.wpr_archive_info = page_set_archive_info.PageSetArchiveInfo.FromFile(
os.path.join(self._base_dir, self.archive_data_file), file_path) os.path.join(self._base_dir, self.archive_data_file))
else: else:
self.wpr_archive_info = None self.wpr_archive_info = None
......
...@@ -13,16 +13,13 @@ from telemetry.page import cloud_storage ...@@ -13,16 +13,13 @@ from telemetry.page import cloud_storage
class PageSetArchiveInfo(object): class PageSetArchiveInfo(object):
def __init__(self, archive_data_file_path, page_set_file_path, data): def __init__(self, file_path, data):
self._archive_data_file_path = archive_data_file_path self._file_path = file_path
self._archive_data_file_dir = os.path.dirname(archive_data_file_path) self._base_dir = os.path.dirname(file_path)
# Ensure directory exists. # Ensure directory exists.
if not os.path.exists(self._archive_data_file_dir): if not os.path.exists(self._base_dir):
os.makedirs(self._archive_data_file_dir) os.makedirs(self._base_dir)
# Back pointer to the page set file.
self._page_set_file_path = page_set_file_path
# Download all .wpr files. # Download all .wpr files.
for archive_path in data['archives']: for archive_path in data['archives']:
...@@ -61,12 +58,12 @@ class PageSetArchiveInfo(object): ...@@ -61,12 +58,12 @@ class PageSetArchiveInfo(object):
self.temp_target_wpr_file_path = None self.temp_target_wpr_file_path = None
@classmethod @classmethod
def FromFile(cls, file_path, page_set_file_path): def FromFile(cls, file_path):
if os.path.exists(file_path): if os.path.exists(file_path):
with open(file_path, 'r') as f: with open(file_path, 'r') as f:
data = json.load(f) data = json.load(f)
return cls(file_path, page_set_file_path, data) return cls(file_path, data)
return cls(file_path, page_set_file_path, {'archives': {}}) return cls(file_path, {'archives': {}})
def WprFilePathForPage(self, page): def WprFilePathForPage(self, page):
if self.temp_target_wpr_file_path: if self.temp_target_wpr_file_path:
...@@ -119,21 +116,18 @@ class PageSetArchiveInfo(object): ...@@ -119,21 +116,18 @@ class PageSetArchiveInfo(object):
metadata['description'] = ( metadata['description'] = (
'Describes the Web Page Replay archives for a page set. Don\'t edit by ' 'Describes the Web Page Replay archives for a page set. Don\'t edit by '
'hand! Use record_wpr for updating.') 'hand! Use record_wpr for updating.')
# Pointer from the metadata to the page set .json file.
metadata['page_set'] = os.path.relpath(self._page_set_file_path,
self._archive_data_file_dir)
metadata['archives'] = self._wpr_file_to_urls.copy() metadata['archives'] = self._wpr_file_to_urls.copy()
# Don't write data for abandoned archives. # Don't write data for abandoned archives.
abandoned_wpr_files = self._AbandonedWprFiles() abandoned_wpr_files = self._AbandonedWprFiles()
for wpr_file in abandoned_wpr_files: for wpr_file in abandoned_wpr_files:
del metadata['archives'][wpr_file] del metadata['archives'][wpr_file]
with open(self._archive_data_file_path, 'w') as f: with open(self._file_path, 'w') as f:
json.dump(metadata, f, indent=4) json.dump(metadata, f, indent=4)
f.flush() f.flush()
def _WprFileNameToPath(self, wpr_file): def _WprFileNameToPath(self, wpr_file):
return os.path.abspath(os.path.join(self._archive_data_file_dir, wpr_file)) return os.path.abspath(os.path.join(self._base_dir, wpr_file))
def _NextWprFileName(self): def _NextWprFileName(self):
"""Creates a new file name for a wpr archive file.""" """Creates a new file name for a wpr archive file."""
...@@ -152,7 +146,7 @@ class PageSetArchiveInfo(object): ...@@ -152,7 +146,7 @@ class PageSetArchiveInfo(object):
if not base: if not base:
# If we're creating a completely new info file, use the base name of the # If we're creating a completely new info file, use the base name of the
# page set file. # page set file.
base = os.path.splitext(os.path.basename(self._page_set_file_path))[0] base = os.path.splitext(os.path.basename(self._file_path))[0]
new_filename = '%s_%03d.wpr' % (base, highest_number + 1) new_filename = '%s_%03d.wpr' % (base, highest_number + 1)
return new_filename, self._WprFileNameToPath(new_filename) return new_filename, self._WprFileNameToPath(new_filename)
......
...@@ -48,8 +48,7 @@ class TestPageSetArchiveInfo(unittest.TestCase): ...@@ -48,8 +48,7 @@ class TestPageSetArchiveInfo(unittest.TestCase):
# Create the PageSetArchiveInfo object to be tested. # Create the PageSetArchiveInfo object to be tested.
self.archive_info = page_set_archive_info.PageSetArchiveInfo.FromFile( self.archive_info = page_set_archive_info.PageSetArchiveInfo.FromFile(
self.page_set_archive_info_file, self.page_set_archive_info_file)
os.path.join(tempfile.gettempdir(), 'pageset.json'))
def tearDown(self): def tearDown(self):
shutil.rmtree(self.tmp_dir) shutil.rmtree(self.tmp_dir)
...@@ -113,7 +112,7 @@ class TestPageSetArchiveInfo(unittest.TestCase): ...@@ -113,7 +112,7 @@ class TestPageSetArchiveInfo(unittest.TestCase):
# Write only the page set without the corresponding metadata file. # Write only the page set without the corresponding metadata file.
page_set_contents = (""" page_set_contents = ("""
{ {
archive_data_file": "new-metadata.json", archive_data_file": "new_archive_info.json",
"pages": [ "pages": [
{ {
"url": "%s", "url": "%s",
...@@ -121,16 +120,16 @@ class TestPageSetArchiveInfo(unittest.TestCase): ...@@ -121,16 +120,16 @@ class TestPageSetArchiveInfo(unittest.TestCase):
] ]
}""" % url1) }""" % url1)
page_set_file = os.path.join(self.tmp_dir, 'new.json') page_set_file = os.path.join(self.tmp_dir, 'new_page_set.json')
with open(page_set_file, 'w') as f: with open(page_set_file, 'w') as f:
f.write(page_set_contents) f.write(page_set_contents)
self.page_set_archive_info_file = os.path.join(self.tmp_dir, self.page_set_archive_info_file = os.path.join(self.tmp_dir,
'new-metadata.json') 'new_archive_info.json')
# Create the PageSetArchiveInfo object to be tested. # Create the PageSetArchiveInfo object to be tested.
self.archive_info = page_set_archive_info.PageSetArchiveInfo.FromFile( self.archive_info = page_set_archive_info.PageSetArchiveInfo.FromFile(
self.page_set_archive_info_file, page_set_file) self.page_set_archive_info_file)
# Add a recording for all the pages. # Add a recording for all the pages.
new_temp_recording = os.path.join(self.tmp_dir, 'recording.wpr') new_temp_recording = os.path.join(self.tmp_dir, 'recording.wpr')
...@@ -145,7 +144,7 @@ class TestPageSetArchiveInfo(unittest.TestCase): ...@@ -145,7 +144,7 @@ class TestPageSetArchiveInfo(unittest.TestCase):
self.archive_info.AddRecordedPages([page1.url]) self.archive_info.AddRecordedPages([page1.url])
# Expected name for the recording (decided by PageSetArchiveInfo). # Expected name for the recording (decided by PageSetArchiveInfo).
new_recording = os.path.join(self.tmp_dir, 'new_000.wpr') new_recording = os.path.join(self.tmp_dir, 'new_archive_info_000.wpr')
self.assertTrue(os.path.exists(new_recording)) self.assertTrue(os.path.exists(new_recording))
self.assertFalse(os.path.exists(new_temp_recording)) self.assertFalse(os.path.exists(new_temp_recording))
...@@ -154,7 +153,6 @@ class TestPageSetArchiveInfo(unittest.TestCase): ...@@ -154,7 +153,6 @@ class TestPageSetArchiveInfo(unittest.TestCase):
# Check that the archive info was written correctly. # Check that the archive info was written correctly.
self.assertTrue(os.path.exists(self.page_set_archive_info_file)) self.assertTrue(os.path.exists(self.page_set_archive_info_file))
read_archive_info = page_set_archive_info.PageSetArchiveInfo.FromFile( read_archive_info = page_set_archive_info.PageSetArchiveInfo.FromFile(
self.page_set_archive_info_file, self.page_set_archive_info_file)
os.path.join(tempfile.gettempdir(), 'pageset.json'))
self.assertEquals(new_recording, self.assertEquals(new_recording,
read_archive_info.WprFilePathForPage(page1)) read_archive_info.WprFilePathForPage(page1))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment