use of tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest in project azure-iot-sdk-java by Azure.
the class QueryTwinTests method queryCollectionCanReturnEmptyQueryResults.
@Test
@StandardTierHubOnlyTest
@ContinuousIntegrationTest
public void queryCollectionCanReturnEmptyQueryResults() throws IOException, IotHubException {
String fullQuery = "select * from devices where deviceId='nonexistantdevice'";
DeviceTwin twinClient = new DeviceTwin(iotHubConnectionString, DeviceTwinClientOptions.builder().httpReadTimeout(HTTP_READ_TIMEOUT).build());
QueryCollection twinQuery = twinClient.queryTwinCollection(fullQuery);
QueryOptions options = new QueryOptions();
QueryCollectionResponse<DeviceTwinDevice> response = twinClient.next(twinQuery, options);
assertNull(response.getContinuationToken());
assertTrue(response.getCollection().isEmpty());
}
use of tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest in project azure-iot-sdk-java by Azure.
the class ExportImportTests method export_import_e2e.
@Test(timeout = IMPORT_EXPORT_TEST_TIMEOUT_MILLISECONDS)
@ContinuousIntegrationTest
@Ignore
public void export_import_e2e() throws Exception {
List<ExportImportDevice> devicesForImport = createListofDevices();
// importing devices - create mode
runImportJob(devicesForImport, ImportMode.CreateOrUpdate, Optional.empty());
List<ExportImportDevice> exportedDevices = runExportJob(Optional.empty());
for (ExportImportDevice importedDevice : devicesForImport) {
if (!exportedDevices.contains(importedDevice)) {
Assert.fail("Exported devices list does not contain device with id: " + importedDevice.getId());
}
}
// importing devices - delete mode
runImportJob(devicesForImport, ImportMode.Delete, Optional.empty());
exportedDevices = runExportJob(Optional.empty());
for (ExportImportDevice importedDevice : devicesForImport) {
if (exportedDevices.contains(importedDevice)) {
Assert.fail("Device with id: " + importedDevice.getId() + " was not deleted by the import job");
}
}
}
use of tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest in project azure-iot-sdk-java by Azure.
the class TransportClientTests method uploadToBlobAsyncSingleFileAndTelemetry.
@Test
@ContinuousIntegrationTest
public void uploadToBlobAsyncSingleFileAndTelemetry() throws Exception {
// arrange
testInstance.setup(false);
setUpFileUploadState();
testInstance.transportClient.open();
ExecutorService executor = Executors.newFixedThreadPool(2);
// act
for (int j = 0; j < testInstance.clientArrayList.size(); j++) {
for (int i = 1; i < MAX_FILES_TO_UPLOAD; i++) {
final int indexI = i;
final int indexJ = j;
executor.submit(() -> {
try {
((DeviceClient) testInstance.clientArrayList.get(indexJ)).uploadToBlobAsync(testInstance.fileUploadState[indexI].blobName, testInstance.fileUploadState[indexI].fileInputStream, testInstance.fileUploadState[indexI].fileLength, new FileUploadCallback(), testInstance.fileUploadState[indexI]);
} catch (IOException e) {
Assert.fail(buildExceptionMessage(e.getMessage(), testInstance.clientArrayList.get(indexJ)));
}
});
executor.submit(() -> testInstance.clientArrayList.get(indexJ).sendEventAsync(new Message(testInstance.messageStates[indexI].messageBody), new FileUploadCallback(), testInstance.messageStates[indexI]));
// assert
FileUploadNotification fileUploadNotification = testInstance.fileUploadNotificationReceiver.receive(MAXIMUM_TIME_TO_WAIT_FOR_IOTHUB_MILLISECONDS);
Assert.assertNotNull(buildExceptionMessage("file upload notification was null", testInstance.clientArrayList.get(indexJ)), fileUploadNotification);
verifyNotification(fileUploadNotification, testInstance.fileUploadState[i], testInstance.clientArrayList.get(indexJ));
Assert.assertTrue(buildExceptionMessage("File upload callback was not triggered for file upload attempt " + i, testInstance.clientArrayList.get(indexJ)), testInstance.fileUploadState[i].isCallBackTriggered);
Assert.assertEquals(buildExceptionMessage("File upload status was not successful on attempt " + i + ", status was: " + testInstance.fileUploadState[i].fileUploadStatus, testInstance.clientArrayList.get(indexJ)), testInstance.fileUploadState[i].fileUploadStatus, SUCCESS);
Assert.assertEquals(buildExceptionMessage("Message status was not successful on attempt " + i + ", status was: " + testInstance.messageStates[i].messageStatus, testInstance.clientArrayList.get(indexJ)), testInstance.messageStates[i].messageStatus, SUCCESS);
}
}
executor.shutdown();
if (!executor.awaitTermination(MULTITHREADED_WAIT_TIMEOUT_MILLISECONDS, TimeUnit.MILLISECONDS)) {
executor.shutdownNow();
}
for (int i = 1; i < MAX_FILES_TO_UPLOAD; i++) {
Assert.assertEquals(CorrelationDetailsLoggingAssert.buildExceptionMessage("File" + i + " has no notification", testInstance.clientArrayList), testInstance.fileUploadState[i].fileUploadNotificationReceived, SUCCESS);
}
testInstance.transportClient.closeNow();
tearDownFileUploadState();
}
use of tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest in project azure-iot-sdk-java by Azure.
the class TransportClientTests method invokeMethodInvokeParallelSucceed.
@Test
@StandardTierHubOnlyTest
@ContinuousIntegrationTest
public void invokeMethodInvokeParallelSucceed() throws Exception {
testInstance.setup(false);
testInstance.transportClient.open();
for (int i = 0; i < testInstance.clientArrayList.size(); i++) {
DeviceMethodStatusCallBack subscribedCallback = new DeviceMethodStatusCallBack();
((DeviceClient) testInstance.clientArrayList.get(i)).subscribeToDeviceMethod(new SampleDeviceMethodCallback(), null, subscribedCallback, null);
long startTime = System.currentTimeMillis();
while (!subscribedCallback.isSubscribed) {
Thread.sleep(200);
if (System.currentTimeMillis() - startTime > METHOD_SUBSCRIBE_TIMEOUT_MILLISECONDS) {
fail(buildExceptionMessage("Timed out waiting for device to subscribe to methods", testInstance.clientArrayList.get(i)));
}
}
}
List<RunnableInvoke> runs = new LinkedList<>();
CountDownLatch countDownLatch = new CountDownLatch(MAX_DEVICE_MULTIPLEX);
for (int i = 0; i < testInstance.clientArrayList.size(); i++) {
RunnableInvoke runnableInvoke = new RunnableInvoke(methodServiceClient, testInstance.devicesList[i].getDeviceId(), METHOD_NAME, METHOD_PAYLOAD, countDownLatch);
new Thread(runnableInvoke).start();
runs.add(runnableInvoke);
}
countDownLatch.await(3, TimeUnit.MINUTES);
Thread.sleep(MAXIMUM_TIME_TO_WAIT_FOR_IOTHUB_PER_CALL_MILLISECONDS * MAX_DEVICE_MULTIPLEX);
for (RunnableInvoke runnableInvoke : runs) {
MethodResult result = runnableInvoke.getResult();
Assert.assertNotNull(CorrelationDetailsLoggingAssert.buildExceptionMessage(runnableInvoke.getException() == null ? "Runnable returns null without exception information" : runnableInvoke.getException().getMessage(), testInstance.clientArrayList), result);
Assert.assertEquals(CorrelationDetailsLoggingAssert.buildExceptionMessage("result was not success, but was: " + result.getStatus(), testInstance.clientArrayList), (long) METHOD_SUCCESS, (long) result.getStatus());
Assert.assertEquals(CorrelationDetailsLoggingAssert.buildExceptionMessage("Received unexpected payload", testInstance.clientArrayList), runnableInvoke.getExpectedPayload(), METHOD_NAME + ":" + result.getPayload().toString());
}
testInstance.transportClient.closeNow();
}
use of tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest in project azure-iot-sdk-java by Azure.
the class SendMessagesErrInjTests method sendMessagesWithTcpConnectionDropNotifiesUserIfRetryExpires.
@Test
@ContinuousIntegrationTest
public void sendMessagesWithTcpConnectionDropNotifiesUserIfRetryExpires() throws Exception {
if (testInstance.protocol == HTTPS || (testInstance.protocol == MQTT_WS && testInstance.authenticationType != SAS) || testInstance.useHttpProxy) {
// MQTT_WS + x509 is not supported for sending messages
return;
}
this.testInstance.setup();
testInstance.identity.getClient().setRetryPolicy(new NoRetry());
Message tcpConnectionDropErrorInjectionMessageUnrecoverable = ErrorInjectionHelper.tcpConnectionDropErrorInjectionMessage(1, 100000);
IotHubServicesCommon.sendMessagesExpectingUnrecoverableConnectionLossAndTimeout(testInstance.identity.getClient(), testInstance.protocol, tcpConnectionDropErrorInjectionMessageUnrecoverable, testInstance.authenticationType);
// reset back to default
testInstance.identity.getClient().setRetryPolicy(new ExponentialBackoffWithJitter());
}
Aggregations