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

test(middleware-sdk-rds): use real regions in integration for DNS #4660

Merged
merged 2 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
preset: "ts-jest",
testMatch: ["**/*.integ.spec.ts"],
testMatch: ["**/*.e2e.spec.ts"],
};
3 changes: 2 additions & 1 deletion clients/client-kinesis/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
"extract:docs": "api-extractor run --local",
"generate:client": "node ../../scripts/generate-clients/single-service --solo kinesis"
"generate:client": "node ../../scripts/generate-clients/single-service --solo kinesis",
"test:e2e": "jest --config jest.config.e2e.js"
},
"main": "./dist-cjs/index.js",
"types": "./dist-types/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
preset: "ts-jest",
testMatch: ["**/*.integ.spec.ts"],
testMatch: ["**/*.e2e.spec.ts"],
};
2 changes: 1 addition & 1 deletion clients/client-transcribe-streaming/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
"extract:docs": "api-extractor run --local",
"generate:client": "node ../../scripts/generate-clients/single-service --solo transcribe-streaming",
"test:integration": "jest --config jest.config.integ.js"
"test:e2e": "jest --config jest.config.e2e.js"
},
"main": "./dist-cjs/index.js",
"types": "./dist-types/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ describe("TranscribeStream client", () => {
client.destroy();
});

