Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions integration-testing/integration-tests/device-integration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,17 @@ if (!isUndefined(topicPrefix)) {

var customAuthHeaders;
var region = args.region;
var customAuthUsername;
var customAuthPassword;

var enableMetrics = true;

if(args.Protocol === 'wss-custom-auth') {
customAuthHeaders = JSON.parse(process.env.CUSTOM_AUTH_HEADERS);
region = 'us-west-2';
region = 'us-east-1';
customAuthUsername = "username?x-amz-customauthorizer-name=" + process.env.CUSTOM_AUTH_NAME;
customAuthPassword = process.env.CUSTOM_AUTH_PASSWORD;
enableMetrics = false;
}

//
Expand All @@ -62,7 +69,10 @@ const device = deviceModule({
port: args.Port,
host: args.Host,
debug: args.Debug,
customAuthHeaders: customAuthHeaders
customAuthHeaders: customAuthHeaders,
username: customAuthUsername,
password: customAuthPassword,
enableMetrics: enableMetrics,
});

var timeout;
Expand Down Expand Up @@ -127,17 +137,17 @@ device
}, Math.max(args.delay,minimumDelay) ); // clip to minimum
}
});
device
device
.on('close', function() {
console.log('close');
process.exit(1);
});
device
device
.on('reconnect', function() {
console.log('reconnect');
process.exit(1);
});
device
device
.on('offline', function() {
console.log('offline');
process.exit(1);
Expand All @@ -149,7 +159,7 @@ device
});
device
.on('message', function(topic, payload) {

var stateObject = JSON.parse( payload.toString() );
console.log('received on \''+topic+'\': '+payload.toString());
if (!isUndefined( stateObject.value ))
Expand Down
14 changes: 12 additions & 2 deletions integration-testing/integration-tests/offline-publishing-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@ function processTest(args) {

var customAuthHeaders;
var region = args.region;
var customAuthUsername;
var customAuthPassword;

var enableMetrics = true;

if(args.Protocol === 'wss-custom-auth') {
customAuthHeaders = JSON.parse(process.env.CUSTOM_AUTH_HEADERS);
region = 'us-west-2';
region = 'us-east-1';
customAuthUsername = "username?x-amz-customauthorizer-name=" + process.env.CUSTOM_AUTH_NAME;
customAuthPassword = process.env.CUSTOM_AUTH_PASSWORD;
enableMetrics = false;
}

//
Expand All @@ -69,7 +76,10 @@ function processTest(args) {
port: args.Port,
host: args.Host,
debug: args.Debug,
customAuthHeaders: customAuthHeaders
customAuthHeaders: customAuthHeaders,
username: customAuthUsername,
password: customAuthPassword,
enableMetrics: enableMetrics,
});
var receiveCount = 0;
var outOfOrderCount = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# Check to make sure the top-level test directory is defined.
#
if [ $NPMTEST_DIR"" = "" ]
if [ $NPMTEST_DIR"" = "" ]
then
echo ${0##*/}": NPMTEST_DIR must be defined!"
exit 1
Expand Down Expand Up @@ -33,7 +33,7 @@ set -o pipefail
RECEIVES_REQUIRED=46
TRANSMITS_TOTAL=48
export HOSTNAME="ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com"
export CUSTOM_AUTH_HOST="ajje7lpljulm4.gamma.us-west-2.iot.amazonaws.com"
export CUSTOM_AUTH_HOST=$(aws --region us-east-1 secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
#
# Process output will be captured in these files.
#
Expand Down Expand Up @@ -93,7 +93,7 @@ if [ $COMBINED_EXIT_CODE"" = "0" ]
then
numReceived=`cat $PROC2_OUTFILE | grep -E '^[0-9]+\ messages received, accumulator=.*' |awk '{print $1}'`
receiveMask=`cat $PROC2_OUTFILE | grep -E '^[0-9]+\ messages received, accumulator=.*' |awk '{print $4}'|sed -e 's/.*=//'`

echo $numReceived" messages received, receive mask ["$receiveMask"]"

if [ $numReceived"" -gt $RECEIVES_REQUIRED"" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# Check to make sure the top-level test directory is defined.
#
if [ $NPMTEST_DIR"" = "" ]
if [ $NPMTEST_DIR"" = "" ]
then
echo ${0##*/}": NPMTEST_DIR must be defined!"
exit 1
Expand All @@ -21,7 +21,7 @@ NODE=node
#
TEST_TAG="test-"$RANDOM
export HOSTNAME="ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com"
export CUSTOM_AUTH_HOST="ajje7lpljulm4.gamma.us-west-2.iot.amazonaws.com"
export CUSTOM_AUTH_HOST=$(aws --region us-east-1 secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
#
# Capture the exit code of the first command which fails in a pipeline.
#
Expand Down Expand Up @@ -120,7 +120,7 @@ then
#
cat $PROC1_OUTFILE | grep -E '^quality' |awk '{print $NF}'
receiveQuality=`cat $PROC1_OUTFILE | grep -E '^quality' |awk '{print $NF}'`

#
# We should receive all of these; allow only a very small error margin.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# Check to make sure the top-level test directory is defined.
#
if [ $NPMTEST_DIR"" = "" ]
if [ $NPMTEST_DIR"" = "" ]
then
echo ${0##*/}": NPMTEST_DIR must be defined!"
exit 1
Expand All @@ -21,7 +21,7 @@ NODE=node
#
TEST_TAG="test-"$RANDOM
export HOSTNAME="ajje7lpljulm4-ats.iot.us-east-1.amazonaws.com"
export CUSTOM_AUTH_HOST="ajje7lpljulm4.gamma.us-west-2.iot.amazonaws.com"
export CUSTOM_AUTH_HOST=$(aws --region us-east-1 secretsmanager get-secret-value --secret-id "unit-test/endpoint" --query "SecretString" | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
#
# Capture the exit code of the first command which fails in a pipeline.
#
Expand Down Expand Up @@ -95,7 +95,7 @@ then
receiveMask1=`cat $PROC1_OUTFILE | grep -E '^[0-9]+\ messages received, accumulator=.*' |awk '{print $4}'|sed -e 's/.*=//'`
numReceived2=`cat $PROC2_OUTFILE | grep -E '^[0-9]+\ messages received, accumulator=.*' |awk '{print $1}'`
receiveMask2=`cat $PROC2_OUTFILE | grep -E '^[0-9]+\ messages received, accumulator=.*' |awk '{print $4}'|sed -e 's/.*=//'`

echo "proc 1: "$numReceived1" messages received, receive mask ["$receiveMask1"]"
echo "proc 2: "$numReceived2" messages received, receive mask ["$receiveMask2"]"

Expand Down
42 changes: 26 additions & 16 deletions integration-testing/integration-tests/thing-integration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ const isUndefined = require('../common/lib/is-undefined.js');
// and subscribes to an MQTT topic; the other (-t 2) listens to deltas on the thing
// shadow and publishes to the MQTT topic. The mode 1 process sends a value with
// each update and doubles it afterwards; the mode 2 process publishes this value
// back to the mode 1 process. Each process adds the value received in an
// back to the mode 1 process. Each process adds the value received in an
// accumulator. After the mode 1 process has sent 48 messages, it prepares to exit
// and sends a 'quit' command on the thing shadow which forces the mode 2 process
// and sends a 'quit' command on the thing shadow which forces the mode 2 process
// to enter its exit logic. As both processes exit, they count the number of bits
// set in their accumulators. This test verifies that thing shadow update and
// deltas are working as well as non-thing publish and subscribe. Since actual
// values are used in the test, it verifies that simple state objects are
// values are used in the test, it verifies that simple state objects are
// transferred correctly, and because it maintains a bitmask of received values it
// allows for some messages to be lost due to QOS:0. A passing integration test
// here should probably expect >90% of the messages to be received on both sides.
Expand Down Expand Up @@ -69,10 +69,17 @@ if (!isUndefined(topicPrefix)) {

var customAuthHeaders;
var region = args.region;
var customAuthUsername;
var customAuthPassword;

var enableMetrics = true;

if(args.Protocol === 'wss-custom-auth') {
customAuthHeaders = JSON.parse(process.env.CUSTOM_AUTH_HEADERS);
region = 'us-west-2';
region = 'us-east-1';
customAuthUsername = "username?x-amz-customauthorizer-name=" + process.env.CUSTOM_AUTH_NAME;
customAuthPassword = process.env.CUSTOM_AUTH_PASSWORD;
enableMetrics = false;
}

//
Expand All @@ -89,7 +96,10 @@ const thingShadows = thingShadow({
port: args.Port,
host: args.Host,
debug: args.Debug,
customAuthHeaders: customAuthHeaders
customAuthHeaders: customAuthHeaders,
username: customAuthUsername,
password: customAuthPassword,
enableMetrics: enableMetrics,
});

var value=1;
Expand Down Expand Up @@ -118,7 +128,7 @@ function checkAccumulator()
}

//
// This test demonstrates the use of thing shadows along with
// This test demonstrates the use of thing shadows along with
// non-thing topics. One process updates a thing shadow and
// subscribes to a non-thing topic; the other receives delta
// updates on the thing shadow on publishes to the non-thing
Expand All @@ -129,7 +139,7 @@ function updateThingShadow( )
if (count < 48)
{
console.log('updating thing shadow...');
clientToken = thingShadows.update( integrationTestShadow,
clientToken = thingShadows.update( integrationTestShadow,
{ state: { desired: { value: value, quit: 0 }}} );
value = value*2;
count++;
Expand All @@ -140,7 +150,7 @@ function updateThingShadow( )
//
// Tell the partner to exit.
//
clientToken = thingShadows.update( integrationTestShadow,
clientToken = thingShadows.update( integrationTestShadow,
{ state: { desired: { value: value, quit: 1 }}} );
setTimeout( function() { process.exit(0); }, 500 );
}
Expand Down Expand Up @@ -169,23 +179,23 @@ thingShadows
else
{
//
// This process will listen to deltas on a thing shadow and publish to a
// This process will listen to deltas on a thing shadow and publish to a
// non-thing topic.
//
thingShadows.register( integrationTestShadow );
}
});
thingShadows
thingShadows
.on('close', function() {
console.log('close');
process.exit(1);
});
thingShadows
thingShadows
.on('reconnect', function() {
console.log('reconnect');
process.exit(1);
});
thingShadows
thingShadows
.on('offline', function() {
console.log('offline');
process.exit(1);
Expand All @@ -201,7 +211,7 @@ thingShadows
accumulator += JSON.parse( payload.toString() ).value;
clearInterval( timer );
//
// After a few seconds, update the thing shadow and if no message has
// After a few seconds, update the thing shadow and if no message has
// been received after 10 seconds, try again.
//
setTimeout( function() {
Expand All @@ -219,7 +229,7 @@ if (args.testMode===2)
{
thingShadows
.on('delta', function(thingName, stateObject) {

console.log('received delta, state='+JSON.stringify( stateObject.state));

if (!stateObject.state.quit)
Expand All @@ -234,8 +244,8 @@ if (args.testMode===2)
// Our partner has told us the test has ended; it's our responsibility to delete
// the shadow afterwards and then exit ourselves.
//
setTimeout( function() {
thingShadows.delete( integrationTestShadow );
setTimeout( function() {
thingShadows.delete( integrationTestShadow );
setTimeout( function() { process.exit(0); }, 500 ); }, 500 );
}
});
Expand Down
Loading