Bug 1955808 - Remove messaging-experiment from Normandy r=nimbus-reviewers,emcminn
Bug 1928476 is changing the ExperimentManager's onRecipe API and this action calls into it. We could update it, but Normandy client is slated for removal. Differential Revision: https://phabricator.services.mozilla.com/D242756
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import { BaseStudyAction } from "resource://normandy/actions/BaseStudyAction.sys.mjs";
|
||||
|
||||
const lazy = {};
|
||||
|
||||
ChromeUtils.defineESModuleGetters(lazy, {
|
||||
ActionSchemas: "resource://normandy/actions/schemas/index.sys.mjs",
|
||||
ExperimentManager: "resource://nimbus/lib/ExperimentManager.sys.mjs",
|
||||
});
|
||||
|
||||
const RECIPE_SOURCE = "normandy";
|
||||
|
||||
export class MessagingExperimentAction extends BaseStudyAction {
|
||||
constructor() {
|
||||
super();
|
||||
this.manager = lazy.ExperimentManager;
|
||||
}
|
||||
get schema() {
|
||||
return lazy.ActionSchemas["messaging-experiment"];
|
||||
}
|
||||
|
||||
async _run(recipe) {
|
||||
if (recipe.arguments) {
|
||||
await this.manager.onRecipe(recipe.arguments, RECIPE_SOURCE);
|
||||
}
|
||||
}
|
||||
|
||||
async _finalize() {
|
||||
this.manager.onFinalize(RECIPE_SOURCE);
|
||||
}
|
||||
}
|
||||
@@ -17,62 +17,6 @@ export const ActionSchemas = {
|
||||
},
|
||||
},
|
||||
|
||||
"messaging-experiment": {
|
||||
$schema: "http://json-schema.org/draft-04/schema#",
|
||||
title: "Messaging Experiment",
|
||||
type: "object",
|
||||
required: ["slug", "branches", "isEnrollmentPaused"],
|
||||
properties: {
|
||||
slug: {
|
||||
description: "Unique identifier for this experiment",
|
||||
type: "string",
|
||||
pattern: "^[A-Za-z0-9\\-_]+$",
|
||||
},
|
||||
isEnrollmentPaused: {
|
||||
description: "If true, new users will not be enrolled in the study.",
|
||||
type: "boolean",
|
||||
default: true,
|
||||
},
|
||||
branches: {
|
||||
description: "List of experimental branches",
|
||||
type: "array",
|
||||
minItems: 1,
|
||||
items: {
|
||||
type: "object",
|
||||
required: ["slug", "value", "ratio", "groups"],
|
||||
properties: {
|
||||
slug: {
|
||||
description:
|
||||
"Unique identifier for this branch of the experiment.",
|
||||
type: "string",
|
||||
pattern: "^[A-Za-z0-9\\-_]+$",
|
||||
},
|
||||
value: {
|
||||
description: "Message content.",
|
||||
type: "object",
|
||||
properties: {},
|
||||
},
|
||||
ratio: {
|
||||
description:
|
||||
"Ratio of users who should be grouped into this branch.",
|
||||
type: "integer",
|
||||
minimum: 1,
|
||||
},
|
||||
groups: {
|
||||
description:
|
||||
"A list of experiment groups that can be used to exclude or select related experiments. May be empty.",
|
||||
type: "array",
|
||||
items: {
|
||||
type: "string",
|
||||
description: "Identifier of the group",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
"preference-rollout": {
|
||||
$schema: "http://json-schema.org/draft-04/schema#",
|
||||
title: "Change preferences permanently",
|
||||
|
||||
@@ -14,8 +14,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
||||
BranchedAddonStudyAction:
|
||||
"resource://normandy/actions/BranchedAddonStudyAction.sys.mjs",
|
||||
ConsoleLogAction: "resource://normandy/actions/ConsoleLogAction.sys.mjs",
|
||||
MessagingExperimentAction:
|
||||
"resource://normandy/actions/MessagingExperimentAction.sys.mjs",
|
||||
PreferenceExperimentAction:
|
||||
"resource://normandy/actions/PreferenceExperimentAction.sys.mjs",
|
||||
PreferenceRollbackAction:
|
||||
@@ -49,7 +47,6 @@ export class ActionsManager {
|
||||
"addon-rollout": lazy.AddonRolloutAction,
|
||||
"branched-addon-study": lazy.BranchedAddonStudyAction,
|
||||
"console-log": lazy.ConsoleLogAction,
|
||||
"messaging-experiment": lazy.MessagingExperimentAction,
|
||||
"multi-preference-experiment": lazy.PreferenceExperimentAction,
|
||||
"preference-rollback": lazy.PreferenceRollbackAction,
|
||||
"preference-rollout": lazy.PreferenceRolloutAction,
|
||||
|
||||
@@ -66,8 +66,6 @@ https_first_disabled = true
|
||||
|
||||
["browser_actions_ConsoleLogAction.js"]
|
||||
|
||||
["browser_actions_MessagingExperimentAction.js"]
|
||||
|
||||
["browser_actions_PreferenceExperimentAction.js"]
|
||||
|
||||
["browser_actions_PreferenceRollbackAction.js"]
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
const { BaseAction } = ChromeUtils.importESModule(
|
||||
"resource://normandy/actions/BaseAction.sys.mjs"
|
||||
);
|
||||
const { Uptake } = ChromeUtils.importESModule(
|
||||
"resource://normandy/lib/Uptake.sys.mjs"
|
||||
);
|
||||
const { MessagingExperimentAction } = ChromeUtils.importESModule(
|
||||
"resource://normandy/actions/MessagingExperimentAction.sys.mjs"
|
||||
);
|
||||
|
||||
const { _ExperimentManager, ExperimentManager } = ChromeUtils.importESModule(
|
||||
"resource://nimbus/lib/ExperimentManager.sys.mjs"
|
||||
);
|
||||
|
||||
decorate_task(
|
||||
withStudiesEnabled(),
|
||||
withStub(Uptake, "reportRecipe"),
|
||||
async function arguments_are_validated({ reportRecipeStub }) {
|
||||
const action = new MessagingExperimentAction();
|
||||
|
||||
is(
|
||||
action.manager,
|
||||
ExperimentManager,
|
||||
"should set .manager to ExperimentManager singleton"
|
||||
);
|
||||
// Override this for the purposes of the test
|
||||
action.manager = new _ExperimentManager();
|
||||
await action.manager.onStartup();
|
||||
const onRecipeStub = sinon.spy(action.manager, "onRecipe");
|
||||
|
||||
const recipe = {
|
||||
id: 1,
|
||||
arguments: {
|
||||
slug: "foo",
|
||||
isEnrollmentPaused: false,
|
||||
branches: [
|
||||
{
|
||||
slug: "control",
|
||||
ratio: 1,
|
||||
groups: ["green"],
|
||||
value: { title: "hello" },
|
||||
},
|
||||
{
|
||||
slug: "variant",
|
||||
ratio: 1,
|
||||
groups: ["green"],
|
||||
value: { title: "world" },
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
ok(action.validateArguments(recipe.arguments), "should validate arguments");
|
||||
|
||||
await action.processRecipe(recipe, BaseAction.suitability.FILTER_MATCH);
|
||||
await action.finalize();
|
||||
|
||||
Assert.deepEqual(reportRecipeStub.args, [[recipe, Uptake.RECIPE_SUCCESS]]);
|
||||
Assert.deepEqual(
|
||||
onRecipeStub.args,
|
||||
[[recipe.arguments, "normandy"]],
|
||||
"should call onRecipe with recipe args and 'normandy' source"
|
||||
);
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user