Skip to content

Commit ec65ccc

Browse files
authored
test(integ): add legacy integration test for changed clients only (#2919)
* test(integ): add legacy integration test for changed clients only * chore: rename integration test script
1 parent 5278c2a commit ec65ccc

File tree

10 files changed

+49
-9
lines changed

10 files changed

+49
-9
lines changed

features/dms/dms.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# language: en
2-
@dms
2+
@databasemigrationservice
33
Feature:
44

55
I want to use AWS Database Migration Service

features/dms/step_definitions/dms.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { DatabaseMigrationService } = require("../../../clients/client-database-migration-service");
22
const { Before } = require("cucumber");
33

4-
Before({ tags: "@dms" }, function (scenario, callback) {
4+
Before({ tags: "@databasemigrationservice" }, function (scenario, callback) {
55
this.service = new DatabaseMigrationService({});
66
callback();
77
});

features/elb/elb.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# language: en
2-
@elb
2+
@elasticloadbalancing
33
Feature: Elastic Load Balancing
44

55
I want to use Elastic Load Balancing

features/elb/step_definitions/elb.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { ElasticLoadBalancing } = require("../../../clients/client-elastic-load-balancing");
22
const { Before, Given, Then } = require("cucumber");
33

4-
Before({ tags: "@elb" }, function (scenario, callback) {
4+
Before({ tags: "@elasticloadbalancing" }, function (scenario, callback) {
55
this.service = new ElasticLoadBalancing({});
66
callback();
77
});

features/elbv2/elbv2.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# language: en
2-
@elbv2
2+
@elasticloadbalancingv2
33
Feature:
44

55
I want to use Elastic Load Balancing v2
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { ElasticLoadBalancingV2 } = require("../../../clients/client-elastic-load-balancing-v2");
22
const { Before } = require("cucumber");
33

4-
Before({ tags: "@elbv2" }, function (scenario, callback) {
4+
Before({ tags: "@elasticloadbalancingv2" }, function (scenario, callback) {
55
this.service = new ElasticLoadBalancingV2({});
66
callback();
77
});

features/es/es.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# language: en
2-
@es
2+
@elasticsearchservice
33
Feature:
44

55
I want to use Amazon ES

features/es/step_definitions/es.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { ElasticsearchService } = require("../../../clients/client-elasticsearch-service");
22
const { Before } = require("cucumber");
33

4-
Before({ tags: "@es" }, function (scenario, callback) {
4+
Before({ tags: "@elasticsearchservice" }, function (scenario, callback) {
55
this.service = new ElasticsearchService({});
66
callback();
77
});

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"pretest:all": "yarn build:all",
2222
"test:all": "jest --coverage --passWithNoTests && lerna run test --scope '@aws-sdk/{fetch-http-handler,hash-blob-browser}'",
2323
"test:functional": "jest --config tests/functional/jest.config.js --passWithNoTests",
24-
"test:integration-legacy": "cucumber-js --fail-fast",
24+
"test:integration:legacy": "cucumber-js --fail-fast",
25+
"test:integration:legacy:since:release": "./tests/integ-legacy/index.js",
2526
"test:integration": "jest --config jest.config.integ.js --passWithNoTests",
2627
"test:protocols": "yarn build:protocols && lerna run test --scope '@aws-sdk/aws-*' --ignore '@aws-sdk/*-server'",
2728
"test:server-protocols": "yarn build:server-protocols && lerna run test --scope '@aws-sdk/*-server'",

tests/integ-legacy/index.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env node
2+
3+
const { join, resolve } = require("path");
4+
const { execSync, spawn } = require("child_process");
5+
6+
const ROOT = resolve(join(__dirname, "..", ".."));
7+
const FEATURES_FOLDER = join(ROOT, "features");
8+
const ROOT_BIN = join(ROOT, "node_modules", ".bin");
9+
10+
const execOptions = {
11+
...process,
12+
cwd: __dirname,
13+
encoding: "utf-8",
14+
};
15+
16+
const allTags = execSync(`grep -h ^@ ${join(FEATURES_FOLDER, "**", "*.feature")}`, execOptions).split(/[\n ]/g);
17+
18+
console.info(`Looking for changed clients that has the legacy integration test tag: ${allTags}`);
19+
20+
const changedPackages = execSync(`${join(ROOT_BIN, "lerna")} changed`, execOptions).split("\n");
21+
const changedPackageTags = changedPackages
22+
.map((name) => name.replace("@aws-sdk/client-", ""))
23+
.map((name) => name.replace("-"))
24+
.map((name) => `@${name}`);
25+
26+
const tagsToTest = changedPackageTags.filter((tag) => allTags.includes(tag));
27+
28+
// Cucumber requires cwd to contain the test cases.
29+
const command = `${join("node_modules", ".bin", "cucumber-js")}`;
30+
const args = ["--fail-fast", "-t", `"${tagsToTest.join(" or ")}"`];
31+
console.info(`Running cucumber test: \n${command} ${args.join(" ")}`);
32+
33+
const cucumber = spawn(command, args, { ...execOptions, cwd: ROOT, shell: true });
34+
cucumber.stdout.pipe(process.stdout);
35+
cucumber.stderr.pipe(process.stderr);
36+
cucumber.on("close", (code) => {
37+
if (code === 0) process.exit();
38+
else process.exit(code);
39+
});

0 commit comments

Comments
 (0)