Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix e2e test common/server/server.test.ts #555

Merged
merged 2 commits into from
Dec 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion test/e2e/common/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ limitations under the License.
*/

import { CommunicationProtocolEnum, DaprServer, DaprPubSubStatusEnum } from "../../../src";
import * as NodeJSUtil from "../../../src/utils/NodeJS.util";

const serverHost = "127.0.0.1";
const serverGrpcPort = "50001";
Expand Down Expand Up @@ -49,6 +50,9 @@ const bulkSubscribeClodEventTopic = "bulk-subscribe-ce-topic";
const bulkSubscribeCloudEventToRawPayloadTopic = "bulk-subscribe-ce-rp-topic";
const bulkSubscribeRawPayloadToClodEventTopic = "bulk-subscribe-rp-ce-topic";

// Set timeout to 10s for all tests
jest.setTimeout(10000);

describe("common/server", () => {
let httpServer: DaprServer;
let grpcServer: DaprServer;
Expand Down Expand Up @@ -134,9 +138,13 @@ describe("common/server", () => {
});

await setupPubSubSubscriptions();
// Sleep for 2 seconds to allow all subscriptions to be registered
MregXN marked this conversation as resolved.
Show resolved Hide resolved
await NodeJSUtil.sleep(2000);
shubham1172 marked this conversation as resolved.
Show resolved Hide resolved

await httpServer.start();
await grpcServer.start();
// Sleep for 2 seconds to get servers ready
await NodeJSUtil.sleep(2000);
});

beforeEach(() => {
Expand All @@ -161,7 +169,7 @@ describe("common/server", () => {
const res = await server.client.pubsub.publish(pubSubName, getTopic(topicWithStatusCb, protocol), "SUCCESS");
expect(res.error).toBeUndefined();
// Delay a bit for event to arrive
await new Promise((resolve, _reject) => setTimeout(resolve, 1000));
await new Promise((resolve, _reject) => setTimeout(resolve, 2000));
expect(mockSubscribeStatusHandler.mock.calls.length).toBe(1);
expect(mockSubscribeStatusHandler.mock.calls[0][1]).toEqual("SUCCESS");
expect(mockSubscribeDeadletterHandler.mock.calls.length).toBe(0);
Expand Down
Loading