-
Notifications
You must be signed in to change notification settings - Fork 383
Moving to github authoritative #377
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e5c515f
Port integration tests from internal to external; add ci placeholder;…
bretambrose 6263d50
Remove matrix from unit test def
bretambrose 9cbf0a5
Unit test try #1
bretambrose 7c78c96
Try #2
bretambrose 06b2745
Copy-paste github tutorial instead
bretambrose ed58622
Not comfortable committing package-lock yet
bretambrose d668325
Node 10 only for now
bretambrose 1d24f8f
Integration test try #1
bretambrose 01e42b9
Specify region and disable imds region resolution
bretambrose File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - '*' | ||
| - '!main' | ||
|
|
||
| env: | ||
| RUN: ${{ github.run_id }}-${{ github.run_number }} | ||
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
| PACKAGE_NAME: aws-iot-device-sdk-js | ||
| AWS_EC2_METADATA_DISABLED: true | ||
|
|
||
| jobs: | ||
| unit-tests: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| node-version: [10.x] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Unit Tests - Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v2 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| - run: npm install | ||
| - run: npm test | ||
|
|
||
| integration-tests: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| node-version: [10.x] | ||
| test-type: [websocket, certificate] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: ${{ matrix.test-type }} Integration Tests - Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v2 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| - run: cd integration-testing && ./run-tests.sh ${{ matrix.test-type }} | ||
174 changes: 174 additions & 0 deletions
174
integration-testing/integration-tests/device-integration-test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,174 @@ | ||
| /* | ||
| * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"). | ||
| * You may not use this file except in compliance with the License. | ||
| * A copy of the License is located at | ||
| * | ||
| * http://aws.amazon.com/apache2.0 | ||
| * | ||
| * or in the "license" file accompanying this file. This file is distributed | ||
| * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
| * express or implied. See the License for the specific language governing | ||
| * permissions and limitations under the License. | ||
| */ | ||
|
|
||
| //node.js deps | ||
|
|
||
| //npm deps | ||
|
|
||
| //app deps | ||
| const deviceModule = require('..').device; | ||
| const cmdLineProcess = require('../examples/lib/cmdline'); | ||
| const isUndefined = require('../common/lib/is-undefined.js'); | ||
|
|
||
| //begin module | ||
|
|
||
| function processTest( args, argsRemaining ) { | ||
| // | ||
| // Use the command line flag '--thing-name | -T' to pass in a topic | ||
| // prefix; this allows us to run multiple copies of this test simultaneously | ||
| // within the same AWS account | ||
| // | ||
| var topicPrefix = args.thingName; | ||
| var integrationTestTopic = 'deviceIntegrationTestTopic'; | ||
|
|
||
| if (!isUndefined(topicPrefix)) { | ||
| integrationTestTopic=topicPrefix+'/'+integrationTestTopic; | ||
| } | ||
|
|
||
| var customAuthHeaders; | ||
| var region = args.region; | ||
|
|
||
| if(args.Protocol === 'wss-custom-auth') { | ||
| customAuthHeaders = JSON.parse(process.env.CUSTOM_AUTH_HEADERS); | ||
| region = 'us-west-2'; | ||
| } | ||
|
|
||
| // | ||
| // The device module exports an MQTT instance, which will attempt | ||
| // to connect to the AWS IoT endpoint configured in the arguments. | ||
| // Once connected, it will emit events which our application can | ||
| // handle. | ||
| // | ||
| const device = deviceModule({ | ||
| keyPath: args.privateKey, | ||
| certPath: args.clientCert, | ||
| caPath: args.caCert, | ||
| clientId: args.clientId, | ||
| region: region, | ||
| reconnectPeriod: args.reconnectPeriod, | ||
| protocol: args.Protocol, | ||
| port: args.Port, | ||
| host: args.Host, | ||
| debug: args.Debug, | ||
| customAuthHeaders: customAuthHeaders | ||
| }); | ||
|
|
||
| var timeout; | ||
| var value=1; | ||
| var count=1; | ||
| var accumulator=0; | ||
|
|
||
| function checkAccumulator() | ||
| { | ||
| // | ||
| // Check the accumulator to see how many messages were received from the | ||
| // partner process via the MQTT passthrough. | ||
| // | ||
| var i, messages = 0, accSave=accumulator; | ||
| for (i = 0; i < 48; i++) | ||
| { | ||
| if (accumulator & 1) | ||
| { | ||
| messages++; | ||
| } | ||
| accumulator = accumulator>>1; | ||
| } | ||
| console.log(messages+' messages received, accumulator='+accSave.toString(16)); | ||
| } | ||
|
|
||
| // | ||
| // Do a simple publish/subscribe demo based on the test-mode passed | ||
| // in the command line arguments. | ||
| // | ||
| device | ||
| .on('connect', function() { | ||
| const minimumDelay=250; | ||
| console.log('connect'); | ||
| if (args.testMode === 2) | ||
| { | ||
| device.subscribe(integrationTestTopic); | ||
| } | ||
| else | ||
| { | ||
| if ((Math.max(args.delay,minimumDelay) ) !== args.delay) | ||
| { | ||
| console.log( 'substituting '+ minimumDelay + 'ms delay for ' + args.delay + 'ms...' ); | ||
| } | ||
| timeout = setInterval( function() { | ||
| console.log('publishing value='+value+' on \''+integrationTestTopic+'\''); | ||
| device.publish(integrationTestTopic, JSON.stringify({ | ||
| value: value }), { qos: 1 }); | ||
|
|
||
| // | ||
| // After 48 publishes, exit the process. This number is chosen as it's the last power of 2 less | ||
| // than 53 (the mantissa size for Node's native floating point numbers). | ||
| // | ||
| value=value*2; | ||
| count++; | ||
| if (count >= 48) | ||
| { | ||
| device.publish(integrationTestTopic, JSON.stringify({ | ||
| quit: 1 })); | ||
| setTimeout( function() { | ||
| process.exit(0); }, 500); | ||
| } | ||
| }, Math.max(args.delay,minimumDelay) ); // clip to minimum | ||
| } | ||
| }); | ||
| device | ||
| .on('close', function() { | ||
| console.log('close'); | ||
| process.exit(1); | ||
| }); | ||
| device | ||
| .on('reconnect', function() { | ||
| console.log('reconnect'); | ||
| process.exit(1); | ||
| }); | ||
| device | ||
| .on('offline', function() { | ||
| console.log('offline'); | ||
| process.exit(1); | ||
| }); | ||
| device | ||
| .on('error', function(error) { | ||
| console.log('error', error); | ||
| process.exit(1); | ||
| }); | ||
| device | ||
| .on('message', function(topic, payload) { | ||
|
|
||
| var stateObject = JSON.parse( payload.toString() ); | ||
| console.log('received on \''+topic+'\': '+payload.toString()); | ||
| if (!isUndefined( stateObject.value )) | ||
| { | ||
| accumulator+=stateObject.value; | ||
| } | ||
| if (!isUndefined( stateObject.quit)) | ||
| { | ||
| checkAccumulator(); | ||
| setTimeout( function() { process.exit(0); }, 500 ); | ||
| } | ||
| }); | ||
|
|
||
| } | ||
|
|
||
| module.exports = cmdLineProcess; | ||
|
|
||
| if (require.main === module) { | ||
| cmdLineProcess('connect to the AWS IoT service and publish/subscribe to topics using MQTT, test modes 1-2', | ||
| process.argv.slice(2), processTest ); | ||
| } | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add 12 and 14 to this, shouldn't we?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
12 and 14 have build errors that look highly unpleasant to resolve (will require breaking change package upgrades and updating the code that gets broken). So I think it's best to delay that until another time; going to add CD next.