it("should stream the transcript", async () => {
// TODO: not working in Node.js with HTTP2 handler?
xit("should stream the transcript", async () => {
const LanguageCode = "en-GB";
const MediaEncoding = "pcm";
const MediaSampleRateHertz = 44100;
Expand Down
2 changes: 1 addition & 1 deletion features/extra/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { AfterAll } = require("@cucumber/cucumber");
AfterAll(async () => {
const path = require("path");
const fs = require("fs");
const filePath = path.resolve("integ.buckets.json");
const filePath = path.resolve("e2e.buckets.json");

try {
if (!fs.existsSync(filePath)) return Promise.resolve();
Expand Down
2 changes: 1 addition & 1 deletion features/extra/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ module.exports = {
cacheBucketName: function (bucket) {
const fs = require("fs");
const path = require("path");
const filePath = path.resolve("integ.buckets.json");
const filePath = path.resolve("e2e.buckets.json");
let cache;
if (fs.existsSync(filePath)) {
try {
Expand Down
2 changes: 1 addition & 1 deletion jest.config.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
module.exports = {
projects: [
// "<rootDir>/clients/*/jest.config.e2e.js",
"<rootDir>/clients/*/jest.config.e2e.js",
// "<rootDir>/lib/*/jest.config.integ.js",
"<rootDir>/packages/*/jest.config.e2e.js",
// "<rootDir>/private/*/jest.config.e2e.js",
Expand Down
6 changes: 3 additions & 3 deletions jest.config.integ.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
* These should be run with the yarn test:integration script in each package.
* For tests that involve network requests to live services, see jest.config.e2e.js.
*
* The "test:integration:legacy" tests run with cucumber-js should be considered
* E2E tests in this classification system.
* The tests run with cucumber-js are
* now E2E tests in this classification system.
*/
module.exports = {
projects: [
"<rootDir>/clients/*/jest.config.integ.js",
// "<rootDir>/clients/*/jest.config.integ.js",
// "<rootDir>/lib/*/jest.config.integ.js",
"<rootDir>/packages/*/jest.config.integ.js",
"<rootDir>/private/*/jest.config.integ.js",
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
"local-publish": "node ./scripts/verdaccio-publish/index.js",
"test:all": "yarn build:all && jest --coverage --passWithNoTests && lerna run test --scope '@aws-sdk/{fetch-http-handler,hash-blob-browser}' && yarn test:versions && yarn test:integration",
"test:ci": "lerna run test --since origin/main",
"test:e2e": "yarn build:e2e && node ./tests/e2e/index.js",
"test:e2e": "node ./tests/e2e/index.js",
"test:e2e:legacy": "cucumber-js --fail-fast",
"test:e2e:legacy:since:release": "./tests/integ-e2e/index.js",
"test:functional": "jest --passWithNoTests --config tests/functional/jest.config.js && lerna run test:unit --scope \"@aws-sdk/client-*\"",
"test:integration": "jest --config jest.config.integ.js --passWithNoTests",
"test:integration:legacy": "cucumber-js --fail-fast",
"test:integration:legacy:since:release": "./tests/integ-legacy/index.js",
trivikr marked this conversation as resolved.
Show resolved Hide resolved
"test:protocols": "yarn build:protocols && lerna run test --scope '@aws-sdk/aws-protocoltests-*'",
"test:server-protocols": "yarn build:server-protocols && lerna run test --scope '@aws-sdk/*-server'",
"test:size": "cd scripts/benchmark-size/runner && yarn && ts-node ./cli.ts",
Expand Down
20 changes: 10 additions & 10 deletions packages/middleware-sdk-ec2/src/middleware-sdk-ec2.integ.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe("EC2", () => {
describe("middleware-sdk-ec2", () => {
it("serializes PSU and DestinationRegion", async () => {
const client = new EC2({
region: "us-destination-region-1",
region: "us-east-1",
});

new TestHttpHandler({
Expand All @@ -17,30 +17,30 @@ describe("EC2", () => {
headers: {},
body: (body) => {
const parse = new URLSearchParams(body);
expect(parse.get("DestinationRegion")).toEqual("us-destination-region-1");
expect(parse.get("SourceRegion")).toEqual("us-source-region-1");
expect(parse.get("DestinationRegion")).toEqual("us-east-1");
expect(parse.get("SourceRegion")).toEqual("us-west-2");
expect(parse.get("SourceSnapshotId")).toEqual("my-snapshot-id");
expect(parse.get("Action")).toEqual("CopySnapshot");
expect(parse.get("Version")).toEqual("2016-11-15");
const psu = parse.get("PresignedUrl") as string;
const matcher =
/https\:\/\/ec2\.us-source-region-1\.amazonaws\.com\/\?Action=CopySnapshot&DestinationRegion=us-destination-region-1&SourceRegion=us-source-region-1&SourceSnapshotId=my-snapshot-id&Version=2016-11-15&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=(.+)\%2Fus-source-region-1\%2Fec2\%2Faws4_request&X-Amz-Date=(\d{8})T(\d{6})Z&X-Amz-Expires=3600&X-Amz-Security-Token=(.+)&X-Amz-Signature=(.+)&X-Amz-SignedHeaders=host/;
/https\:\/\/ec2\.us-west-2\.amazonaws\.com\/\?Action=CopySnapshot&DestinationRegion=us-east-1&SourceRegion=us-west-2&SourceSnapshotId=my-snapshot-id&Version=2016-11-15&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=(.+)\%2Fus-west-2\%2Fec2\%2Faws4_request&X-Amz-Date=(\d{8})T(\d{6})Z&X-Amz-Expires=3600&X-Amz-Security-Token=(.+)&X-Amz-Signature=(.+)&X-Amz-SignedHeaders=host/;

expect(psu).toMatch(matcher);
},
}).watch(client);

await client.copySnapshot({
SourceSnapshotId: "my-snapshot-id",
SourceRegion: "us-source-region-1",
SourceRegion: "us-west-2",
});

expect.hasAssertions();
});

it("serializes PSU and DestinationRegion when Encrypted=true and KmsKeyId present", async () => {
const client = new EC2({
region: "us-destination-region-1",
region: "us-east-1",
});

new TestHttpHandler({
Expand All @@ -51,24 +51,24 @@ describe("EC2", () => {
headers: {},
body: (body) => {
const parse = new URLSearchParams(body);
expect(parse.get("DestinationRegion")).toEqual("us-destination-region-1");
expect(parse.get("DestinationRegion")).toEqual("us-east-1");
expect(parse.get("Encrypted")).toEqual("true");
expect(parse.get("KmsKeyId")).toEqual("my-kms-key");
expect(parse.get("SourceRegion")).toEqual("us-source-region-1");
expect(parse.get("SourceRegion")).toEqual("us-west-2");
expect(parse.get("SourceSnapshotId")).toEqual("my-snapshot-id");
expect(parse.get("Action")).toEqual("CopySnapshot");
expect(parse.get("Version")).toEqual("2016-11-15");
const psu = parse.get("PresignedUrl") as string;
const matcher =
/https\:\/\/ec2\.us-source-region-1\.amazonaws\.com\/\?Action=CopySnapshot&DestinationRegion=us-destination-region-1&Encrypted=true&KmsKeyId=my-kms-key&SourceRegion=us-source-region-1&SourceSnapshotId=my-snapshot-id&Version=2016-11-15&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=(.+)\%2Fus-source-region-1\%2Fec2\%2Faws4_request&X-Amz-Date=(\d{8})T(\d{6})Z&X-Amz-Expires=3600&X-Amz-Security-Token=(.+)&X-Amz-Signature=(.+)&X-Amz-SignedHeaders=host/;
/https\:\/\/ec2\.us-west-2\.amazonaws\.com\/\?Action=CopySnapshot&DestinationRegion=us-east-1&Encrypted=true&KmsKeyId=my-kms-key&SourceRegion=us-west-2&SourceSnapshotId=my-snapshot-id&Version=2016-11-15&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=(.+)\%2Fus-west-2\%2Fec2\%2Faws4_request&X-Amz-Date=(\d{8})T(\d{6})Z&X-Amz-Expires=3600&X-Amz-Security-Token=(.+)&X-Amz-Signature=(.+)&X-Amz-SignedHeaders=host/;

expect(psu).toMatch(matcher);
},
}).watch(client);

await client.copySnapshot({
SourceSnapshotId: "my-snapshot-id",
SourceRegion: "us-source-region-1",
SourceRegion: "us-west-2",
Encrypted: true,
KmsKeyId: "my-kms-key",
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe(RDS.name, () => {
describe("middleware-sdk-rds", () => {
it("copyDBClusterSnapshot without KMS key", async () => {
const client = new RDS({
region: "us-destination-region-1",
region: "us-east-1",
});

new TestHttpHandler({
Expand All @@ -18,7 +18,7 @@ describe(RDS.name, () => {
body: (body) => {
const parse = new URLSearchParams(body);
expect(parse.get("SourceDBClusterSnapshotIdentifier")).toEqual(
"arn:aws:rds:us-source-region-1:1234567890:my-db-cluster-snapshot-id"
"arn:aws:rds:us-west-2:1234567890:my-db-cluster-snapshot-id"
);
expect(parse.get("TargetDBClusterSnapshotIdentifier")).toEqual("my-target-db-cluster-snapshot-id");
expect(parse.get("Action")).toEqual("CopyDBClusterSnapshot");
Expand All @@ -40,7 +40,7 @@ describe(RDS.name, () => {
}).watch(client);

await client.copyDBClusterSnapshot({
SourceDBClusterSnapshotIdentifier: "arn:aws:rds:us-source-region-1:1234567890:my-db-cluster-snapshot-id",
SourceDBClusterSnapshotIdentifier: "arn:aws:rds:us-west-2:1234567890:my-db-cluster-snapshot-id",
TargetDBClusterSnapshotIdentifier: "my-target-db-cluster-snapshot-id",
});

Expand All @@ -49,7 +49,7 @@ describe(RDS.name, () => {

it("copyDBSnapshot with KMS key", async () => {
const client = new RDS({
region: "us-destination-region-1",
region: "us-east-1",
});

new TestHttpHandler({
Expand All @@ -60,9 +60,7 @@ describe(RDS.name, () => {
headers: {},
body: (body) => {
const parse = new URLSearchParams(body);
expect(parse.get("SourceDBSnapshotIdentifier")).toEqual(
"arn:aws:rds:us-source-region-1:1234567890:my-db-snapshot-id"
);
expect(parse.get("SourceDBSnapshotIdentifier")).toEqual("arn:aws:rds:us-west-2:1234567890:my-db-snapshot-id");
expect(parse.get("TargetDBSnapshotIdentifier")).toEqual("my-target-snapshot-id");
expect(parse.get("Action")).toEqual("CopyDBSnapshot");
expect(parse.get("Version")).toEqual("2014-10-31");
Expand All @@ -84,7 +82,7 @@ describe(RDS.name, () => {
}).watch(client);

await client.copyDBSnapshot({
SourceDBSnapshotIdentifier: "arn:aws:rds:us-source-region-1:1234567890:my-db-snapshot-id",
SourceDBSnapshotIdentifier: "arn:aws:rds:us-west-2:1234567890:my-db-snapshot-id",
TargetDBSnapshotIdentifier: "my-target-snapshot-id",
KmsKeyId: "my-kms-key",
});
Expand All @@ -94,7 +92,7 @@ describe(RDS.name, () => {

it("startDBInstanceAutomatedBackupsReplication with KMS key", async () => {
const client = new RDS({
region: "us-destination-region-1",
region: "us-east-1",
});

new TestHttpHandler({
Expand All @@ -105,9 +103,7 @@ describe(RDS.name, () => {
headers: {},
body: (body) => {
const parse = new URLSearchParams(body);
expect(parse.get("SourceDBInstanceArn")).toEqual(
"arn:aws:rds:us-source-region-1:1234567890:my-db-instance-id"
);
expect(parse.get("SourceDBInstanceArn")).toEqual("arn:aws:rds:us-west-2:1234567890:my-db-instance-id");
expect(parse.get("Action")).toEqual("StartDBInstanceAutomatedBackupsReplication");
expect(parse.get("Version")).toEqual("2014-10-31");
expect(parse.get("KmsKeyId")).toEqual("my-kms-key");
Expand All @@ -128,7 +124,7 @@ describe(RDS.name, () => {
}).watch(client);

await client.startDBInstanceAutomatedBackupsReplication({
SourceDBInstanceArn: "arn:aws:rds:us-source-region-1:1234567890:my-db-instance-id",
SourceDBInstanceArn: "arn:aws:rds:us-west-2:1234567890:my-db-instance-id",
KmsKeyId: "my-kms-key",
});

Expand Down
6 changes: 3 additions & 3 deletions scripts/utils/spawn-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ const { spawn } = require("child_process");
const spawnProcess = async (command, args = [], options = {}) => {
const childProcess = spawn(command, args, options);

childProcess.stdout.pipe(process.stdout);
childProcess.stderr.pipe(process.stderr);
childProcess.stdout?.pipe(process.stdout);
childProcess.stderr?.pipe(process.stderr);

return new Promise((resolve, reject) => {
childProcess.on("error", reject);
childProcess.on("exit", (code, signal) =>
code === 0 ? resolve() : reject(`${command} failed with { code: ${code}, signal: ${signal} }`)
code === 0 ? resolve(0) : reject(`${command} failed with { code: ${code}, signal: ${signal} }`)
);
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const execOptions = {

const allTags = execSync(`grep -h ^@ ${join(FEATURES_FOLDER, "**", "*.feature")}`, execOptions).split(/[\n ]/g);

console.info(`Looking for changed clients that has the legacy integration test tag: ${allTags}`);
console.info(`Looking for changed clients that has the legacy e2e test tag: ${allTags}`);

let changedPackages = [];
try {
Expand Down
10 changes: 6 additions & 4 deletions tests/e2e/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
const { join } = require("path");

const { getIntegTestResources } = require("./get-integ-test-resources");
const execa = require("execa");
const { spawnProcess } = require("../../scripts/utils/spawn-process");

const run = async () => {
try {
const integTestResourcesEnv = await getIntegTestResources();
await execa("yarn", ["lerna", "run", "test:e2e", "--since", "--concurrency", "1"], {
await spawnProcess("lerna", ["run", "test:e2e", "--concurrency", "1"], {
cwd: join(__dirname, "..", ".."),
env: {
...integTestResourcesEnv,
...process.env,
...integTestResourcesEnv,
},
stdio: "inherit",
});
process.exit(0);
} catch (e) {
Expand Down