-
Notifications
You must be signed in to change notification settings - Fork 956
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds test lab triggers to firebase deploy (#5011)
* adding in test lab deployment code * merge changelogs * updating product name to Test Lab * fix test
- Loading branch information
1 parent
3b4d850
commit 3b48be0
Showing
6 changed files
with
172 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
- Add the "experiments" family of commands (#4994) | ||
- Enable detecting and skipping no-op function deploys (#5032). | ||
- Catches errors when fetching CLI MOTD, allowing process to continue (#4998). | ||
- Adds test lab triggers to firebase deploy (#5011). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as backend from "../backend"; | ||
import { FirebaseError } from "../../../error"; | ||
|
||
/** | ||
* Sets a Test Lab event trigger's region to 'global' since the service is global | ||
* @param endpoint the test lab endpoint | ||
*/ | ||
export function ensureTestLabTriggerRegion( | ||
endpoint: backend.Endpoint & backend.EventTriggered | ||
): Promise<void> { | ||
if (!endpoint.eventTrigger.region) { | ||
endpoint.eventTrigger.region = "global"; | ||
} | ||
if (endpoint.eventTrigger.region !== "global") { | ||
throw new FirebaseError("A Test Lab trigger must specify 'global' trigger location"); | ||
} | ||
return Promise.resolve(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { expect } from "chai"; | ||
import { Endpoint } from "../../../../deploy/functions/backend"; | ||
import * as testLab from "../../../../deploy/functions/services/testLab"; | ||
|
||
const projectNumber = "123456789"; | ||
|
||
const endpoint: Endpoint = { | ||
id: "endpoint", | ||
region: "us-central1", | ||
project: projectNumber, | ||
eventTrigger: { | ||
retry: false, | ||
eventType: "google.firebase.testlab.testMatrix.v1.completed", | ||
eventFilters: {}, | ||
}, | ||
entryPoint: "endpoint", | ||
platform: "gcfv2", | ||
runtime: "nodejs16", | ||
}; | ||
|
||
describe("ensureTestLabTriggerRegion", () => { | ||
it("should set the trigger location to global", async () => { | ||
const ep = { ...endpoint }; | ||
|
||
await testLab.ensureTestLabTriggerRegion(ep); | ||
|
||
expect(ep.eventTrigger.region).to.eq("global"); | ||
}); | ||
|
||
it("should not error if the trigger location is global", async () => { | ||
const ep = { ...endpoint }; | ||
ep.eventTrigger.region = "global"; | ||
|
||
await testLab.ensureTestLabTriggerRegion(ep); | ||
|
||
expect(ep.eventTrigger.region).to.eq("global"); | ||
}); | ||
|
||
it("should error if the trigger location is not global", () => { | ||
const ep = { ...endpoint }; | ||
ep.eventTrigger.region = "us-west1"; | ||
|
||
expect(() => testLab.ensureTestLabTriggerRegion(ep)).to.throw( | ||
"A Test Lab trigger must specify 'global' trigger location" | ||
); | ||
}); | ||
}); |