Search in sources :

Example 6 with ContinuousIntegrationTest

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());
}
Also used : QueryCollection(com.microsoft.azure.sdk.iot.service.devicetwin.QueryCollection) DeviceTwinDevice(com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice) IotHubConnectionString(com.microsoft.azure.sdk.iot.service.IotHubConnectionString) QueryOptions(com.microsoft.azure.sdk.iot.service.devicetwin.QueryOptions) DeviceTwin(com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin) StandardTierHubOnlyTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest) ContinuousIntegrationTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest) IotHubTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.IotHubTest) IntegrationTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.IntegrationTest) StandardTierHubOnlyTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest) Test(org.junit.Test) ContinuousIntegrationTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest)

Example 7 with ContinuousIntegrationTest

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");
        }
    }
}
Also used : ExportImportDevice(com.microsoft.azure.sdk.iot.service.ExportImportDevice) Ignore(org.junit.Ignore) ContinuousIntegrationTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest) IotHubTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.IotHubTest) IntegrationTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.IntegrationTest) Test(org.junit.Test) ContinuousIntegrationTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest)

Example 8 with ContinuousIntegrationTest

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();
}
Also used : Message(com.microsoft.azure.sdk.iot.device.Message) CorrelationDetailsLoggingAssert.buildExceptionMessage(tests.integration.com.microsoft.azure.sdk.iot.helpers.CorrelationDetailsLoggingAssert.buildExceptionMessage) ExecutorService(java.util.concurrent.ExecutorService) IOException(java.io.IOException) ContinuousIntegrationTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest) IotHubTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.IotHubTest) StandardTierHubOnlyTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest) ContinuousIntegrationTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest)

Example 9 with ContinuousIntegrationTest

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();
}
Also used : CountDownLatch(java.util.concurrent.CountDownLatch) StandardTierHubOnlyTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest) ContinuousIntegrationTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest) IotHubTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.IotHubTest) StandardTierHubOnlyTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest) ContinuousIntegrationTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest)

Example 10 with ContinuousIntegrationTest

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());
}
Also used : NoRetry(com.microsoft.azure.sdk.iot.device.transport.NoRetry) ExponentialBackoffWithJitter(com.microsoft.azure.sdk.iot.device.transport.ExponentialBackoffWithJitter) ContinuousIntegrationTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest) IotHubTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.IotHubTest) ErrInjTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ErrInjTest) Test(org.junit.Test) ContinuousIntegrationTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest)

Aggregations

ContinuousIntegrationTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest)22 IotHubTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.IotHubTest)22 Test (org.junit.Test)20 StandardTierHubOnlyTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest)15 IntegrationTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.IntegrationTest)14 IOException (java.io.IOException)9 Ignore (org.junit.Ignore)6 IotHubConnectionString (com.microsoft.azure.sdk.iot.service.IotHubConnectionString)5 DeviceTwinDevice (com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice)5 IotHubUnathorizedException (com.microsoft.azure.sdk.iot.service.exceptions.IotHubUnathorizedException)5 ExecutorService (java.util.concurrent.ExecutorService)4 DeviceTestManager (tests.integration.com.microsoft.azure.sdk.iot.helpers.DeviceTestManager)4 Device (com.microsoft.azure.sdk.iot.service.Device)3 ServiceClient (com.microsoft.azure.sdk.iot.service.ServiceClient)3 MethodResult (com.microsoft.azure.sdk.iot.service.devicetwin.MethodResult)3 Pair (com.microsoft.azure.sdk.iot.service.devicetwin.Pair)3 ArrayList (java.util.ArrayList)3 Property (com.microsoft.azure.sdk.iot.device.DeviceTwin.Property)2 Message (com.microsoft.azure.sdk.iot.device.Message)2 Module (com.microsoft.azure.sdk.iot.service.Module)2