use of org.junit.jupiter.params.provider.MethodSource in project hono by eclipse.
the class CoapTestBase method testUploadMessagesWithTtdThatReplyWithCommand.
/**
* Verifies that the CoAP adapter delivers a command to a device and accepts
* the corresponding response from the device.
*
* @param endpointConfig The endpoints to use for sending/receiving commands.
* @param ctx The test context.
* @throws InterruptedException if the test fails.
*/
@ParameterizedTest(name = IntegrationTestSupport.PARAMETERIZED_TEST_NAME_PATTERN)
@MethodSource("commandAndControlVariants")
public void testUploadMessagesWithTtdThatReplyWithCommand(final CoapCommandEndpointConfiguration endpointConfig, final VertxTestContext ctx) throws InterruptedException {
final Tenant tenant = new Tenant();
testUploadMessagesWithTtdThatReplyWithCommand(endpointConfig, tenant, ctx);
}
use of org.junit.jupiter.params.provider.MethodSource in project hono by eclipse.
the class AmqpUploadTestBase method testUploadMessagesUsingSaslExternal.
/**
* Verifies that a number of messages uploaded to the AMQP adapter using client certificate
* based authentication can be successfully consumed via the AMQP Messaging Network.
*
* @param senderQos The delivery semantics used by the device for uploading messages.
* @throws InterruptedException if test execution is interrupted.
*/
@ParameterizedTest(name = IntegrationTestSupport.PARAMETERIZED_TEST_NAME_PATTERN)
@MethodSource("senderQoSTypes")
public void testUploadMessagesUsingSaslExternal(final ProtonQoS senderQos) throws InterruptedException {
final String tenantId = helper.getRandomTenantId();
final String deviceId = helper.getRandomDeviceId(tenantId);
final SelfSignedCertificate deviceCert = SelfSignedCertificate.create(deviceId + ".iot.eclipse.org");
final VertxTestContext setup = new VertxTestContext();
helper.getCertificate(deviceCert.certificatePath()).compose(cert -> {
final var tenant = Tenants.createTenantForTrustAnchor(cert);
prepareTenantConfig(tenant);
return helper.registry.addDeviceForTenant(tenantId, tenant, deviceId, cert);
}).compose(ok -> connectToAdapter(deviceCert)).compose(con -> createProducer(null, senderQos)).onComplete(setup.succeeding(s -> {
setup.verify(() -> {
final UnsignedLong maxMessageSize = s.getRemoteMaxMessageSize();
assertWithMessage("max-message-size included in adapter's attach frame").that(maxMessageSize).isNotNull();
assertWithMessage("max-message-size").that(maxMessageSize.longValue()).isGreaterThan(0);
});
sender = s;
setup.completeNow();
}));
assertThat(setup.awaitCompletion(5, TimeUnit.SECONDS)).isTrue();
assertWithMessage("adapter connection failure occurred").that(setup.failed()).isFalse();
testUploadMessages(tenantId, senderQos);
}
use of org.junit.jupiter.params.provider.MethodSource in project hono by eclipse.
the class MicrometerBasedMetricsTest method testConnectionTimeDuration.
/**
* Verifies that the connection time duration is recorded for the given tenant when devices get connected and
* disconnected.
*
* @param registry The registry that the tests should be run against.
*/
@ParameterizedTest
@MethodSource("registries")
public void testConnectionTimeDuration(final MeterRegistry registry) {
final MeterRegistry meterRegistry = Mockito.spy(registry);
final Metrics metrics = new MicrometerBasedMetrics(meterRegistry, mock(Vertx.class));
metrics.incrementConnections("TEST_TENANT");
metrics.decrementConnections("TEST_TENANT");
verify(meterRegistry, times(1)).timer(MicrometerBasedMetrics.METER_CONNECTIONS_AUTHENTICATED_DURATION, Tags.of(MetricsTags.getTenantTag("TEST_TENANT")));
}
use of org.junit.jupiter.params.provider.MethodSource in project hono by eclipse.
the class MicrometerBasedMetricsTest method testPayloadSizeForTelemetryMessages.
/**
* Verifies that the payload size is calculated based on the configured minimum message size
* when reporting downstream telemetry messages.
*
* @param registry The registry that the tests should be run against.
*/
@ParameterizedTest
@MethodSource("registries")
public void testPayloadSizeForTelemetryMessages(final MeterRegistry registry) {
final Metrics metrics = new MicrometerBasedMetrics(registry, mock(Vertx.class));
final TenantObject tenantObject = TenantObject.from("TEST_TENANT", true).setMinimumMessageSize(4 * 1024);
metrics.reportTelemetry(MetricsTags.EndpointType.TELEMETRY, "tenant", tenantObject, MetricsTags.ProcessingOutcome.FORWARDED, MetricsTags.QoS.UNKNOWN, 1 * 1024, MetricsTags.TtdStatus.NONE, metrics.startTimer());
assertEquals(4 * 1024, registry.find(MicrometerBasedMetrics.METER_MESSAGES_PAYLOAD).summary().totalAmount());
}
use of org.junit.jupiter.params.provider.MethodSource in project hono by eclipse.
the class MicrometerBasedMetricsTest method testNoTenantTimeoutOnDefault.
/**
* Verifies that collecting the last message send time is disabled by default.
*
* @param registry The registry that the tests should be run against.
*/
@ParameterizedTest
@MethodSource("registries")
public void testNoTenantTimeoutOnDefault(final MeterRegistry registry) {
final MicrometerBasedMetrics metrics = new MicrometerBasedMetrics(registry, mock(Vertx.class));
reportTelemetry(metrics);
assertTrue(metrics.getLastSeenTimestampPerTenant().isEmpty());
metrics.setProtocolAdapterProperties(new ProtocolAdapterProperties());
reportTelemetry(metrics);
assertTrue(metrics.getLastSeenTimestampPerTenant().isEmpty());
final ProtocolAdapterProperties config = new ProtocolAdapterProperties();
config.setTenantIdleTimeout(Duration.ZERO);
metrics.setProtocolAdapterProperties(config);
reportTelemetry(metrics);
assertTrue(metrics.getLastSeenTimestampPerTenant().isEmpty());
}
Aggregations