Skip to content

Commit

Permalink
iot: add mqtt gateway samples to GA (#1169)
Browse files Browse the repository at this point in the history
* iot: add mqtt gateway samples to GA

* iot: update kokoro iot presubmits, codereview check

* iot: update mqttDeviceDemo arguments

* iot: add iot presubmit common.cfg

* iot: fix name for mqtt-http test

* iot: fix flaky test

* iot: lint fix
  • Loading branch information
hongalex authored Feb 20, 2019
1 parent 91fc1da commit eca6a65
Show file tree
Hide file tree
Showing 12 changed files with 865 additions and 142 deletions.
13 changes: 0 additions & 13 deletions .kokoro/iot-scripts.cfg

This file was deleted.

16 changes: 16 additions & 0 deletions .kokoro/iot/common.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Download trampoline resources. These will be in ${KOKORO_GFILE_DIR}
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Download secrets from Cloud Storage.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/nodejs-docs-samples"

# All builds use the trampoline script to run in docker.
build_file: "nodejs-docs-samples/.kokoro/trampoline.sh"

# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/node:8-user"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion iot/beta-features/gateway/gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,6 @@ function sendDataFromBoundDevice(
if (!success) {
console.log('Client not connected...');
} else if (!publishChainInProgress) {
// TODO: wait for commands
console.log('Client connected: Attaching device');
attachDevice(deviceId, client);
setTimeout(() => {
Expand Down
2 changes: 1 addition & 1 deletion iot/http_example/system-test/cloudiot_http_example.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ test(`should send event message`, async t => {
await tools.runAsync(`${helper} deleteRegistry ${localRegName}`, cwd);
});

test(`should send event message`, async t => {
test(`should send state message`, async t => {
const localDevice = `test-rsa-device`;
const localRegName = `${registryName}-rsa256`;
await tools.runAsync(`${helper} setupIotTopic ${topicName}`, cwd);
Expand Down
24 changes: 19 additions & 5 deletions iot/manager/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1381,10 +1381,10 @@ require(`yargs`) // eslint-disable-line
`Creates a device with the given public key. Public key can be ommitted and added later on.`,
{
publicKeyFormat: {
default: 'RS256_X509_PEM',
default: 'RSA_X509_PEM',
description: 'Public key format for devices.',
requiresArg: true,
choices: ['RS256_PEM', 'RS256_X509_PEM', 'ES256_PEM', 'ES256_X509_PEM'],
choices: ['RSA_PEM', 'RSA_X509_PEM', 'ES256_PEM', 'ES256_X509_PEM'],
type: 'string',
},
publicKeyFile: {
Expand Down Expand Up @@ -1671,7 +1671,21 @@ require(`yargs`) // eslint-disable-line
.command(
`createGateway <registryId> <gatewayId>`,
`Creates a gateway`,
{},
{
publicKeyFormat: {
default: 'RSA_X509_PEM',
description: 'Public key format for devices.',
requiresArg: true,
choices: ['RSA_PEM', 'RSA_X509_PEM', 'ES256_PEM', 'ES256_X509_PEM'],
type: 'string',
},
publicKeyFile: {
description:
'Path to the public key file used for device authentication.',
requiresArg: true,
type: 'string',
},
},
opts => {
const cb = function(client) {
createGateway(
Expand All @@ -1680,8 +1694,8 @@ require(`yargs`) // eslint-disable-line
opts.cloudRegion,
opts.registryId,
opts.gatewayId,
opts.publicKeyFile,
opts.publicKeyFormat
opts.publicKeyFormat,
opts.publicKeyFile
);
};
getClient(opts.serviceAccount, cb);
Expand Down
12 changes: 6 additions & 6 deletions iot/manager/system-test/manager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ test(`should send command message to device`, async t => {
);

tools.runAsync(
`node cloudiot_mqtt_example_nodejs.js --deviceId=${deviceId} --registryId=${registryName} --privateKeyFile=${rsaPrivateKey} --algorithm=RS256 --numMessages=20 --mqttBridgePort=443`,
`node cloudiot_mqtt_example_nodejs.js mqttDeviceDemo --deviceId=${deviceId} --registryId=${registryName} --privateKeyFile=${rsaPrivateKey} --algorithm=RS256 --numMessages=20 --mqttBridgePort=443`,
path.join(__dirname, '../../mqtt_example')
);

Expand All @@ -283,7 +283,7 @@ test(`should send command message to device`, async t => {
test(`should create a new gateway`, async t => {
const gatewayId = `nodejs-test-gateway-iot-${uuid.v4()}`;
let gatewayOut = await tools.runAsync(
`${cmd} createGateway ${registryName} ${gatewayId} RS256_X509_PEM ${rsaPublicCert}`
`${cmd} createGateway ${registryName} ${gatewayId} RSA_X509_PEM ${rsaPublicCert}`
);

// test no error on create gateway.
Expand All @@ -297,7 +297,7 @@ test(`should create a new gateway`, async t => {
test(`should list gateways`, async t => {
const gatewayId = `nodejs-test-gateway-iot-${uuid.v4()}`;
await tools.runAsync(
`${cmd} createGateway ${registryName} ${gatewayId} RS256_X509_PEM ${rsaPublicCert}`
`${cmd} createGateway ${registryName} ${gatewayId} RSA_X509_PEM ${rsaPublicCert}`
);

// look for output in list gateway
Expand All @@ -312,7 +312,7 @@ test(`should list gateways`, async t => {
test(`should bind existing device to gateway`, async t => {
const gatewayId = `nodejs-test-gateway-iot-${uuid.v4()}`;
await tools.runAsync(
`${cmd} createGateway ${registryName} ${gatewayId} RS256_X509_PEM ${rsaPublicCert}`
`${cmd} createGateway ${registryName} ${gatewayId} RSA_X509_PEM ${rsaPublicCert}`
);

// create device
Expand Down Expand Up @@ -350,7 +350,7 @@ test(`should bind existing device to gateway`, async t => {
test(`should list devices bound to gateway`, async t => {
const gatewayId = `nodejs-test-gateway-iot-${uuid.v4()}`;
await tools.runAsync(
`${cmd} createGateway ${registryName} ${gatewayId} RS256_X509_PEM ${rsaPublicCert}`
`${cmd} createGateway ${registryName} ${gatewayId} RSA_X509_PEM ${rsaPublicCert}`
);

const deviceId = `nodejs-test-device-iot-${uuid.v4()}`;
Expand Down Expand Up @@ -389,7 +389,7 @@ test(`should list devices bound to gateway`, async t => {
test(`should list gateways for bound device`, async t => {
const gatewayId = `nodejs-test-gateway-iot-${uuid.v4()}`;
await tools.runAsync(
`${cmd} createGateway ${registryName} ${gatewayId} RS256_X509_PEM ${rsaPublicCert}`
`${cmd} createGateway ${registryName} ${gatewayId} RSA_X509_PEM ${rsaPublicCert}`
);

// create device
Expand Down
Loading

0 comments on commit eca6a65

Please sign in to comment.