Skip to content

Commit

Permalink
fixing timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
colerogers committed Oct 3, 2022
1 parent 41f0bc3 commit 03556f2
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 97 deletions.
32 changes: 7 additions & 25 deletions scripts/integration-helpers/framework.ts
Expand Up @@ -23,10 +23,7 @@ const STORAGE_BUCKET_FUNCTION_V2_FINALIZED_LOG =
"========== STORAGE BUCKET V2 FUNCTION FINALIZED ==========";
const STORAGE_BUCKET_FUNCTION_V2_METADATA_LOG =
"========== STORAGE BUCKET V2 FUNCTION METADATA ==========";
const RTDB_V2_WRITTEN_LOG = "========== RTDB V2 FUNCTION WRITTEN ==========";
const RTDB_V2_CREATED_LOG = "========== RTDB V2 FUNCTION CREATED ==========";
const RTDB_V2_UPDATED_LOG = "========== RTDB V2 FUNCTION UPDATED ==========";
const RTDB_V2_DELETED_LOG = "========== RTDB V2 FUNCTION DELETED ==========";
const RTDB_V2_FUNCTION_LOG = "========== RTDB V2 FUNCTION ==========";
/* Functions V1 */
const RTDB_FUNCTION_LOG = "========== RTDB FUNCTION ==========";
const FIRESTORE_FUNCTION_LOG = "========== FIRESTORE FUNCTION ==========";
Expand Down Expand Up @@ -145,10 +142,7 @@ export class TriggerEndToEndTest extends EmulatorEndToEndTest {
storageBucketV2MetadataTriggerCount = 0;
authBlockingCreateV2TriggerCount = 0;
authBlockingSignInV2TriggerCount = 0;
rtdbV2WrittenTriggerCount = 0;
rtdbV2CreatedTriggerCount = 0;
rtdbV2UpdatedTriggerCount = 0;
rtdbV2DeletedTriggerCount = 0;
rtdbV2TriggerCount = 0;

rtdbFromFirestore = false;
firestoreFromRtdb = false;
Expand Down Expand Up @@ -184,10 +178,7 @@ export class TriggerEndToEndTest extends EmulatorEndToEndTest {
this.storageBucketV2MetadataTriggerCount = 0;
this.authBlockingCreateV2TriggerCount = 0;
this.authBlockingSignInV2TriggerCount = 0;
this.rtdbV2WrittenTriggerCount = 0;
this.rtdbV2CreatedTriggerCount = 0;
this.rtdbV2UpdatedTriggerCount = 0;
this.rtdbV2DeletedTriggerCount = 0;
this.rtdbV2TriggerCount = 0;
}

/*
Expand Down Expand Up @@ -280,17 +271,8 @@ export class TriggerEndToEndTest extends EmulatorEndToEndTest {
if (data.includes(AUTH_BLOCKING_SIGN_IN_V2_LOG)) {
this.authBlockingSignInV2TriggerCount++;
}
if (data.includes(RTDB_V2_WRITTEN_LOG)) {
this.rtdbV2WrittenTriggerCount++;
}
if (data.includes(RTDB_V2_CREATED_LOG)) {
this.rtdbV2CreatedTriggerCount++;
}
if (data.includes(RTDB_V2_UPDATED_LOG)) {
this.rtdbV2UpdatedTriggerCount++;
}
if (data.includes(RTDB_V2_DELETED_LOG)) {
this.rtdbV2DeletedTriggerCount++;
if (data.includes(RTDB_V2_FUNCTION_LOG)) {
this.rtdbV2TriggerCount++;
}
});

Expand Down Expand Up @@ -362,8 +344,8 @@ export class TriggerEndToEndTest extends EmulatorEndToEndTest {
return this.invokeHttpFunction("signInUserFromAuth");
}

writeUpdateDeleteToRtdb(): Promise<Response> {
return this.invokeHttpFunction("writeUpdateDeleteToRtdb");
writeToRtdb(): Promise<Response> {
return this.invokeHttpFunction("writeToRtdb");
}

writeToFirestore(): Promise<Response> {
Expand Down
9 changes: 3 additions & 6 deletions scripts/triggers-end-to-end-tests/tests.ts
Expand Up @@ -115,7 +115,7 @@ describe("function triggers", () => {
});

after(async function (this) {
this.timeout(EMULATORS_SHUTDOWN_DELAY_MS * 2);
this.timeout(EMULATORS_SHUTDOWN_DELAY_MS);
database?.goOffline();
for (const fn of firestoreUnsub) fn();
await firestore?.terminate();
Expand All @@ -126,7 +126,7 @@ describe("function triggers", () => {
it("should write to the database emulator", async function (this) {
this.timeout(EMULATOR_TEST_TIMEOUT);

const response = await test.writeUpdateDeleteToRtdb();
const response = await test.writeToRtdb();
expect(response.status).to.equal(200);
});

Expand All @@ -148,10 +148,7 @@ describe("function triggers", () => {

it("should have have triggered cloud functions", () => {
expect(test.rtdbTriggerCount).to.equal(1);
expect(test.rtdbV2WrittenTriggerCount).to.eq(1);
expect(test.rtdbV2CreatedTriggerCount).to.eq(1);
expect(test.rtdbV2UpdatedTriggerCount).to.eq(1);
expect(test.rtdbV2DeletedTriggerCount).to.eq(1);
expect(test.rtdbV2TriggerCount).to.eq(1);
expect(test.firestoreTriggerCount).to.equal(1);
/*
* Check for the presence of all expected documents in the firestore
Expand Down
11 changes: 4 additions & 7 deletions scripts/triggers-end-to-end-tests/triggers/index.js
Expand Up @@ -61,15 +61,12 @@ exports.writeToFirestore = functions.https.onRequest(async (req, res) => {
});
});

exports.writeUpdateDeleteToRtdb = functions.https.onRequest(async (req, res) => {
exports.writeToRtdb = functions.https.onRequest(async (req, res) => {
const ref = admin.database().ref(START_DOCUMENT_NAME);
await ref.set({ start: new Date().toISOString() });
console.log("Wrote to RTDB");
await ref.update({ start: new Date().toISOString() });
console.log("Update to RTDB");
await ref.remove();
console.log("Delete from RTDB");
res.json({ status: "done" });
ref.once("value", (snap) => {
res.json({ data: snap });
});
});

exports.writeToPubsub = functions.https.onRequest(async (req, res) => {
Expand Down
14 changes: 7 additions & 7 deletions scripts/triggers-end-to-end-tests/triggers/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scripts/triggers-end-to-end-tests/triggers/package.json
Expand Up @@ -10,7 +10,7 @@
"@google-cloud/pubsub": "^3.0.1",
"firebase": "^9.9.0",
"firebase-admin": "^11.0.0",
"firebase-functions": "^3.22.0"
"firebase-functions": "^3.24.1"
},
"devDependencies": {
"firebase-functions-test": "^0.2.0"
Expand Down
14 changes: 7 additions & 7 deletions scripts/triggers-end-to-end-tests/v1/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scripts/triggers-end-to-end-tests/v1/package.json
Expand Up @@ -8,7 +8,7 @@
"dependencies": {
"@firebase/database-compat": "0.1.2",
"firebase-admin": "^11.0.0",
"firebase-functions": "^3.22.0"
"firebase-functions": "^3.24.1"
},
"devDependencies": {
"firebase-functions-test": "^0.2.0"
Expand Down
40 changes: 5 additions & 35 deletions scripts/triggers-end-to-end-tests/v2/index.js
Expand Up @@ -22,10 +22,7 @@ const AUTH_BLOCKING_CREATE_V2_LOG =
"========== AUTH BLOCKING CREATE V2 FUNCTION METADATA ==========";
const AUTH_BLOCKING_SIGN_IN_V2_LOG =
"========== AUTH BLOCKING SIGN IN V2 FUNCTION METADATA ==========";
const RTDB_WRITTEN_LOG = "========== RTDB V2 FUNCTION WRITTEN ==========";
const RTDB_CREATED_LOG = "========== RTDB V2 FUNCTION CREATED ==========";
const RTDB_UPDATED_LOG = "========== RTDB V2 FUNCTION UPDATED ==========";
const RTDB_DELETED_LOG = "========== RTDB V2 FUNCTION DELETED ==========";
const RTDB_LOG = "========== RTDB V2 FUNCTION ==========";

const PUBSUB_TOPIC = "test-topic";
const START_DOCUMENT_NAME = "test/start";
Expand Down Expand Up @@ -131,34 +128,7 @@ exports.onreqv2timeout = functionsV2.https.onRequest({ timeoutSeconds: 1 }, asyn
});
});

exports.rtdbv2writtenreaction = functionsV2.database.onValueWritten(
START_DOCUMENT_NAME,
(event) => {
console.log(RTDB_WRITTEN_LOG);
return;
}
);

exports.rtdbv2createdreaction = functionsV2.database.onValueCreated(
START_DOCUMENT_NAME,
(event) => {
console.log(RTDB_CREATED_LOG);
return;
}
);

exports.rtdbv2updatedreaction = functionsV2.database.onValueUpdated(
START_DOCUMENT_NAME,
(event) => {
console.log(RTDB_UPDATED_LOG);
return;
}
);

exports.rtdbv2deletedreaction = functionsV2.database.onValueDeleted(
START_DOCUMENT_NAME,
(event) => {
console.log(RTDB_DELETED_LOG);
return;
}
);
exports.rtdbv2reaction = functionsV2.database.onValueWritten(START_DOCUMENT_NAME, (event) => {
console.log(RTDB_LOG);
return;
});
14 changes: 7 additions & 7 deletions scripts/triggers-end-to-end-tests/v2/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scripts/triggers-end-to-end-tests/v2/package.json
Expand Up @@ -7,7 +7,7 @@
},
"dependencies": {
"firebase-admin": "^11.0.0",
"firebase-functions": "^3.22.0"
"firebase-functions": "^3.24.1"
},
"devDependencies": {
"firebase-functions-test": "^0.2.0"
Expand Down

0 comments on commit 03556f2

Please sign in to comment.