Skip to content

Commit 9f0d8cf

Browse files
authored
Iot fix tests (#743)
* Installs modules for test dependency in manager parent * Fix flaky test * Links and installs manager dependency * Moves link to package.json
1 parent b193c3c commit 9f0d8cf

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

iot/http_example/package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@
1111
"test": "repo-tools test run --cmd ava -- -T 3m --verbose system-test/*.test.js"
1212
},
1313
"dependencies": {
14+
"jsonwebtoken": "7.4.1",
15+
"retry-request": "3.3.1",
16+
"yargs": "8.0.2"
17+
},
18+
"devDependencies": {
19+
"manager": "../manager",
1420
"googleapis": "^32.0.0",
1521
"@google-cloud/pubsub": "0.13.2",
1622
"@google-cloud/nodejs-repo-tools": "2.2.5",
1723
"ava": "0.22.0",
18-
"jsonwebtoken": "7.4.1",
19-
"retry-request": "3.3.1",
2024
"semistandard": "^12.0.1",
21-
"uuid": "3.1.0",
22-
"yargs": "8.0.2"
23-
},
24-
"devDependencies": {}
25+
"uuid": "3.1.0"
26+
}
2527
}

iot/http_example/system-test/cloudiot_http_example.test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ const registryName = `nodejs-test-registry-iot-${uuid.v4()}`;
2727
const helper = `node ../manager/manager.js`;
2828
const cmd = `node cloudiot_http_example.js --registryId="${registryName}" --deviceId="${deviceId}" `;
2929
const cwd = path.join(__dirname, `..`);
30-
const installDeps = `pushd ../manager && npm install`;
30+
const installDeps = `npm install`;
3131

32+
test.todo(tools.run(installDeps, `${cwd}/../manager`));
3233
test.before(tools.checkCredentials);
3334
test.before(async () => {
3435
const pubsub = PubSub();
@@ -53,7 +54,6 @@ test(`should receive configuration message`, async (t) => {
5354
const localDevice = `test-rsa-device`;
5455
const localRegName = `${registryName}-rsa256`;
5556

56-
await tools.runAsync(installDeps, cwd);
5757
await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd);
5858
await tools.runAsync(
5959
`${helper} createRegistry ${localRegName} ${topicName}`, cwd);
@@ -75,7 +75,6 @@ test(`should send event message`, async (t) => {
7575
const localDevice = `test-rsa-device`;
7676
const localRegName = `${registryName}-rsa256`;
7777

78-
await tools.runAsync(installDeps, cwd);
7978
await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd);
8079
await tools.runAsync(
8180
`${helper} createRegistry ${localRegName} ${topicName}`, cwd);
@@ -96,7 +95,6 @@ test(`should send event message`, async (t) => {
9695
test(`should send event message`, async (t) => {
9796
const localDevice = `test-rsa-device`;
9897
const localRegName = `${registryName}-rsa256`;
99-
await tools.runAsync(installDeps, cwd);
10098
await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd);
10199
await tools.runAsync(
102100
`${helper} createRegistry ${localRegName} ${topicName}`, cwd);

iot/mqtt_example/package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@
1111
"test": "repo-tools test run --cmd ava -- -T 3m --verbose system-test/*.test.js"
1212
},
1313
"dependencies": {
14+
"jsonwebtoken": "8.2.0",
15+
"mqtt": "2.16.0",
16+
"yargs": "11.0.0"
17+
},
18+
"devDependencies": {
19+
"manager": "../manager",
1420
"googleapis": "^32.0.0",
1521
"@google-cloud/pubsub": "0.16.4",
1622
"@google-cloud/nodejs-repo-tools": "2.2.5",
1723
"ava": "0.25.0",
18-
"jsonwebtoken": "8.2.0",
19-
"mqtt": "2.16.0",
2024
"semistandard": "^12.0.1",
21-
"uuid": "3.2.1",
22-
"yargs": "11.0.0"
23-
},
24-
"devDependencies": {}
25+
"uuid": "3.2.1"
26+
}
2527
}

iot/mqtt_example/system-test/cloudiot_mqtt_example.test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ const helper = `node ../manager/manager.js`;
2727
const cmd = `node cloudiot_mqtt_example_nodejs.js `;
2828
const cmdSuffix = ` --numMessages=1 --privateKeyFile=resources/rsa_private.pem --algorithm=RS256`;
2929
const cwd = path.join(__dirname, `..`);
30-
const installDeps = `pushd ../manager && npm install`;
30+
const installDeps = `npm install`;
3131

32+
test.todo(tools.run(installDeps, `${cwd}/../manager`));
3233
test.before(tools.checkCredentials);
3334
test.before(async () => {
3435
const pubsub = PubSub();
@@ -53,7 +54,6 @@ test(`should receive configuration message`, async (t) => {
5354
const localDevice = `test-rsa-device`;
5455
const localRegName = `${registryName}-rsa256`;
5556

56-
await tools.runAsync(installDeps, cwd);
5757
let output = await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd);
5858
await tools.runAsync(
5959
`${helper} createRegistry ${localRegName} ${topicName}`, cwd);
@@ -78,7 +78,6 @@ test(`should send event message`, async (t) => {
7878
const localDevice = `test-rsa-device`;
7979
const localRegName = `${registryName}-rsa256`;
8080

81-
await tools.runAsync(installDeps, cwd);
8281
await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd);
8382
await tools.runAsync(
8483
`${helper} createRegistry ${localRegName} ${topicName}`, cwd);
@@ -101,7 +100,6 @@ test(`should send event message`, async (t) => {
101100
test(`should send state message`, async (t) => {
102101
const localDevice = `test-rsa-device`;
103102
const localRegName = `${registryName}-rsa256`;
104-
await tools.runAsync(installDeps, cwd);
105103
await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd);
106104
await tools.runAsync(
107105
`${helper} createRegistry ${localRegName} ${topicName}`, cwd);

0 commit comments

Comments
 (0)