- * This is a workaround for SUREFIRE-1799, which silently drops unit tests in case
- * there is an exception being thrown in a method of a {@link MethodSource}. As we
- * create {@link Device}s for parametrized tests and creation of devices might fail,
- * that will be an issue.
- *
- * The idea is to delay the actual execution of the device creation until it
- * is running in the actual test case. So instead of creating devices, we create
- * code that creates devices. The call to the {@link #get()} method should perform
- * the actual device creation, and it may fail, which is reported as a test failure.
- *
- * @see SUREFIRE-1799
- */
-@FunctionalInterface
-public interface DeviceSupplier {
-
- public Device get() throws Exception;
-
- /**
- * Allows to override the output of the {@link #toString()} method.
- *
- * This may be used to provide a stable name for parameterized test.
- *
- * @implNote This was originally part of the {@link Device} class. Due to
- * SUREFIRE-1799 this code currently lives here.
- *
- * @param name The value to report from {@link #toString()}.
- * @return The new instance, reporting the provided name.
- */
- static DeviceSupplier named(final String name, final DeviceSupplier supplier) {
-
- Objects.requireNonNull(name);
- Objects.requireNonNull(supplier);
-
- return new DeviceSupplier() {
-
- @Override
- public Device get() throws Exception {
- return supplier.get();
- }
-
- @Override
- public String toString() {
- return name;
- }
- };
-
- }
-
-}
diff --git a/systemtests/src/test/java/io/enmasse/systemtest/iot/IoTTestSessionTest.java b/systemtests/src/test/java/io/enmasse/systemtest/iot/IoTTestSessionTest.java
deleted file mode 100644
index f5b600013c1..00000000000
--- a/systemtests/src/test/java/io/enmasse/systemtest/iot/IoTTestSessionTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2020, EnMasse authors.
- * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
- */
-
-package io.enmasse.systemtest.iot;
-
-import static io.enmasse.systemtest.TestTag.FRAMEWORK;
-import static io.enmasse.systemtest.iot.IoTTestSession.Adapter.HTTP;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.junit.jupiter.api.Tag;
-import org.junit.jupiter.api.Test;
-
-import io.enmasse.iot.model.v1.IoTConfig;
-import io.enmasse.systemtest.iot.IoTTestSession.Adapter;
-
-@Tag(FRAMEWORK)
-public class IoTTestSessionTest {
-
- @Test
- public void testNameInDefaultConfig() throws Exception {
- var config = IoTTestSession.createDefaultConfig("default-ns", true).build();
-
- assertDefaultConfig(config);
- }
-
- @Test
- public void testNameInDefaultConfigAfterChange() throws Exception {
- var configBuilder = IoTTestSession.createDefaultConfig("default-ns", true);
-
- assertDefaultConfig(configBuilder.build());
-
- for (Adapter adapter : Adapter.values()) {
- configBuilder = adapter.disable(configBuilder);
- }
- configBuilder = HTTP.enable(configBuilder);
-
- assertDefaultConfig(configBuilder.build());
-
- }
-
- private void assertDefaultConfig(IoTConfig config) {
- assertNotNull(config);
-
- assertNotNull(config.getMetadata());
- assertEquals("default", config.getMetadata().getName());
- assertEquals("default-ns", config.getMetadata().getNamespace());
- }
-
- @Test
- public void testEnableAdapter() throws Exception {
- AtomicBoolean called = new AtomicBoolean();
-
- IoTTestSession
- .create("default-ns", true)
- .adapters(Adapter.HTTP)
- .config(configBuilder -> {
-
- var config = configBuilder.build();
-
- assertNotNull(config.getSpec());
- assertNotNull(config.getSpec().getAdapters());
-
- assertNotNull(config.getSpec().getAdapters().getHttp());
- assertEquals(Boolean.TRUE, config.getSpec().getAdapters().getHttp().getEnabled());
-
- assertNotNull(config.getSpec().getAdapters().getMqtt());
- assertEquals(Boolean.FALSE, config.getSpec().getAdapters().getMqtt().getEnabled());
-
- called.set(true);
-
- });
-
- assertTrue(called.get());
- }
-
-}
diff --git a/systemtests/src/test/java/io/enmasse/systemtest/iot/KeyStoreCreatorTest.java b/systemtests/src/test/java/io/enmasse/systemtest/iot/KeyStoreCreatorTest.java
deleted file mode 100644
index 60aae1db950..00000000000
--- a/systemtests/src/test/java/io/enmasse/systemtest/iot/KeyStoreCreatorTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2020, EnMasse authors.
- * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
- */
-
-package io.enmasse.systemtest.iot;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import java.time.Duration;
-import java.time.Instant;
-
-import javax.security.auth.x500.X500Principal;
-
-import org.junit.jupiter.api.Tag;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.EnumSource;
-
-import io.enmasse.systemtest.TestTag;
-import io.enmasse.systemtest.iot.DeviceCertificateManager.Mode;
-
-@Tag(TestTag.FRAMEWORK)
-public class KeyStoreCreatorTest {
-
- @Test
- public void testBasicRsa() throws Exception {
- var mgr = new DeviceCertificateManager(Mode.RSA, new X500Principal("O=EnMasse,C=IO"));
- var device = mgr.createDevice("foo", Instant.now(), Duration.ofDays(90));
- KeyStoreCreator.from(device.getKey().getPrivate(), device.getCertificate());
- }
-
- @Test
- public void testBasicEc() throws Exception {
- var mgr = new DeviceCertificateManager(Mode.EC, new X500Principal("O=EnMasse,C=IO"));
- var device = mgr.createDevice("foo", Instant.now(), Duration.ofDays(90));
- KeyStoreCreator.from(device.getKey().getPrivate(), device.getCertificate());
- }
-
- @ParameterizedTest(name = "testToByteArray-{0}")
- @EnumSource(Mode.class)
- public void testToByteArray(final Mode mode) throws Exception {
- var mgr = new DeviceCertificateManager(mode, new X500Principal("O=EnMasse,C=IO"));
- var device = mgr.createDevice("foo", Instant.now(), Duration.ofDays(90));
-
- byte[] bytes = KeyStoreCreator.toByteArray(device.getKey().getPrivate(), device.getCertificate());
-
- assertNotNull(bytes);
- }
-
-}
diff --git a/systemtests/src/test/java/io/enmasse/systemtest/iot/MessageSendTesterTest.java b/systemtests/src/test/java/io/enmasse/systemtest/iot/MessageSendTesterTest.java
deleted file mode 100644
index a74c23fa442..00000000000
--- a/systemtests/src/test/java/io/enmasse/systemtest/iot/MessageSendTesterTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2020, EnMasse authors.
- * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
- */
-
-package io.enmasse.systemtest.iot;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-
-import org.junit.jupiter.api.Tag;
-import org.junit.jupiter.api.Test;
-
-import io.enmasse.systemtest.TestTag;
-import io.vertx.core.json.JsonObject;
-
-@Tag(TestTag.FRAMEWORK)
-public class MessageSendTesterTest {
-
- @Test
- public void testFillingEmpty() {
- final JsonObject json = new JsonObject();
- var result = MessageSendTester.fillWithPayload(json, 1024);
- assertEquals(1024, result.length());
- }
-
- @Test
- public void testFillUtf8() {
- final JsonObject json = new JsonObject();
- json.put("some-utf-8", "\u1F926");
- var result = MessageSendTester.fillWithPayload(json, 1024);
- assertEquals(1024, result.length());
- }
-
- @Test
- public void testFillingNonEmpty() {
-
- final int fixedLength = "{\"init\":\"\"}".getBytes(StandardCharsets.UTF_8).length;
-
- for (int initialLength = fixedLength; initialLength < 1024; initialLength++) {
-
- final char init[] = new char[initialLength - fixedLength];
- Arrays.fill(init, 'b');
- final String initValue = String.valueOf(init);
-
- for (int expectedLength = initialLength + MessageSendTester.FIXED_JSON_EXTRA_SIZE + 1; expectedLength < 1024; expectedLength++) {
-
- final JsonObject json = new JsonObject();
- json.put("init", initValue);
-
- var result = MessageSendTester.fillWithPayload(json, expectedLength);
- assertEquals(expectedLength, result.length());
-
- }
-
- }
-
- }
-
-}
diff --git a/systemtests/src/test/java/io/enmasse/systemtest/iot/StandardIoTTests.java b/systemtests/src/test/java/io/enmasse/systemtest/iot/StandardIoTTests.java
deleted file mode 100644
index 277a841e8e9..00000000000
--- a/systemtests/src/test/java/io/enmasse/systemtest/iot/StandardIoTTests.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2020, EnMasse authors.
- * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
- */
-
-package io.enmasse.systemtest.iot;
-
-import java.util.List;
-
-public interface StandardIoTTests extends IoTTests {
-
- /**
- * Test the test session.
- */
- public IoTTestSession getSession();
-
- /**
- * Get a list of devices which must succeed.
- */
- public List getDevices();
-
- /**
- * Get a list of devices which must fail.
- */
- public List getInvalidDevices();
-
-}
diff --git a/systemtests/src/test/java/io/enmasse/systemtest/iot/http/StandardIoTHttpTests.java b/systemtests/src/test/java/io/enmasse/systemtest/iot/http/StandardIoTHttpTests.java
deleted file mode 100644
index 6796c8ad454..00000000000
--- a/systemtests/src/test/java/io/enmasse/systemtest/iot/http/StandardIoTHttpTests.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright 2020, EnMasse authors.
- * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
- */
-
-package io.enmasse.systemtest.iot.http;
-
-import static io.enmasse.systemtest.TestTag.ACCEPTANCE;
-import static io.enmasse.systemtest.iot.HttpAdapterClient.causedBy;
-import static io.enmasse.systemtest.iot.HttpAdapterClient.ResponseException.statusCode;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-import java.time.Duration;
-import java.util.concurrent.TimeoutException;
-
-import javax.net.ssl.SSLHandshakeException;
-
-import org.junit.jupiter.api.Tag;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.MethodSource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import io.enmasse.systemtest.iot.DeviceSupplier;
-import io.enmasse.systemtest.iot.HttpAdapterClient;
-import io.enmasse.systemtest.iot.MessageSendTester;
-import io.enmasse.systemtest.iot.MessageSendTester.ConsumerFactory;
-import io.enmasse.systemtest.iot.StandardIoTTests;
-
-public interface StandardIoTHttpTests extends StandardIoTTests {
-
- static final Logger log = LoggerFactory.getLogger(StandardIoTHttpTests.class);
-
- /**
- * Single telemetry message with attached consumer.
- */
- @Tag(ACCEPTANCE)
- @ParameterizedTest(name = "testHttpTelemetrySingle-{0}")
- @MethodSource("getDevices")
- default void testHttpTelemetrySingle(final DeviceSupplier device) throws Exception {
-
- try (HttpAdapterClient client = device.get().createHttpAdapterClient()) {
- new MessageSendTester()
- .type(MessageSendTester.Type.TELEMETRY)
- .delay(Duration.ofSeconds(1))
- .consumerFactory(ConsumerFactory.of(getSession().getConsumerClient(), getSession().getTenantId()))
- .sender(client::send)
- .amount(1)
- .consume(MessageSendTester.Consume.BEFORE)
- .execute();
- }
-
- }
-
- /**
- * Test a single event message.
- *
- * Send a single message, no consumer attached. The message gets delivered
- * when the consumer attaches.
- */
- @ParameterizedTest(name = "testHttpEventSingle-{0}")
- @MethodSource("getDevices")
- default void testHttpEventSingle(final DeviceSupplier device) throws Exception {
-
- try (HttpAdapterClient client = device.get().createHttpAdapterClient()) {
- new MessageSendTester()
- .type(MessageSendTester.Type.EVENT)
- .delay(Duration.ofSeconds(1))
- .consumerFactory(ConsumerFactory.of(getSession().getConsumerClient(), getSession().getTenantId()))
- .sender(client::send)
- .amount(1)
- .consume(MessageSendTester.Consume.AFTER)
- .execute();
- }
-
- }
-
- /**
- * Test a batch of telemetry messages, consumer is started before sending.
- *
- * This is the normal telemetry case.
- */
- @ParameterizedTest(name = "testHttpTelemetryBatch50-{0}")
- @MethodSource("getDevices")
- default void testHttpTelemetryBatch50(final DeviceSupplier device) throws Exception {
-
- try (HttpAdapterClient client = device.get().createHttpAdapterClient()) {
- new MessageSendTester()
- .type(MessageSendTester.Type.TELEMETRY)
- .delay(Duration.ofSeconds(1))
- .consumerFactory(ConsumerFactory.of(getSession().getConsumerClient(), getSession().getTenantId()))
- .sender(client::send)
- .amount(50)
- .consume(MessageSendTester.Consume.BEFORE)
- .execute();
- }
-
- }
-
- /**
- * Test a batch of events, having no consumer attached.
- *
- * As events get buffered by the broker, there is no requirement to start
- * a consumer before sending the messages. However when the consumer is
- * attached, it should receive those messages.
- */
- @ParameterizedTest(name = "testHttpEventBatch5After-{0}")
- @MethodSource("getDevices")
- default void testHttpEventBatch5After(final DeviceSupplier device) throws Exception {
-
- try (HttpAdapterClient client = device.get().createHttpAdapterClient()) {
- new MessageSendTester()
- .type(MessageSendTester.Type.EVENT)
- .delay(Duration.ofMillis(100))
- .additionalSendTimeout(Duration.ofSeconds(10))
- .consumerFactory(ConsumerFactory.of(getSession().getConsumerClient(), getSession().getTenantId()))
- .sender(client::send)
- .amount(5)
- .consume(MessageSendTester.Consume.AFTER)
- .execute();
- }
-
- }
-
- /**
- * Test a batch of events, starting the consumer before sending.
- *
- * This is the default use case with events, and should simply work
- * as with telemetry.
- */
- @ParameterizedTest(name = "testHttpEventBatch5Before-{0}")
- @MethodSource("getDevices")
- default void testHttpEventBatch5Before(final DeviceSupplier device) throws Exception {
-
- try (HttpAdapterClient client = device.get().createHttpAdapterClient()) {
- new MessageSendTester()
- .type(MessageSendTester.Type.EVENT)
- .delay(Duration.ZERO)
- .additionalSendTimeout(Duration.ofSeconds(10))
- .consumerFactory(ConsumerFactory.of(getSession().getConsumerClient(), getSession().getTenantId()))
- .sender(client::send)
- .amount(5)
- .consume(MessageSendTester.Consume.BEFORE)
- .execute();
- }
-
- }
-
- /**
- * Test for an invalid device.
- *
- * With an invalid device, no messages must pass.
- */
- @ParameterizedTest(name = "testHttpDeviceFails-{0}")
- @MethodSource("getInvalidDevices")
- default void testHttpDeviceFails(final DeviceSupplier deviceSupplier) throws Exception {
-
- log.info("Testing invalid devices, the following exception may be expected");
- var device = deviceSupplier.get();
-
- /*
- * We test an invalid device by trying to send either telemetry or event messages.
- * Two separate connections, and more than one message.
- */
-
- try (HttpAdapterClient client = device.createHttpAdapterClient()) {
- client.suppressExceptions(
- statusCode(401)
- .or(causedBy(SSLHandshakeException.class)));
- assertThrows(TimeoutException.class, () -> {
- new MessageSendTester()
- .type(MessageSendTester.Type.TELEMETRY)
- .delay(Duration.ofSeconds(1))
- .consumerFactory(ConsumerFactory.of(getSession().getConsumerClient(), getSession().getTenantId()))
- .sender(client::send)
- .amount(5)
- .consume(MessageSendTester.Consume.BEFORE)
- .execute();
- });
- }
-
- try (HttpAdapterClient client = device.createHttpAdapterClient()) {
- client.suppressExceptions(
- statusCode(401)
- .or(causedBy(SSLHandshakeException.class)));
- assertThrows(TimeoutException.class, () -> {
- new MessageSendTester()
- .type(MessageSendTester.Type.EVENT)
- .delay(Duration.ofSeconds(1))
- .consumerFactory(ConsumerFactory.of(getSession().getConsumerClient(), getSession().getTenantId()))
- .sender(client::send)
- .amount(5)
- .consume(MessageSendTester.Consume.BEFORE)
- .execute();
- });
- }
-
- }
-}
diff --git a/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/AbstractMaxPayloadSizeTest.java b/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/AbstractMaxPayloadSizeTest.java
deleted file mode 100644
index f54a937838f..00000000000
--- a/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/AbstractMaxPayloadSizeTest.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright 2020, EnMasse authors.
- * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
- */
-
-package io.enmasse.systemtest.iot.isolated;
-
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-import java.time.Duration;
-import java.util.concurrent.TimeoutException;
-
-import org.junit.jupiter.api.Test;
-
-import io.enmasse.systemtest.bases.TestBase;
-import io.enmasse.systemtest.bases.iot.ITestIoTIsolated;
-import io.enmasse.systemtest.iot.IoTTestSession;
-import io.enmasse.systemtest.iot.IoTTestSession.Adapter;
-import io.enmasse.systemtest.iot.IoTTestSession.Device;
-import io.enmasse.systemtest.iot.MessageSendTester;
-import io.enmasse.systemtest.iot.MessageSendTester.ConsumerFactory;
-import io.enmasse.systemtest.iot.MessageSendTester.Sender;
-import io.enmasse.systemtest.iot.MessageSendTester.Type;
-
-public abstract class AbstractMaxPayloadSizeTest extends TestBase implements ITestIoTIsolated {
-
- protected abstract Adapter adapter();
-
- protected abstract Sender sender(Device device) throws Exception;
-
- /**
- * Reduce the payload by this amount of bytes.
- *
- * This is required by e.g. the MQTT protocol, as the topic name counts against the total length of
- * the MQTT payload.
- *
- * @param type the type to send.
- *
- * @return The number of bytes to remove from the payload.
- */
- protected int reducePayloadBy(final Type type) {
- return 0;
- }
-
- @Test
- public void testDecreasedMaxPayloadDefault() throws Exception {
-
- IoTTestSession
- .createDefault()
- .adapters(adapter())
- .config(config -> config
- .editOrNewSpec()
- .editOrNewAdapters()
- .editOrNewDefaults()
- .withMaxPayloadSize(256)
- .endDefaults()
- .endAdapters()
- .endSpec())
- .run(session -> {
-
- var device = session
- .newDevice("4711")
- .register()
- .setPassword("auth-1", "123456");
-
- // we expect the sending to fail, due to timeouts, as the payload exceeds the maximum
-
- assertThrows(TimeoutException.class, () -> {
- new MessageSendTester()
- .type(MessageSendTester.Type.TELEMETRY)
- .payloadSize(1024 - reducePayloadBy(MessageSendTester.Type.TELEMETRY))
- .delay(Duration.ofSeconds(1))
- .consumerFactory(ConsumerFactory.of(session.getConsumerClient(), session.getTenantId()))
- .sender(sender(device))
- .amount(50)
- .consume(MessageSendTester.Consume.BEFORE)
- .execute();
- });
-
- });
-
- }
-
- @Test
- public void testIncreasedMaxPayloadDefault() throws Exception {
-
- IoTTestSession
- .createDefault()
- .adapters(adapter())
- .config(config -> config
- .editOrNewSpec()
- .editOrNewAdapters()
- .editOrNewDefaults()
- .withMaxPayloadSize(16 * 1024)
- .endDefaults()
- .endAdapters()
- .endSpec())
- .run(session -> {
-
- var device = session
- .newDevice("4711")
- .register()
- .setPassword("auth-1", "123456");
-
- new MessageSendTester()
- .type(MessageSendTester.Type.TELEMETRY)
- .payloadSize((16 * 1024) - reducePayloadBy(MessageSendTester.Type.TELEMETRY))
- .delay(Duration.ofSeconds(1))
- .consumerFactory(ConsumerFactory.of(session.getConsumerClient(), session.getTenantId()))
- .sender(sender(device))
- .amount(50)
- .consume(MessageSendTester.Consume.BEFORE)
- .execute();
- });
-
- }
-
- @Test
- public void testStandardMaxPayloadDefault() throws Exception {
-
- IoTTestSession
- .createDefault()
- .adapters(adapter())
- .run(session -> {
-
- var device = session
- .newDevice("4711")
- .register()
- .setPassword("auth-1", "123456");
-
- new MessageSendTester()
- .type(MessageSendTester.Type.TELEMETRY)
- .payloadSize(1024 - reducePayloadBy(MessageSendTester.Type.TELEMETRY))
- .delay(Duration.ofSeconds(1))
- .consumerFactory(ConsumerFactory.of(session.getConsumerClient(), session.getTenantId()))
- .sender(sender(device))
- .amount(50)
- .consume(MessageSendTester.Consume.BEFORE)
- .execute();
- });
-
- }
-
-}
diff --git a/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/IoTProjectManagedTest.java b/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/IoTProjectManagedTest.java
deleted file mode 100644
index 8cdc076141a..00000000000
--- a/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/IoTProjectManagedTest.java
+++ /dev/null
@@ -1,421 +0,0 @@
-/*
- * Copyright 2018-2020, EnMasse authors.
- * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
- */
-package io.enmasse.systemtest.iot.isolated;
-
-import static io.enmasse.systemtest.TestTag.ACCEPTANCE;
-import static io.enmasse.systemtest.TestTag.SMOKE;
-import static io.enmasse.systemtest.iot.DefaultDeviceRegistry.newDefaultInstance;
-import static io.enmasse.systemtest.time.TimeoutBudget.ofDuration;
-import static io.enmasse.user.model.v1.Operation.recv;
-import static io.enmasse.user.model.v1.Operation.send;
-import static java.time.Duration.ofMinutes;
-import static java.util.Arrays.asList;
-import static java.util.EnumSet.of;
-import static java.util.Optional.ofNullable;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.beans.HasPropertyWithValue.hasProperty;
-import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
-import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
-import static org.hamcrest.core.AllOf.allOf;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.time.Duration;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import org.hamcrest.Matcher;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Tag;
-import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-
-import io.enmasse.address.model.Address;
-import io.enmasse.address.model.AddressSpace;
-import io.enmasse.address.model.AddressSpaceStatus;
-import io.enmasse.address.model.AddressStatus;
-import io.enmasse.address.model.KubeUtil;
-import io.enmasse.address.model.Phase;
-import io.enmasse.iot.model.v1.DoneableIoTProject;
-import io.enmasse.iot.model.v1.IoTProject;
-import io.enmasse.iot.model.v1.IoTProjectList;
-import io.enmasse.systemtest.bases.TestBase;
-import io.enmasse.systemtest.bases.iot.ITestIoTIsolated;
-import io.enmasse.systemtest.iot.IoTTestSession;
-import io.enmasse.systemtest.logs.CustomLogger;
-import io.enmasse.systemtest.model.address.AddressType;
-import io.enmasse.systemtest.model.addressplan.DestinationPlan;
-import io.enmasse.systemtest.model.addressspace.AddressSpacePlans;
-import io.enmasse.systemtest.model.addressspace.AddressSpaceType;
-import io.enmasse.systemtest.platform.Kubernetes;
-import io.enmasse.systemtest.time.TimeoutBudget;
-import io.enmasse.systemtest.utils.AddressUtils;
-import io.enmasse.systemtest.utils.IoTUtils;
-import io.enmasse.systemtest.utils.TestUtils;
-import io.enmasse.user.model.v1.Operation;
-import io.enmasse.user.model.v1.User;
-import io.enmasse.user.model.v1.UserAuthorization;
-import io.enmasse.user.model.v1.UserStatus;
-import io.fabric8.kubernetes.api.model.Doneable;
-import io.fabric8.kubernetes.api.model.HasMetadata;
-import io.fabric8.kubernetes.api.model.ObjectMeta;
-import io.fabric8.kubernetes.api.model.OwnerReference;
-import io.fabric8.kubernetes.client.dsl.MixedOperation;
-import io.fabric8.kubernetes.client.dsl.Resource;
-
-class IoTProjectManagedTest extends TestBase implements ITestIoTIsolated {
- private final static Logger log = CustomLogger.getLogger();
-
- @FunctionalInterface
- interface ProjectModificator {
- /**
- * Modify a project
- *
- * @param timeout The timeout budget the operation has available.
- * @param project The project to work with. It is an provisioned project, which already passed a
- * call to {@link IoTProjectManagedTest#assertManaged(IoTProject)}.
- * @return {@code true} if the state has been change and a final call to
- * {@link IoTProjectManagedTest#assertManaged(IoTProject)} to be performed.
- */
- boolean modify(TimeoutBudget timeout, IoTProject project) throws Exception;
- }
-
- private Kubernetes kubernetes = Kubernetes.getInstance();
-
- private MixedOperation> projectClient;
-
- @BeforeEach
- void createIoTClient() {
- this.projectClient = this.kubernetes.getIoTProjectClient(IOT_PROJECT_NAMESPACE);
- }
-
- /**
- * Simply create a project and directly test it.
- */
- @Test
- @Tag(SMOKE)
- @Tag(ACCEPTANCE)
- void testCreate() throws Exception {
- // run a default test, with no modifications
- doTestAddressSpaceWithModifications(ofDuration(ofMinutes(5)), (timeout, project) -> false);
- }
-
- /**
- * Delete a resource and wait for it to be re-created properly.
- *
- * @param The resource type.
- * @param The list type of the resource.
- * @param The {@link Doneable} type.
- * @param project The IoT project to process.
- * @param clazz The class instance of the resource type.
- * @param name The kubernetes name of the resource.
- * @param basicClient The basic resource client. Does not need to be namespaced.
- * @param phaseExtractor The function which extracts the phase information.
- */
- ProjectModificator deleteAndWaitResource(final Class clazz, final Function nameExtractor,
- final MixedOperation> basicClient, final Function> phaseExtractor) {
-
- return (timeout, project) -> {
-
- final var name = nameExtractor.apply(project);
- final var className = clazz.getSimpleName();
- final var client = basicClient.inNamespace(IOT_PROJECT_NAMESPACE);
-
- // get the current address space
-
- final var namedClient = client.withName(name);
- final var currentResource = namedClient.get();
- assertNotNull(currentResource, () -> String.format("Unable to find resource - type: %s, name: '%s'", className, name));
-
- // remember its ID
-
- final String originalId = currentResource.getMetadata().getUid();
- assertNotNull(originalId);
-
- // delete it
-
- client.withName(name).delete();
-
- // now wait for it to be re-created
-
- TestUtils.waitUntilConditionOrFail(() -> {
-
- var current = namedClient.get();
- if (current == null) {
- log.info("{} is still missing", className);
- return false;
- }
- if (originalId.equals(current.getMetadata().getUid())) {
- log.info("{} has still the same ID", className);
- // still the same object
- return false;
- }
-
- // get current phase
- final var phase = phaseExtractor.apply(current);
- if (!phase.isPresent()) {
- log.info("{} no phase information", className);
- return false;
- }
-
- if (phase.get() != Phase.Active) {
- log.info("{} is not ready yet: {}", className, phase.get());
- return false;
- }
-
- return true;
- }, timeout.remaining(), Duration.ofSeconds(10), () -> className + " did not get re-created");
-
- // and wait for the IoT project to become ready again
-
- var projectAccess = kubernetes.getIoTProjectClient(project.getMetadata().getNamespace()).withName(project.getMetadata().getName());
- TestUtils.waitUntilConditionOrFail(() -> {
- var current = projectAccess.get();
-
- if (current == null) {
- log.info("IoTProject missing");
- return false;
- }
-
- if (current.getStatus() == null || current.getStatus().getPhase() == null) {
- log.info("IoTProject is missing status information");
- return false;
- }
-
- if (!current.getStatus().getPhase().equals("Active")) {
- return false;
- }
-
- return true;
- }, timeout.remaining(), Duration.ofSeconds(10), () -> "IoTProject failed to switch back to 'Active'");
-
- return true;
- };
- }
-
- /**
- * Test deleting the whole address space.
- */
- @Test
- void testDeleteAddressSpace() throws Exception {
- doTestAddressSpaceWithModifications(
- ofDuration(ofMinutes(15)),
- deleteAndWaitResource(
- AddressSpace.class,
- project -> project.getSpec().getDownstreamStrategy().getManagedStrategy().getAddressSpace().getName(),
- kubernetes.getAddressSpaceClient(),
- addressSpace -> ofNullable(addressSpace).map(AddressSpace::getStatus).map(AddressSpaceStatus::getPhase)));
- }
-
- /**
- * Test deleting the telememtry address.
- */
- @Test
- void testDeleteTelemetryAddress() throws Exception {
- doTestAddressSpaceWithModifications(
- ofDuration(ofMinutes(10)),
- deleteAndWaitResource(
- Address.class,
- project -> KubeUtil.sanitizeForGo(
- project.getSpec().getDownstreamStrategy().getManagedStrategy().getAddressSpace().getName(),
- "telemetry/" + project.getStatus().getTenantName()),
- kubernetes.getAddressClient(),
- address -> ofNullable(address).map(Address::getStatus).map(AddressStatus::getPhase)));
- }
-
- /**
- * Test deleting the event address.
- *
- * The event address is expected to be backed by a brokered address. Thus is might behave
- * differently than the others.
- */
- @Test
- void testDeleteEventAddress() throws Exception {
- doTestAddressSpaceWithModifications(
- ofDuration(ofMinutes(15)),
- deleteAndWaitResource(
- Address.class,
- project -> KubeUtil.sanitizeForGo(
- project.getSpec().getDownstreamStrategy().getManagedStrategy().getAddressSpace().getName(),
- "event/" + project.getStatus().getTenantName()),
- kubernetes.getAddressClient(),
- address -> ofNullable(address).map(Address::getStatus).map(AddressStatus::getPhase)));
- }
-
- /**
- * Test deleting the adapter user.
- */
- @Test
- void testDeleteAdapterUser() throws Exception {
- doTestAddressSpaceWithModifications(
- ofDuration(ofMinutes(10)),
- deleteAndWaitResource(
- User.class,
- project -> project.getSpec().getDownstreamStrategy().getManagedStrategy().getAddressSpace().getName()
- + "."
- + project.getStatus().getDownstreamEndpoint().getUsername(),
- kubernetes.getUserClient(),
- user -> ofNullable(user).map(User::getStatus).map(UserStatus::getPhase)));
- }
-
- void doTestAddressSpaceWithModifications(final TimeoutBudget timeout, final ProjectModificator modificator) throws Exception {
-
- isolatedIoTManager.createIoTConfig(IoTTestSession.createDefaultConfig()
- .editOrNewSpec().withServices(newDefaultInstance()).endSpec()
- .build());
-
- final String addressSpaceName = "managed-address-space";
- final String iotProjectName = "iot-project-managed";
-
- IoTProject project = IoTUtils.getBasicIoTProjectObject(iotProjectName, addressSpaceName,
- IOT_PROJECT_NAMESPACE, getDefaultAddressSpacePlan());
- LOGGER.warn("NAMESPACE EXISTS? {}, {}", project.getMetadata().getNamespace(), kubernetes.namespaceExists(project.getMetadata().getNamespace()));
- isolatedIoTManager.createIoTProject(project); // waiting until ready
- IoTProject created = this.projectClient.withName(iotProjectName).get();
-
- assertNotNull(created);
- assertEquals(IOT_PROJECT_NAMESPACE, created.getMetadata().getNamespace());
- assertEquals(project.getMetadata().getName(), created.getMetadata().getName());
- assertEquals(
- project.getSpec().getDownstreamStrategy().getManagedStrategy().getAddressSpace().getName(),
- created.getSpec().getDownstreamStrategy().getManagedStrategy().getAddressSpace().getName());
-
- assertManaged(created);
-
- if (modificator.modify(timeout, created)) {
- created = this.projectClient.withName(iotProjectName).get();
- assertNotNull(created);
- assertManaged(created);
- }
- }
-
- private static void assertAddressType(final Address address, final AddressType type, final String plan) {
- assertEquals(type.toString(), address.getSpec().getType());
- assertEquals(plan, address.getSpec().getPlan());
- }
-
- private void assertManaged(IoTProject project) throws Exception {
- // address spaces
- AddressSpace addressSpace =
- isolatedIoTManager.getAddressSpace(IOT_PROJECT_NAMESPACE, project.getSpec().getDownstreamStrategy().getManagedStrategy().getAddressSpace().getName());
- assertEquals(project.getSpec().getDownstreamStrategy().getManagedStrategy().getAddressSpace().getName(), addressSpace.getMetadata().getName());
- assertEquals(AddressSpaceType.STANDARD.toString(), addressSpace.getSpec().getType());
- assertEquals(AddressSpacePlans.STANDARD_SMALL, addressSpace.getSpec().getPlan());
- assertEquals(Phase.Active, addressSpace.getStatus().getPhase());
-
- // addresses
- // {event/control/command/command_response/telemetry}/"project-namespace"."project-name"
- final String addressSuffix = "/" + project.getMetadata().getNamespace() + "." + project.getMetadata().getName();
- final List addresses = AddressUtils.getAddresses(addressSpace);
- // assert that we have the right number of addresses
- assertEquals(5, addresses.size());
- // assert that all addresses have the project set as owner
- assertEquals(5, addresses.stream()
- .map(Address::getMetadata)
- .map(ObjectMeta::getOwnerReferences)
- .flatMap(List::stream)
- .filter(reference -> isOwner(project, reference))
- .count());
-
- int correctAddressesCounter = 0;
- for (Address address : addresses) {
-
- final String addressName = address.getSpec().getAddress();
-
- if (addressName.equals(IOT_ADDRESS_EVENT + addressSuffix)) {
-
- assertAddressType(address, AddressType.QUEUE, DestinationPlan.STANDARD_SMALL_QUEUE);
- correctAddressesCounter++;
-
- } else if (addressName.equals(IOT_ADDRESS_CONTROL + addressSuffix)
- || addressName.equals(IOT_ADDRESS_TELEMETRY + addressSuffix)
- || addressName.equals(IOT_ADDRESS_COMMAND + addressSuffix)
- || addressName.equals(IOT_ADDRESS_COMMAND_RESPONSE + addressSuffix)) {
-
- assertAddressType(address, AddressType.ANYCAST, DestinationPlan.STANDARD_SMALL_ANYCAST);
- correctAddressesCounter++;
-
- }
-
- assertEquals(Phase.Active, address.getStatus().getPhase());
-
- }
- assertEquals(5, correctAddressesCounter, "There are incorrect IoT addresses " + addresses);
-
- // username "adapter"
- // name "project-address-space"+".adapter"
- User user = isolatedIoTManager.getUser(addressSpace, "adapter-" + project.getMetadata().getUid());
- assertNotNull(user);
- assertEquals(1, user.getMetadata().getOwnerReferences().size());
- assertTrue(isOwner(project, user.getMetadata().getOwnerReferences().get(0)));
-
- final List authorizations = user.getSpec().getAuthorization();
-
- assertThat(authorizations, hasSize(3));
-
- assertThat(authorizations, containsInAnyOrder(
- asList(
- assertAdapterAuthorization(of(send), expandAddresses(addressSuffix, IOT_ADDRESS_TELEMETRY, IOT_ADDRESS_EVENT, IOT_ADDRESS_COMMAND_RESPONSE)),
- assertAdapterAuthorization(of(recv), expandAddresses(addressSuffix, IOT_ADDRESS_COMMAND)),
- assertAdapterAuthorization(of(recv, send), expandAddresses(addressSuffix, IOT_ADDRESS_CONTROL)))));
- }
-
- /**
- * Assert an authorization entry.
- *
- * @param operations The expected operations.
- * @param addresses The expected addresses.
- * @return A matcher, asserting the entry.
- */
- private static Matcher assertAdapterAuthorization(final Set operations, final Set addresses) {
-
- return allOf(asList(
-
- hasProperty("operations", containsInAnyOrder(operations.toArray(Operation[]::new))),
- hasProperty("addresses", containsInAnyOrder(addresses.toArray(String[]::new)))
-
- ));
-
- }
-
- /**
- * Expand addresses to match ACLs.
- *
- * @param addressSuffix The "suffix" (tenant) of the address.
- * @return A set of all addresses.
- */
- private static Set expandAddresses(final String addressSuffix, final String... baseAddresses) {
-
- return Arrays
- .stream(baseAddresses)
- .flatMap(address -> {
- return Stream.of(
- address + addressSuffix,
- address + addressSuffix + "/*");
- })
-
- .collect(Collectors.toSet());
-
- }
-
- /**
- * Test if the project is the owner the reference points to.
- *
- * @param project The project to check for.
- * @param ownerReference The reference to check.
- * @return {@code true} if the reference points to the project.
- */
- private boolean isOwner(final IoTProject project, final OwnerReference ownerReference) {
- return ownerReference.getKind().equals(IoTProject.KIND) &&
- project.getMetadata().getName().equals(ownerReference.getName());
- }
-
-}
diff --git a/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/MultipleProjectsTest.java b/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/MultipleProjectsTest.java
deleted file mode 100644
index bf470525fc2..00000000000
--- a/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/MultipleProjectsTest.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Copyright 2019-2020, EnMasse authors.
- * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
- */
-package io.enmasse.systemtest.iot.isolated;
-
-import static io.enmasse.systemtest.TestTag.ACCEPTANCE;
-import static io.enmasse.systemtest.iot.DefaultDeviceRegistry.newDefaultInstance;
-
-import java.net.HttpURLConnection;
-import java.nio.charset.StandardCharsets;
-import java.time.Duration;
-import java.util.ArrayList;
-import java.util.Base64;
-import java.util.Collections;
-import java.util.List;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-
-import org.eclipse.paho.client.mqttv3.IMqttClient;
-import org.eclipse.paho.client.mqttv3.MqttException;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Tag;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtensionContext;
-import org.slf4j.Logger;
-
-import io.enmasse.address.model.AddressSpace;
-import io.enmasse.iot.model.v1.IoTConfig;
-import io.enmasse.iot.model.v1.IoTProject;
-import io.enmasse.systemtest.Endpoint;
-import io.enmasse.systemtest.TestTag;
-import io.enmasse.systemtest.amqp.AmqpClient;
-import io.enmasse.systemtest.bases.TestBase;
-import io.enmasse.systemtest.bases.iot.ITestIoTIsolated;
-import io.enmasse.systemtest.iot.CredentialsRegistryClient;
-import io.enmasse.systemtest.iot.DeviceRegistryClient;
-import io.enmasse.systemtest.iot.HttpAdapterClient;
-import io.enmasse.systemtest.iot.IoTProjectTestContext;
-import io.enmasse.systemtest.iot.IoTTestSession;
-import io.enmasse.systemtest.iot.MessageSendTester;
-import io.enmasse.systemtest.iot.MessageSendTester.ConsumerFactory;
-import io.enmasse.systemtest.logs.CustomLogger;
-import io.enmasse.systemtest.mqtt.MqttClientFactory;
-import io.enmasse.systemtest.time.TimeoutBudget;
-import io.enmasse.systemtest.time.WaitPhase;
-import io.enmasse.systemtest.utils.IoTUtils;
-import io.enmasse.systemtest.utils.TestUtils;
-import io.enmasse.user.model.v1.Operation;
-import io.enmasse.user.model.v1.User;
-import io.enmasse.user.model.v1.UserAuthenticationType;
-import io.enmasse.user.model.v1.UserAuthorizationBuilder;
-import io.enmasse.user.model.v1.UserBuilder;
-
-@Tag(TestTag.SMOKE)
-class MultipleProjectsTest extends TestBase implements ITestIoTIsolated {
- private static Logger log = CustomLogger.getLogger();
- private DeviceRegistryClient registryClient;
- private CredentialsRegistryClient credentialsClient;
-
- private int numberOfProjects = 2;
- private List projects = new ArrayList<>();
-
- @BeforeEach
- void initEnv() throws Exception {
- IoTConfig iotConfig = IoTTestSession.createDefaultConfig()
- .editOrNewSpec().withServices(newDefaultInstance()).endSpec()
- .build();
- isolatedIoTManager.createIoTConfig(iotConfig);
-
- Endpoint deviceRegistryEndpoint = IoTUtils.getDeviceRegistryManagementEndpoint();
- registryClient = new DeviceRegistryClient(deviceRegistryEndpoint);
- credentialsClient = new CredentialsRegistryClient(deviceRegistryEndpoint);
-
- for (int i = 1; i <= numberOfProjects; i++) {
- String projectName = String.format("project-%s", i);
-
- kubernetes.createNamespace(projectName);
-
- IoTProject project = IoTUtils.getBasicIoTProjectObject(projectName, projectName,
- projectName, getDefaultAddressSpacePlan());
- isolatedIoTManager.createIoTProject(project);
- IoTProjectTestContext ctx = new IoTProjectTestContext(projectName, project);
-
- configureDeviceSide(ctx);
-
- configureAmqpSide(ctx);
-
- projects.add(ctx);
- }
- }
-
- @AfterEach
- void cleanEnv(ExtensionContext context) throws Exception {
- for (IoTProjectTestContext ctx : projects) {
- cleanDeviceSide(ctx);
- cleanAmqpSide(ctx);
- }
- }
-
- @Test
- @Tag(ACCEPTANCE)
- void testMultipleProjects() throws Exception {
-
- for (final IoTProjectTestContext ctx : projects) {
- try (var http = ctx.getHttpAdapterClient()) {
- new MessageSendTester()
- .type(MessageSendTester.Type.TELEMETRY)
- .delay(Duration.ofSeconds(1))
- .consumerFactory(ConsumerFactory.of(ctx.getAmqpClient(), IoTUtils.getTenantId(ctx.getProject())))
- .sender(http::send)
- .amount(50)
- .consume(MessageSendTester.Consume.BEFORE)
- .execute();
-
- new MessageSendTester()
- .type(MessageSendTester.Type.EVENT)
- .delay(Duration.ofMillis(100))
- .consumerFactory(ConsumerFactory.of(ctx.getAmqpClient(), IoTUtils.getTenantId(ctx.getProject())))
- .sender(http::send)
- .amount(5)
- .consume(MessageSendTester.Consume.AFTER)
- .execute();
- }
- }
-
- }
-
- private void configureAmqpSide(IoTProjectTestContext ctx) throws Exception {
- AddressSpace addressSpace = isolatedIoTManager.getAddressSpace(ctx.getNamespace(),
- ctx.getProject().getSpec().getDownstreamStrategy().getManagedStrategy().getAddressSpace().getName());
- User amqpUser = configureAmqpUser(ctx.getProject(), addressSpace);
- ctx.setAmqpUser(amqpUser);
- AmqpClient amqpClient = configureAmqpClient(addressSpace, amqpUser);
- ctx.setAmqpClient(amqpClient);
- }
-
- private User configureAmqpUser(IoTProject project, AddressSpace addressSpace) {
- String tenant = IoTUtils.getTenantId(project);
-
- User amqpUser = new UserBuilder()
-
- .withNewMetadata()
- .withName(String.format("%s.%s", addressSpace.getMetadata().getName(), project.getMetadata().getName()))
- .endMetadata()
-
- .withNewSpec()
- .withUsername(UUID.randomUUID().toString())
- .withNewAuthentication()
- .withPassword(Base64.getEncoder().encodeToString(UUID.randomUUID().toString().getBytes(StandardCharsets.UTF_8)))
- .withType(UserAuthenticationType.password)
- .endAuthentication()
- .withAuthorization(Collections.singletonList(new UserAuthorizationBuilder()
- .withAddresses(IOT_ADDRESS_TELEMETRY + "/" + tenant,
- IOT_ADDRESS_TELEMETRY + "/" + tenant + "/*",
- IOT_ADDRESS_EVENT + "/" + tenant,
- IOT_ADDRESS_EVENT + "/" + tenant + "/*")
- .withOperations(Operation.recv)
- .build()))
- .endSpec()
- .build();
- kubernetes.getUserClient(project.getMetadata().getNamespace()).create(amqpUser);
-
- return amqpUser;
- }
-
- private AmqpClient configureAmqpClient(AddressSpace addressSpace, User user) throws Exception {
- LOGGER.warn("Amqp factory: " + getAmqpClientFactory());
- AmqpClient amqpClient = getAmqpClientFactory().createQueueClient(addressSpace);
- amqpClient.getConnectOptions()
- .setUsername(user.getSpec().getUsername())
- .setPassword(new String(Base64.getDecoder().decode(user.getSpec().getAuthentication().getPassword())));
- return amqpClient;
- }
-
- private void cleanAmqpSide(IoTProjectTestContext ctx) throws Exception {
- ctx.getAmqpClient().close();
- var userClient = kubernetes.getUserClient(ctx.getNamespace());
- userClient.withName(ctx.getAmqpUser().getMetadata().getName()).cascading(true).delete();
- }
-
- private void configureDeviceSide(IoTProjectTestContext ctx) throws Exception {
- String tenant = IoTUtils.getTenantId(ctx.getProject());
- ctx.setDeviceId(UUID.randomUUID().toString());
- ctx.setDeviceAuthId(UUID.randomUUID().toString());
- ctx.setDevicePassword(UUID.randomUUID().toString());
- registryClient.registerDevice(tenant, ctx.getDeviceId());
- credentialsClient.addCredentials(tenant, ctx.getDeviceId(), ctx.getDeviceAuthId(), ctx.getDevicePassword(), null, HttpURLConnection.HTTP_NO_CONTENT);
- Endpoint httpAdapterEndpoint = kubernetes.getExternalEndpoint("iot-http-adapter");
- ctx.setHttpAdapterClient(new HttpAdapterClient(httpAdapterEndpoint, ctx.getDeviceAuthId(), tenant, ctx.getDevicePassword()));
- IMqttClient mqttAdapterClient = new MqttClientFactory.Builder()
- .clientId(ctx.getDeviceId())
- .endpoint(kubernetes.getExternalEndpoint("iot-mqtt-adapter"))
- .usernameAndPassword(ctx.getDeviceAuthId() + "@" + tenant, ctx.getDevicePassword())
- .mqttConnectionOptions(options -> {
- options.setAutomaticReconnect(true);
- options.setConnectionTimeout(60);
- options.setHttpsHostnameVerificationEnabled(false);
- })
- .create();
- TestUtils.waitUntilCondition("Successfully connect to mqtt adapter", phase -> {
- try {
- mqttAdapterClient.connect();
- return true;
- } catch (MqttException mqttException) {
- if (phase == WaitPhase.LAST_TRY) {
- log.error("Error waiting to connect mqtt adapter", mqttException);
- }
- return false;
- }
- }, new TimeoutBudget(1, TimeUnit.MINUTES));
- log.info("Connection to mqtt adapter succeeded");
- ctx.setMqttAdapterClient(mqttAdapterClient);
- }
-
- private void cleanDeviceSide(IoTProjectTestContext ctx) throws Exception {
- String tenant = IoTUtils.getTenantId(ctx.getProject());
- String deviceId = ctx.getDeviceId();
- credentialsClient.deleteAllCredentials(tenant, deviceId);
- registryClient.deleteDeviceRegistration(tenant, deviceId);
- registryClient.getDeviceRegistration(tenant, deviceId, HttpURLConnection.HTTP_NOT_FOUND);
- ctx.getHttpAdapterClient().close();
- ctx.getMqttAdapterClient().close();
- }
-
-}
diff --git a/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/SimpleK8sDeployTest.java b/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/SimpleK8sDeployTest.java
deleted file mode 100644
index 0dcbe0bab1b..00000000000
--- a/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/SimpleK8sDeployTest.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright 2019-2020, EnMasse authors.
- * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
- */
-
-package io.enmasse.systemtest.iot.isolated;
-
-import static io.enmasse.systemtest.TestTag.SMOKE;
-import static io.enmasse.systemtest.time.TimeoutBudget.ofDuration;
-import static java.time.Duration.ofMinutes;
-import static java.util.Collections.singletonMap;
-
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Tag;
-import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import io.enmasse.iot.model.v1.CommonAdapterContainersBuilder;
-import io.enmasse.iot.model.v1.ContainerConfigBuilder;
-import io.enmasse.iot.model.v1.IoTConfig;
-import io.enmasse.iot.model.v1.JavaContainerConfigBuilder;
-import io.enmasse.systemtest.Environment;
-import io.enmasse.systemtest.bases.TestBase;
-import io.enmasse.systemtest.bases.iot.ITestIoTIsolated;
-import io.enmasse.systemtest.condition.Kubernetes;
-import io.enmasse.systemtest.iot.DefaultDeviceRegistry;
-import io.enmasse.systemtest.iot.IoTTestSession;
-import io.enmasse.systemtest.platform.KubeCMDClient;
-import io.enmasse.systemtest.platform.apps.SystemtestsKubernetesApps;
-import io.enmasse.systemtest.utils.IoTUtils;
-import io.enmasse.systemtest.utils.TestUtils;
-import io.fabric8.kubernetes.api.model.Quantity;
-
-@Tag(SMOKE)
-@Kubernetes
-class SimpleK8sDeployTest extends TestBase implements ITestIoTIsolated {
-
- private static final Logger log = LoggerFactory.getLogger(SimpleK8sDeployTest.class);
- private static final String NAMESPACE = Environment.getInstance().namespace();
- private static IoTConfig config;
- private io.enmasse.systemtest.platform.Kubernetes client = io.enmasse.systemtest.platform.Kubernetes.getInstance();
-
- @BeforeAll
- static void setup() throws Exception {
- Map secrets = new HashMap<>();
- secrets.put("iot-auth-service", "systemtests-iot-auth-service-tls");
- secrets.put("iot-tenant-service", "systemtests-iot-tenant-service-tls");
- secrets.put("iot-device-connection", "systemtests-iot-device-connection-tls");
- secrets.put("iot-device-registry", "systemtests-iot-device-registry-tls");
-
- var r1 = new ContainerConfigBuilder()
- .withNewResources().addToLimits("memory", new Quantity("64Mi")).endResources()
- .build();
- var j2 = new JavaContainerConfigBuilder()
- .withNewContainerConfig()
- .withNewResources().addToLimits("memory", new Quantity("256Mi")).endResources()
- .endContainerConfig()
- .build();
-
- var commonContainers = new CommonAdapterContainersBuilder()
- .withNewAdapterLike(j2).endAdapter()
- .withNewProxyLike(r1).endProxy()
- .withNewProxyConfiguratorLike(r1).endProxyConfigurator()
- .build();
-
- var jdbcEndpoint = SystemtestsKubernetesApps.deployPostgresqlServer();
-
- config = IoTTestSession.createDefaultConfig()
-
- .editOrNewSpec()
-
- .editOrNewAdapters()
-
- .editOrNewHttp()
- .withNewContainersLike(commonContainers).endContainers()
- .endHttp()
-
- .editOrNewMqtt()
- .withNewContainersLike(commonContainers).endContainers()
- .endMqtt()
-
- .editOrNewSigfox()
- .withNewContainersLike(commonContainers).endContainers()
- .endSigfox()
-
- .editOrNewLoraWan()
- .withNewContainersLike(commonContainers).endContainers()
- .endLoraWan()
-
- .endAdapters()
-
- .withNewServices()
-
- .withNewAuthentication()
- .withNewContainerLike(j2).endContainer()
- .endAuthentication()
-
- .withNewTenant()
- .withNewContainerLike(j2).endContainer()
- .endTenant()
-
- .withDeviceConnection(DefaultDeviceRegistry.newPostgresBasedConnection(jdbcEndpoint))
- .withDeviceRegistry(DefaultDeviceRegistry.newPostgresBasedRegistry(jdbcEndpoint, false))
-
- .editDeviceConnection()
- .editJdbc()
- .editOrNewCommonServiceConfig()
- .withNewContainerLike(j2).endContainer()
- .endCommonServiceConfig()
- .endJdbc()
- .endDeviceConnection()
-
- .editDeviceRegistry()
- .editJdbc()
- .editServer()
- .editExternal()
- .editManagement()
- .editOrNewCommonConfig()
- .withNewContainerLike(j2).endContainer()
- .endCommonConfig()
- .endManagement()
- .endExternal()
- .endServer()
- .endJdbc()
- .endDeviceRegistry()
-
- .endServices()
-
- .endSpec()
- .build();
-
- final Path configTempFile = Files.createTempFile("iot-config", "json");
- try {
- Files.write(configTempFile, new ObjectMapper().writeValueAsBytes(config));
- KubeCMDClient.createFromFile(NAMESPACE, configTempFile);
- } finally {
- Files.deleteIfExists(configTempFile);
- }
- }
-
- @AfterAll
- static void cleanup() throws Exception {
- KubeCMDClient.deleteIoTConfig(NAMESPACE, "default");
- log.info("Waiting for IoT components to be removed");
- TestUtils.waitForNReplicas(0, NAMESPACE, singletonMap("component", "iot"), ofDuration(ofMinutes(5)));
- }
-
- @Test
- void testDeploy() throws Exception {
- IoTUtils.waitForIoTConfigReady(client, config);
- }
-
-}
diff --git a/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/http/HttpAdapterTest.java b/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/http/HttpAdapterTest.java
deleted file mode 100644
index ee4098122a3..00000000000
--- a/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/http/HttpAdapterTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2019-2020, EnMasse authors.
- * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
- */
-
-package io.enmasse.systemtest.iot.isolated.http;
-
-import static io.enmasse.systemtest.TestTag.ISOLATED_IOT;
-import static io.enmasse.systemtest.iot.DeviceSupplier.named;
-import static io.enmasse.systemtest.iot.IoTTestSession.Adapter.HTTP;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Tag;
-
-import io.enmasse.systemtest.iot.DeviceSupplier;
-import io.enmasse.systemtest.iot.IoTTestSession;
-import io.enmasse.systemtest.iot.http.StandardIoTHttpTests;
-
-@Tag(ISOLATED_IOT)
-class HttpAdapterTest implements StandardIoTHttpTests {
-
- private static IoTTestSession session;
-
- @BeforeAll
- public static void setup() throws Exception {
- session = IoTTestSession.createDefault()
- .adapters(HTTP)
- .deploy();
- }
-
- @AfterAll
- public static void cleanup() throws Exception {
- if (session != null) {
- session.close();
- session = null;
- }
- }
-
- @Override
- public List getDevices() {
- return Arrays.asList(
- named("default", () -> session.newDevice()
- .register()
- .setPassword()));
- }
-
- @Override
- public List getInvalidDevices() {
- return Arrays.asList(
- named("invalidPassword", () -> session.newDevice()
- .register()
- .setPassword()
- .overridePassword()));
- }
-
- @Override
- public IoTTestSession getSession() {
- return session;
- }
-}
diff --git a/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/http/MaxPayloadSizeTest.java b/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/http/MaxPayloadSizeTest.java
deleted file mode 100644
index 7b57b6375fd..00000000000
--- a/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/http/MaxPayloadSizeTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2020, EnMasse authors.
- * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
- */
-
-package io.enmasse.systemtest.iot.isolated.http;
-
-import static io.enmasse.systemtest.iot.HttpAdapterClient.ResponseException.statusCode;
-
-import io.enmasse.systemtest.iot.IoTTestSession.Adapter;
-import io.enmasse.systemtest.iot.IoTTestSession.Device;
-import io.enmasse.systemtest.iot.MessageSendTester.Sender;
-import io.enmasse.systemtest.iot.isolated.AbstractMaxPayloadSizeTest;
-
-public class MaxPayloadSizeTest extends AbstractMaxPayloadSizeTest {
-
- @Override
- protected Adapter adapter() {
- return Adapter.HTTP;
- }
-
- @SuppressWarnings("resource")
- @Override
- protected Sender sender(Device device) throws Exception {
- return cleanup(device
- .createHttpAdapterClient()
- .suppressExceptions(statusCode(413)))::send;
- }
-
-}
diff --git a/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/mqtt/MaxPayloadSizeTest.java b/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/mqtt/MaxPayloadSizeTest.java
deleted file mode 100644
index 5acfc5fb908..00000000000
--- a/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/mqtt/MaxPayloadSizeTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2020, EnMasse authors.
- * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
- */
-
-package io.enmasse.systemtest.iot.isolated.mqtt;
-
-import java.nio.charset.StandardCharsets;
-
-import io.enmasse.systemtest.iot.IoTTestSession.Adapter;
-import io.enmasse.systemtest.iot.IoTTestSession.Device;
-import io.enmasse.systemtest.iot.MessageSendTester.Sender;
-import io.enmasse.systemtest.iot.MessageSendTester.Type;
-import io.enmasse.systemtest.iot.isolated.AbstractMaxPayloadSizeTest;
-
-public class MaxPayloadSizeTest extends AbstractMaxPayloadSizeTest {
-
- @Override
- protected int reducePayloadBy(final Type type) {
- // reduce by: 2 (length) + x (topic name) bytes + 2 (QoS 1 msg id)
- return 2 + type.type().address().getBytes(StandardCharsets.UTF_8).length + 2;
- }
-
- @Override
- protected Adapter adapter() {
- return Adapter.MQTT;
- }
-
- @SuppressWarnings("resource")
- @Override
- protected Sender sender(Device device) throws Exception {
- return cleanup(device.createMqttAdapterClient())::sendQos1;
- }
-
-}
diff --git a/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/mqtt/MqttAdapterTest.java b/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/mqtt/MqttAdapterTest.java
deleted file mode 100644
index 9cc2b8e715f..00000000000
--- a/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/mqtt/MqttAdapterTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2019-2020, EnMasse authors.
- * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
- */
-
-package io.enmasse.systemtest.iot.isolated.mqtt;
-
-import static io.enmasse.systemtest.TestTag.ISOLATED_IOT;
-import static io.enmasse.systemtest.iot.DeviceSupplier.named;
-import static io.enmasse.systemtest.iot.IoTTestSession.Adapter.MQTT;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Tag;
-
-import io.enmasse.systemtest.iot.DeviceSupplier;
-import io.enmasse.systemtest.iot.IoTTestSession;
-import io.enmasse.systemtest.iot.mqtt.StandardIoTMqttTests;
-
-/**
- * Testing MQTT message transmission.
- */
-@Tag(ISOLATED_IOT)
-class MqttAdapterTest implements StandardIoTMqttTests {
-
- private static IoTTestSession session;
-
- @BeforeAll
- public static void setup() throws Exception {
- session = IoTTestSession.createDefault()
- .adapters(MQTT)
- .deploy();
- }
-
- @AfterAll
- public static void cleanup() throws Exception {
- if (session != null) {
- session.close();
- session = null;
- }
- }
-
- @Override
- public List getDevices() {
- return Arrays.asList(
- named("default", () -> session.newDevice()
- .register()
- .setPassword()));
- }
-
- @Override
- public List getInvalidDevices() {
- return Arrays.asList(
- named("invalidPassword", () -> session.newDevice()
- .register()
- .setPassword()
- .overridePassword()));
- }
-
- @Override
- public IoTTestSession getSession() {
- return session;
- }
-
-}
diff --git a/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/project/ManagedTest.java b/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/project/ManagedTest.java
deleted file mode 100644
index eade350eb0e..00000000000
--- a/systemtests/src/test/java/io/enmasse/systemtest/iot/isolated/project/ManagedTest.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright 2019-2020, EnMasse authors.
- * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
- */
-package io.enmasse.systemtest.iot.isolated.project;
-
-import static io.enmasse.systemtest.iot.DefaultDeviceRegistry.newDefaultInstance;
-import static io.enmasse.systemtest.utils.AddressSpaceUtils.addressSpaceExists;
-import static io.enmasse.systemtest.utils.TestUtils.waitUntilConditionOrFail;
-import static java.time.Duration.ofMinutes;
-import static java.time.Duration.ofSeconds;
-import static org.hamcrest.collection.IsEmptyIterable.emptyIterable;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-import java.net.HttpURLConnection;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.UUID;
-import java.util.function.BiConsumer;
-
-import org.apache.qpid.proton.message.Message;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-
-import io.enmasse.address.model.Address;
-import io.enmasse.address.model.AddressList;
-import io.enmasse.address.model.AddressSpace;
-import io.enmasse.address.model.AddressSpaceList;
-import io.enmasse.address.model.DoneableAddress;
-import io.enmasse.address.model.DoneableAddressSpace;
-import io.enmasse.address.model.KubeUtil;
-import io.enmasse.iot.model.v1.DoneableIoTProject;
-import io.enmasse.iot.model.v1.IoTConfig;
-import io.enmasse.iot.model.v1.IoTProject;
-import io.enmasse.iot.model.v1.IoTProjectBuilder;
-import io.enmasse.iot.model.v1.IoTProjectList;
-import io.enmasse.systemtest.Endpoint;
-import io.enmasse.systemtest.UserCredentials;
-import io.enmasse.systemtest.amqp.AmqpClientFactory;
-import io.enmasse.systemtest.bases.TestBase;
-import io.enmasse.systemtest.bases.iot.ITestIoTIsolated;
-import io.enmasse.systemtest.iot.CredentialsRegistryClient;
-import io.enmasse.systemtest.iot.DeviceRegistryClient;
-import io.enmasse.systemtest.iot.HttpAdapterClient;
-import io.enmasse.systemtest.iot.IoTTestSession;
-import io.enmasse.systemtest.iot.MessageSendTester;
-import io.enmasse.systemtest.iot.MessageSendTester.Type;
-import io.enmasse.systemtest.logs.CustomLogger;
-import io.enmasse.systemtest.utils.IoTUtils;
-import io.enmasse.user.model.v1.DoneableUser;
-import io.enmasse.user.model.v1.User;
-import io.enmasse.user.model.v1.UserList;
-import io.fabric8.kubernetes.client.dsl.MixedOperation;
-import io.fabric8.kubernetes.client.dsl.Resource;
-
-public class ManagedTest extends TestBase implements ITestIoTIsolated {
-
- private static final String MANAGED_TEST_ADDRESSSPACE = "managed-test-addrspace";
-
- private static final Logger log = CustomLogger.getLogger();
-
- private MixedOperation> client;
- private MixedOperation> addressClient;
- private MixedOperation> addressSpaceClient;
- private MixedOperation> userClient;
- protected DeviceRegistryClient registryClient;
- protected CredentialsRegistryClient credentialsClient;
-
- private Endpoint httpAdapterEndpoint;
- private UserCredentials credentials;
-
- @BeforeEach
- public void initClients () throws Exception {
- IoTConfig iotConfig = IoTTestSession.createDefaultConfig()
- .editOrNewSpec().withServices(newDefaultInstance()).endSpec()
- .build();
-
- isolatedIoTManager.createIoTConfig(iotConfig);
-
- final Endpoint deviceRegistryEndpoint = IoTUtils.getDeviceRegistryManagementEndpoint();
- this.registryClient = new DeviceRegistryClient(deviceRegistryEndpoint);
- this.credentialsClient = new CredentialsRegistryClient(deviceRegistryEndpoint);
- this.client = kubernetes.getIoTProjectClient(IOT_PROJECT_NAMESPACE);
- this.addressClient = kubernetes.getAddressClient(IOT_PROJECT_NAMESPACE);
- this.addressSpaceClient = kubernetes.getAddressSpaceClient(IOT_PROJECT_NAMESPACE);
- this.userClient = kubernetes.getUserClient(IOT_PROJECT_NAMESPACE);
- this.httpAdapterEndpoint = kubernetes.getExternalEndpoint("iot-http-adapter");
-
- this.credentials = new UserCredentials(UUID.randomUUID().toString(), UUID.randomUUID().toString());
- }
-
- @Test
- public void testChangeAddressSpace() throws Exception {
-
- var project = IoTUtils.getBasicIoTProjectObject("iot1", "as1",
- IOT_PROJECT_NAMESPACE, getDefaultAddressSpacePlan());
- isolatedIoTManager.createIoTProject(project);
-
- assertManagedResources(Assertions::assertNotNull, project, "as1");
-
- project = new IoTProjectBuilder(project)
- .editSpec()
- .editDownstreamStrategy()
- .editManagedStrategy()
- .editAddressSpace()
-
- .withName("as1a")
-
- .endAddressSpace()
- .endManagedStrategy()
- .endDownstreamStrategy()
- .endSpec()
- .build();
-
- // update the project
-
- log.info("Update project namespace");
- client.createOrReplace(project);
-
- // immediately after the change, the project is still ready but the new
- // address space is still missing, so we need to wait for it to be created
- // otherwise io.enmasse.systemtest.utils.IoTUtils.waitForIoTProjectReady(Kubernetes, IoTProject) will fail
-
- waitUntilConditionOrFail(
- addressSpaceExists(project.getMetadata().getNamespace(), project.getSpec().getDownstreamStrategy().getManagedStrategy().getAddressSpace().getName()),
- ofMinutes(5), ofSeconds(10),
- () -> String.format("Expected address space to be created"));
-
- // wait until the project and address space become ready
-
- log.info("For for project to become ready again");
- IoTUtils.waitForIoTProjectReady(kubernetes, project);
-
- // assert existence
-
- assertManagedResources(Assertions::assertNotNull, project, "as1a");
- assertManagedResources(Assertions::assertNull, project, "as1");
- }
-
- @Test
- public void testTwoManagedToTheSameAddressSpace() throws Exception {
-
- // first create two projects for a single address space
-
- var project1 = IoTUtils.getBasicIoTProjectObject("iot1", MANAGED_TEST_ADDRESSSPACE,
- IOT_PROJECT_NAMESPACE, getDefaultAddressSpacePlan());
- var project2 = IoTUtils.getBasicIoTProjectObject("iot2", MANAGED_TEST_ADDRESSSPACE,
- IOT_PROJECT_NAMESPACE, getDefaultAddressSpacePlan());
-
- var tenant1 = IoTUtils.getTenantId(project1);
- var tenant2 = IoTUtils.getTenantId(project2);
-
- // wait for the projects to be ready
-
- isolatedIoTManager.createIoTProject(project1);
- isolatedIoTManager.createIoTProject(project2);
-
- assertManagedResources(Assertions::assertNotNull, project1, MANAGED_TEST_ADDRESSSPACE);
- assertManagedResources(Assertions::assertNotNull, project2, MANAGED_TEST_ADDRESSSPACE);
-
- // register two devices with the same ids, but for different tenants
-
- this.registryClient.registerDevice(tenant1, "device1");
- this.registryClient.registerDevice(tenant2, "device1");
- this.credentialsClient.addPlainPasswordCredentials(tenant1, "device1", "auth1", "password1", null, HttpURLConnection.HTTP_NO_CONTENT);
- this.credentialsClient.addPlainPasswordCredentials(tenant2, "device1", "auth1", "password1", null, HttpURLConnection.HTTP_NO_CONTENT);
-
- // set up client
-
- isolatedIoTManager.createOrUpdateUser(isolatedIoTManager.getAddressSpace(IOT_PROJECT_NAMESPACE, MANAGED_TEST_ADDRESSSPACE), this.credentials);
- var iotAmqpClientFactory = new AmqpClientFactory(this.resourcesManager.getAddressSpace(IOT_PROJECT_NAMESPACE, MANAGED_TEST_ADDRESSSPACE), this.credentials);
- var amqpClient = iotAmqpClientFactory.createQueueClient();
-
- // now try to send some messages
-
- final List otherMessages = new LinkedList<>();
- try (
- var httpAdapterClient = new HttpAdapterClient(this.httpAdapterEndpoint, "auth1", tenant1, "password1");
- var otherReceiver = MessageSendTester.ConsumerFactory.of(amqpClient, tenant2).start(Type.TELEMETRY, msg -> otherMessages.add(msg)) ) {
-
- new MessageSendTester()
- .type(MessageSendTester.Type.TELEMETRY)
- .amount(1)
- .consumerFactory(MessageSendTester.ConsumerFactory.of(amqpClient, tenant1))
- .sender(httpAdapterClient::send)
- .execute();
-
- }
-
- assertThat(otherMessages, emptyIterable());
- }
-
- private void assertManagedResources(final BiConsumer