commit 82d9e5ab82f87244422ddcea56518f57b17acdc2
parent 5f91e21037b5034a26d8f99cc5232f534eb31fef
Author: Erik Nordin <enordin@mozilla.com>
Date: Thu, 2 Oct 2025 18:16:17 +0000
Bug 1991761 - Pass architecture arg to Translations e2e tests r=translations-reviewers,gregtatum
This patch updates the Translations end-to-end test arguments
to take an argument for the model architecture to test.
This is a partial patch that will not work as written,
but will work with the subsequent changes in the stack.
Differential Revision: https://phabricator.services.mozilla.com/D266892
Diffstat:
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/browser/components/translations/tests/browser/head.js b/browser/components/translations/tests/browser/head.js
@@ -683,6 +683,7 @@ class TranslationsBencher {
* @param {string} options.page - The URL of the page to test.
* @param {string} options.sourceLanguage - The BCP-47 language tag for the source language.
* @param {string} options.targetLanguage - The BCP-47 language tag for the target language.
+ * @param {("tiny"|"base-memory"|"base")} options.architecture - The architecture of the model.
* @param {number} options.speedBenchCount - The number of speed-sampling runs to perform.
* @param {number} options.memoryBenchCount - The number of memory-sampling runs to perform.
* @param {number} [options.memorySampleInterval] - The interval in milliseconds between memory usage samples.
@@ -693,6 +694,7 @@ class TranslationsBencher {
page,
sourceLanguage,
targetLanguage,
+ architecture,
speedBenchCount,
memoryBenchCount,
memorySampleInterval = 10,
@@ -743,6 +745,7 @@ class TranslationsBencher {
journal,
sourceLanguage,
targetLanguage,
+ architecture,
memoryBenchCount,
memorySampleInterval,
});
@@ -752,6 +755,7 @@ class TranslationsBencher {
journal,
sourceLanguage,
targetLanguage,
+ architecture,
wordCount,
tokenCount,
speedBenchCount,
@@ -769,6 +773,7 @@ class TranslationsBencher {
* @param {TranslationsBencher.Journal} options.journal - The shared metrics journal.
* @param {string} options.sourceLanguage - The BCP-47 language tag for the source language.
* @param {string} options.targetLanguage - The BCP-47 language tag for the target language.
+ * @param {("tiny"|"base-memory"|"base")} options.architecture - The architecture of the model.
* @param {number} options.memoryBenchCount - The number of runs to perform for memory sampling.
* @param {number} options.memorySampleInterval - The interval in milliseconds between memory samples.
*
@@ -779,6 +784,7 @@ class TranslationsBencher {
journal,
sourceLanguage,
targetLanguage,
+ architecture,
memoryBenchCount,
memorySampleInterval,
}) {
@@ -790,6 +796,7 @@ class TranslationsBencher {
{ fromLang: sourceLanguage, toLang: "en" },
{ fromLang: "en", toLang: targetLanguage },
],
+ architecture,
prefs: [["browser.translations.logLevel", "Error"]],
contentEagerMode: true,
});
@@ -894,6 +901,7 @@ class TranslationsBencher {
* @param {TranslationsBencher.Journal} options.journal - The shared metrics journal.
* @param {string} options.sourceLanguage - The BCP-47 language tag for the source language.
* @param {string} options.targetLanguage - The BCP-47 language tag for the target language.
+ * @param {("tiny"|"base-memory"|"base")} options.architecture - The architecture of the model.
* @param {number} options.wordCount - The total word count of the page.
* @param {number} options.tokenCount - The total token count of the page.
* @param {number} options.speedBenchCount - The number of runs to perform for speed sampling.
@@ -905,6 +913,7 @@ class TranslationsBencher {
journal,
sourceLanguage,
targetLanguage,
+ architecture,
wordCount,
tokenCount,
speedBenchCount,
@@ -917,6 +926,7 @@ class TranslationsBencher {
{ fromLang: sourceLanguage, toLang: "en" },
{ fromLang: "en", toLang: targetLanguage },
],
+ architecture,
prefs: [["browser.translations.logLevel", "Error"]],
contentEagerMode: true,
});
diff --git a/toolkit/components/translations/tests/browser/shared-head.js b/toolkit/components/translations/tests/browser/shared-head.js
@@ -1220,7 +1220,7 @@ async function pathExists(path) {
*
* @returns {Promise<object>} - An object containing the removeMocks function and remoteClients.
*/
-async function createFileSystemRemoteSettings(languagePairs) {
+async function createFileSystemRemoteSettings(languagePairs, architecture) {
const { removeMocks, remoteClients } = await createAndMockRemoteSettings({
languagePairs,
useMockedTranslator: false,
@@ -1255,12 +1255,14 @@ async function createFileSystemRemoteSettings(languagePairs) {
const download = async record => {
const recordPath = normalizePathForOS(
- `${artifactDirectory}/${record.name}.zst`
+ record.name === "bergamot-translator"
+ ? `${artifactDirectory}/${record.name}.zst`
+ : `${artifactDirectory}/${architecture}.${record.name}.zst`
);
if (!(await pathExists(recordPath))) {
throw new Error(`
- The record ${record.name} was not found in ${artifactDirectory} specified by MOZ_FETCHES_DIR.
+ The record ${record.name} was not found in ${artifactDirectory} specified by MOZ_FETCHES_DIR at the expected path: ${recordPath}
If you are running a Translations end-to-end test locally, you will need to download the required artifacts to MOZ_FETCHES_DIR.
To configure MOZ_FETCHES_DIR to run Translations end-to-end tests locally, please run toolkit/components/translations/tests/scripts/download-translations-artifacts.py
`);
@@ -1390,6 +1392,7 @@ async function loadTestPage({
systemLocales = ["en"],
appLocales,
webLanguages,
+ architecture,
contentEagerMode = false,
win = window,
}) {
@@ -1444,7 +1447,7 @@ async function loadTestPage({
);
const result = endToEndTest
- ? await createFileSystemRemoteSettings(languagePairs)
+ ? await createFileSystemRemoteSettings(languagePairs, architecture)
: await createAndMockRemoteSettings({
languagePairs,
autoDownloadFromRemoteSettings,