Skip to content

Commit f8258d3

Browse files
author
Bastien Abadie
committed
Fix unit tests & keep string conversions
1 parent 1efa870 commit f8258d3

File tree

9 files changed

+477
-17
lines changed

9 files changed

+477
-17
lines changed

bot/code_coverage_bot/artifacts.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def get(self, platform=None, suite=None, chunk=None):
6060
return filtered_files
6161

6262
def download(self, test_task):
63-
chunk_name = taskcluster.get_chunk(test_task["task"]["metadata"]["name"])
64-
platform_name = taskcluster.get_platform(test_task["task"]["metadata"]["name"])
63+
chunk_name = taskcluster.get_chunk(test_task["task"])
64+
platform_name = taskcluster.get_platform(test_task["task"])
6565
test_task_id = test_task["status"]["taskId"]
6666

6767
for artifact in taskcluster.get_task_artifacts(test_task_id):
@@ -104,7 +104,8 @@ def download_all(self):
104104
task
105105
for group in groups
106106
for task in taskcluster.get_tasks_in_group(group)
107-
if taskcluster.is_coverage_task(task) and not self.is_filtered_task(task)
107+
if taskcluster.is_coverage_task(task["task"])
108+
and not self.is_filtered_task(task)
108109
]
109110
logger.info("Downloading artifacts from {} tasks".format(len(test_tasks)))
110111

@@ -130,10 +131,8 @@ def download_all(self):
130131
status
131132
)
132133

133-
chunk_name = taskcluster.get_chunk(test_task["task"]["metadata"]["name"])
134-
platform_name = taskcluster.get_platform(
135-
test_task["task"]["metadata"]["name"]
136-
)
134+
chunk_name = taskcluster.get_chunk(test_task["task"])
135+
platform_name = taskcluster.get_platform(test_task["task"])
137136

138137
if any(to_ignore in chunk_name for to_ignore in SUITES_TO_IGNORE):
139138
continue

bot/code_coverage_bot/chunk_mapping.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ def get_tests_chunks(revision, platform, suite):
6262
run_key_prefix = "test-linux64-ccov"
6363
elif platform == "windows":
6464
run_key_prefix = "test-windows10-64-ccov"
65+
else:
66+
raise Exception("Unsupported platform {}".format(platform))
6567

