Skip to content

Commit

Permalink
Fixed flaky e2e test (#355)
Browse files Browse the repository at this point in the history
* e2e.ts refactored and adjust expected latency
* README.md moved "Add device" to "Deploy" step
  • Loading branch information
jmostella authored Jun 3, 2021
1 parent f9f0a7b commit ba9bcdf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
9 changes: 5 additions & 4 deletions single_tech_samples/streamanalytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
```bash
APP="tech-sample"
ENVIRONMENT="test"
LOCATION="japaneast"
LOCATION="westus"
STORAGE_ACCOUNT="st${APP/-/}${ENVIRONMENT}"
```

Expand All @@ -50,14 +50,15 @@ az deployment group what-if -f main.bicep -g rg-${APP} --parameters query='@./st
# Create Azure Resources. This will also start the job

az deployment group create -f main.bicep -g rg-${APP} --parameters query='@./streamanalytics-tech-sample.asaql' name=${APP} env=${ENVIRONMENT}

# Add device

az iot hub device-identity create --hub-name iot-${APP}-${ENVIRONMENT} --device-id iot-${APP}-${ENVIRONMENT} --edge-enabled
```

## Functional Test

```bash
# Add device

az iot hub device-identity create --hub-name iot-${APP}-${ENVIRONMENT} --device-id iot-${APP}-${ENVIRONMENT} --edge-enabled

# Use connection information with "Raspberry Pi Azure IoT Online Simulator": https://azure-samples.github.io/raspberry-pi-web-simulator/

Expand Down
16 changes: 8 additions & 8 deletions single_tech_samples/streamanalytics/e2e/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BlobItem, ContainerClient } from '@azure/storage-blob';
chai.use(require('chai-subset'));

const EVENT_SINK_CONTAINER = 'bloboutput';
const EXPECTED_E2E_LATENCY_MS = 1000;
const EXPECTED_E2E_LATENCY_MS = 1500;
const DEVICE_ID = 'modern-data-warehouse-dataops/single_tech_samples/streamanalytics/e2e'

describe('Send to IoT Hub', () => {
Expand Down Expand Up @@ -78,8 +78,8 @@ describe('Send to IoT Hub', () => {
});
}

async function delay(factor = 1) {
await new Promise(resolve => setTimeout(resolve, EXPECTED_E2E_LATENCY_MS * factor));
async function delay() {
await new Promise(resolve => setTimeout(resolve, EXPECTED_E2E_LATENCY_MS));
}

describe('payload with temperature', () => {
Expand All @@ -101,7 +101,7 @@ describe('Send to IoT Hub', () => {
const entries = convertBlobData(blobData);
chai.expect(entries).to.have.length(1);
chai.expect(entries).to.containSubset([data]);
});
}).timeout(3000);
});

describe('equal to 27 degrees', () => {
Expand All @@ -114,11 +114,11 @@ describe('Send to IoT Hub', () => {

await send(message);

await delay(1.5);
await delay();

const blob = await getFirstBlob();
chai.expect(blob).to.be.undefined;
});
}).timeout(2000);
});

describe('less than 27 degrees', () => {
Expand All @@ -131,11 +131,11 @@ describe('Send to IoT Hub', () => {

await send(message);

await delay(1.5);
await delay();

const blob = await getFirstBlob();
chai.expect(blob).to.be.undefined;
});
}).timeout(2000);
});
});
});

0 comments on commit ba9bcdf

Please sign in to comment.