From b02582a13a68bf7744bfb58424f3fd19e79782e9 Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Wed, 22 May 2019 18:02:21 +0000 Subject: [PATCH] Bug 1553062 - Send events on Normandy recipe runner start/end r=mythmon Differential Revision: https://phabricator.services.mozilla.com/D32006 --HG-- extra : moz-landing-system : lando --- .../components/normandy/lib/RecipeRunner.jsm | 2 ++ .../test/browser/browser_RecipeRunner.js | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/toolkit/components/normandy/lib/RecipeRunner.jsm b/toolkit/components/normandy/lib/RecipeRunner.jsm index b89f9fd9c185..e0a4bbeb4a13 100644 --- a/toolkit/components/normandy/lib/RecipeRunner.jsm +++ b/toolkit/components/normandy/lib/RecipeRunner.jsm @@ -199,6 +199,7 @@ var RecipeRunner = { }, async run() { + Services.obs.notifyObservers(null, "recipe-runner:start"); this.clearCaches(); // Unless lazy classification is enabled, prep the classify cache. if (!Services.prefs.getBoolPref(LAZY_CLASSIFY_PREF, false)) { @@ -241,6 +242,7 @@ var RecipeRunner = { await actions.finalize(); await Uptake.reportRunner(Uptake.RUNNER_SUCCESS); + Services.obs.notifyObservers(null, "recipe-runner:end"); }, /** diff --git a/toolkit/components/normandy/test/browser/browser_RecipeRunner.js b/toolkit/components/normandy/test/browser/browser_RecipeRunner.js index 14e3942830b8..1ef527da3296 100644 --- a/toolkit/components/normandy/test/browser/browser_RecipeRunner.js +++ b/toolkit/components/normandy/test/browser/browser_RecipeRunner.js @@ -127,6 +127,27 @@ decorate_task( } ); +decorate_task( + withStub(Uptake, "reportRunner"), + withStub(RecipeRunner, "loadRecipes"), + withStub(ActionsManager.prototype, "finalize"), + async function testRunEvents( + reportRunnerStub, + loadRecipesStub, + finalizeStub, + ) { + loadRecipesStub.returns(Promise.resolve([])); + const startPromise = TestUtils.topicObserved("recipe-runner:start"); + const endPromise = TestUtils.topicObserved("recipe-runner:end"); + + await RecipeRunner.run(); + + // Will timeout if notifications were not received. + await startPromise; + await endPromise; + } +); + decorate_task( withPrefEnv({ set: [