6668
r = requests.post(
6769
ACTIVEDATA_QUERY_URL,
@@ -239,7 +241,7 @@ def _inner_generate(
239241
def chunk_test_iter():
240242
test_iter = enumerate(tests_data["result.test"])
241243
return (
242-
(platform, taskcluster.get_chunk(task_names[i]), test)
244+
(platform, taskcluster.name_to_chunk(task_names[i]), test)
243245
for i, test in test_iter
244246
)
245247

@@ -257,7 +259,7 @@ def chunk_test_iter():
257259
(platform, chunk) = futures[future]
258260
files = future.result()
259261

260-
suite = taskcluster.get_suite(chunk)
262+
suite = taskcluster.chunk_to_suite(chunk)
261263
if is_chunk_only_suite(suite):
262264
per_test_cursor.executemany(
263265
"INSERT INTO file_to_chunk VALUES (?,?,?)",

bot/code_coverage_bot/taskcluster.py

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,54 @@ def perform_download():
109109
retry(perform_download)
110110

111111

112+
BUILD_PLATFORMS = [
113+
"build-linux64-ccov/debug",
114+
"build-win64-ccov/debug",
115+
"build-android-test-ccov/opt",
116+
]
117+
118+
TEST_PLATFORMS = [
119+
"test-linux64-ccov/debug",
120+
"test-windows10-64-ccov/debug",
121+
"test-android-em-4.3-arm7-api-16-ccov/debug",
122+
] + BUILD_PLATFORMS
123+
124+
112125
def is_coverage_task(task):
113-
return get_suite(task) != "build"
126+
return any(task["metadata"]["name"].startswith(t) for t in TEST_PLATFORMS)
127+
128+
129+
def name_to_chunk(name):
130+
"""
131+
Helper to convert a task naem to a chunk
132+
Used by chunk mapping
133+
"""
134+
assert isinstance(name, str)
135+
136+
# Some tests are run on build machines, we define a placeholder chunk for those.
137+
if name in BUILD_PLATFORMS:
138+
return "build"
139+
140+
for t in TEST_PLATFORMS:
141+
if name.startswith(t):
142+
name = name[len(t) + 1 :]
143+
break
144+
return "-".join([p for p in name.split("-") if p != "e10s"])
145+
146+
147+
def chunk_to_suite(chunk):
148+
"""
149+
Helper to convert a chunk to a suite (no numbers)
150+
Used by chunk mapping
151+
"""
152+
assert isinstance(chunk, str)
153+
return "-".join([p for p in chunk.split("-") if not p.isdigit()])
114154

115155

116156
def get_chunk(task):
157+
"""
158+
Build clean chunk name from a Taskcluster task
159+
"""
117160
suite = get_suite(task)
118161
chunks = task["extra"].get("chunks", {})
119162
if "current" in chunks:
@@ -122,6 +165,9 @@ def get_chunk(task):
122165

123166

124167
def get_suite(task):
168+
"""
169+
Build clean suite name from a Taskcluster task
170+
"""
125171
assert isinstance(task, dict)
126172
tags = task["tags"]
127173
extra = task["extra"]
@@ -140,6 +186,10 @@ def get_suite(task):
140186

141187

142188
def get_platform(task):
189+
"""
190+
Build clean platform from a Taskcluster task
191+
"""
192+
assert isinstance(task, dict)
143193
assert isinstance(task, dict)
144194
tags = task.get("tags", {})
145195
platform = tags.get("os")
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{
2+
"provisionerId": "aws-provisioner-v1",
3+
"workerType": "gecko-3-b-win2012",
4+
"schedulerId": "gecko-level-3",
5+
"taskGroupId": "Mu6w3n-dS9GOfrv6wGOtvg",
6+
"dependencies": [
7+
"A2glmsCuQP6RKiZ2b64GWw",
8+
"A2x8ujDgTjiUU55Ym0vKFg",
9+
"GpEX9Ol1RRKqxoUtKaEe3Q",
10+
"HdSEPz7vQTCG528C4aPYLA",
11+
"HeAtunPjSe6ovqMjikX_cQ",
12+
"LebTjyemRzylVAXC0W52jA",
13+
"cz8EDILrTYinz5bdpsJUxQ",
14+
"Mu6w3n-dS9GOfrv6wGOtvg"
15+
],
16+
"requires": "all-completed",
17+
"routes": [
18+
"index.gecko.v2.mozilla-central.latest.firefox.win64-debug",
19+
"index.gecko.v2.mozilla-central.pushdate.2019.03.28.20190328173141.firefox.win64-debug",
20+
"index.gecko.v2.mozilla-central.pushlog-id.35772.firefox.win64-debug",
21+
"index.gecko.v2.mozilla-central.revision.e31357c7759379d2279b6883cb09c91997bfaa5d.firefox.win64-debug",
22+
"index.gecko.v2.trunk.revision.e31357c7759379d2279b6883cb09c91997bfaa5d.firefox.win64-debug",
23+
"tc-treeherder.v2.mozilla-central.e31357c7759379d2279b6883cb09c91997bfaa5d.35772"
24+
],
25+
"priority": "medium",
26+
"retries": 5,
27+
"created": "2019-03-28T17:38:38.226Z",
28+
"deadline": "2019-03-29T17:38:38.226Z",
29+
"expires": "2020-03-27T17:38:38.226Z",
30+
"scopes": [
31+
"secrets:get:project/releng/gecko/build/level-3/*",
32+
"secrets:get:project/taskcluster/gecko/hgfingerprint"
33+
],
34+
"payload": {
35+
"maxRunTime": 7200,
36+
"artifacts": [
37+
{
38+
"path": "logs",
39+
"type": "directory",
40+
"name": "public/logs"
41+
},
42+
{
43+
"path": "public/build",
44+
"type": "directory",
45+
"name": "public/build"
46+
}
47+
],
48+
"command": [
49+
":: sccache currently uses the full compiler commandline as input to the\n:: cache hash key, so create a symlink to the task dir and build from\n:: the symlink dir to get consistent paths.\nif exist z:\\build rmdir z:\\build",
50+
"mklink /d z:\\build %cd%",
51+
"icacls z:\\build /grant *S-1-1-0:D /L",
52+
"cd /d z:\\build",
53+
"\"c:\\Program Files\\Mercurial\\hg.exe\" robustcheckout --sharebase y:\\hg-shared --purge --upstream https://hg.mozilla.org/mozilla-unified --revision e31357c7759379d2279b6883cb09c91997bfaa5d https://hg.mozilla.org/mozilla-central .\\build\\src",
54+
":: TinderboxPrint:<a href=https://hg.mozilla.org/mozilla-central/rev/e31357c7759379d2279b6883cb09c91997bfaa5d title='Built from mozilla-central revision e31357c7759379d2279b6883cb09c91997bfaa5d'>e31357c7759379d2279b6883cb09c91997bfaa5d</a>\n",
55+
"c:\\mozilla-build\\python\\python.exe .\\build\\src\\testing\\mozharness\\scripts\\fx_desktop_build.py --config builds\\releng_base_firefox.py --config builds\\taskcluster_base_windows.py --config builds\\taskcluster_base_win64.py --config builds\\taskcluster_sub_win64\\debug.py --branch mozilla-central --work-dir %cd:Z:=z:%\\build --append-env-variables-from-configs"
56+
],
57+
"features": {
58+
"taskclusterProxy": true,
59+
"chainOfTrust": true
60+
},
61+
"env": {
62+
"MOZ_SOURCE_CHANGESET": "e31357c7759379d2279b6883cb09c91997bfaa5d",
63+
"MOZ_BUILD_DATE": "20190328173141",
64+
"MOZ_SOURCE_REPO": "https://hg.mozilla.org/mozilla-central",
65+
"HG_STORE_PATH": "y:/hg-shared",
66+
"GECKO_HEAD_REV": "e31357c7759379d2279b6883cb09c91997bfaa5d",
67+
"MH_BRANCH": "mozilla-central",
68+
"GECKO_PATH": "./build/src",
69+
"MOZ_SCM_LEVEL": "3",
70+
"EXTRA_MOZHARNESS_CONFIG": "{\"update_channel\": \"nightly\", \"mozconfig_variant\": \"debug\"}",
71+
"MOZ_TOOLCHAINS": "public/build/clang.tar.bz2@HdSEPz7vQTCG528C4aPYLA public/build/rustc.tar.bz2@cz8EDILrTYinz5bdpsJUxQ public/build/rust-size.tar.bz2@HeAtunPjSe6ovqMjikX_cQ public/build/cbindgen.tar.bz2@A2glmsCuQP6RKiZ2b64GWw public/build/sccache2.tar.bz2@GpEX9Ol1RRKqxoUtKaEe3Q public/build/nasm.tar.bz2@A2x8ujDgTjiUU55Ym0vKFg public/build/node.tar.bz2@LebTjyemRzylVAXC0W52jA",
72+
"MOZ_SIMPLE_PACKAGE_NAME": "target",
73+
"SCCACHE_IDLE_TIMEOUT": "0",
74+
"GECKO_HEAD_REPOSITORY": "https://hg.mozilla.org/mozilla-central",
75+
"TOOLTOOL_MANIFEST": "browser/config/tooltool-manifests/win64/releng.manifest",
76+
"USE_SCCACHE": "1",
77+
"MOZ_AUTOMATION": "1",
78+
"GECKO_BASE_REPOSITORY": "https://hg.mozilla.org/mozilla-unified"
79+
}
80+
},
81+
"metadata": {
82+
"owner": "[email protected]",
83+
"source": "https://hg.mozilla.org/mozilla-central/file/e31357c7759379d2279b6883cb09c91997bfaa5d/taskcluster/ci/build",
84+
"description": "Win64 Debug ([Treeherder push](https://treeherder.mozilla.org/#/jobs?repo=mozilla-central&revision=e31357c7759379d2279b6883cb09c91997bfaa5d))",
85+
"name": "build-win64/debug"
86+
},
87+
"tags": {
88+
"os": "windows",
89+
"createdForUser": "[email protected]",
90+
"worker-implementation": "generic-worker",
91+
"kind": "build",
92+
"label": "build-win64/debug"
93+
},
94+
"extra": {
95+
"index": {
96+
"rank": 1553794301
97+
},
98+
"treeherder": {
99+
"machine": {
100+
"platform": "windows2012-64"
101+
},
102+
"tier": 1,
103+
"symbol": "B",
104+
"jobKind": "build",
105+
"collection": {
106+
"debug": true
107+
}
108+
},
109+
"treeherder-platform": "windows2012-64/debug",
110+
"parent": "Mu6w3n-dS9GOfrv6wGOtvg"
111+
}
112+
}

0 commit comments

Comments
 (0)