Skip to content

Commit

Permalink
Add AMQ in memory test resource
Browse files Browse the repository at this point in the history
With this resource we can have more control over async processing
and even avoid unnecessary async processing when not needed

Signed-off-by: Andrea Lamparelli <a.lamparelli95@gmail.com>
  • Loading branch information
lampajr committed Dec 5, 2024
1 parent db1bf13 commit 0fb4f11
Show file tree
Hide file tree
Showing 9 changed files with 669 additions and 568 deletions.
5 changes: 5 additions & 0 deletions horreum-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@
<version>3.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.smallrye.reactive</groupId>
<artifactId>smallrye-reactive-messaging-in-memory</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,14 @@ protected TestService.TestListing listTestSummary(String roles, String folder, i
.as(TestService.TestListing.class);
}

protected void updateView(View view) {
View newView = jsonRequest().body(view).post("/api/ui/view")
.then().statusCode(200).extract().body().as(View.class);
if (view.id != null) {
assertEquals(view.id, newView.id);
}
}

protected DataPoint assertValue(BlockingQueue<DataPoint.Event> datapointQueue, double value) throws InterruptedException {
DataPoint.Event dpe = datapointQueue.poll(10, TimeUnit.SECONDS);
assertNotNull(dpe);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
import io.hyperfoil.tools.horreum.entity.data.RunDAO;
import io.hyperfoil.tools.horreum.mapper.DatasetMapper;
import io.hyperfoil.tools.horreum.server.CloseMe;
import io.hyperfoil.tools.horreum.test.HorreumTestProfile;
import io.hyperfoil.tools.horreum.test.InMemoryAMQTestProfile;
import io.hyperfoil.tools.horreum.test.PostgresResource;
import io.hyperfoil.tools.horreum.test.TestUtil;
import io.quarkus.test.common.QuarkusTestResource;
Expand All @@ -75,7 +75,7 @@
@QuarkusTest
@QuarkusTestResource(PostgresResource.class)
@QuarkusTestResource(OidcWiremockTestResource.class)
@TestProfile(HorreumTestProfile.class)
@TestProfile(InMemoryAMQTestProfile.class)
public class RunServiceTest extends BaseServiceTest {
private static final int POLL_DURATION_SECONDS = 10;

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package io.hyperfoil.tools.horreum.test;

import java.util.HashMap;
import java.util.Map;

import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
import io.smallrye.reactive.messaging.memory.InMemoryConnector;

public class AMQPInMemoryResource implements QuarkusTestResourceLifecycleManager {
@Override
public Map<String, String> start() {
Map<String, String> env = new HashMap<>();
Map<String, String> props1 = InMemoryConnector.switchIncomingChannelsToInMemory("run-upload-in");
Map<String, String> props2 = InMemoryConnector.switchOutgoingChannelsToInMemory("run-upload-out");
Map<String, String> props3 = InMemoryConnector.switchIncomingChannelsToInMemory("dataset-event-in");
Map<String, String> props4 = InMemoryConnector.switchOutgoingChannelsToInMemory("dataset-event-out");
Map<String, String> props5 = InMemoryConnector.switchIncomingChannelsToInMemory("run-recalc-in");
Map<String, String> props6 = InMemoryConnector.switchOutgoingChannelsToInMemory("run-recalc-out");
Map<String, String> props7 = InMemoryConnector.switchIncomingChannelsToInMemory("schema-sync-in");
Map<String, String> props8 = InMemoryConnector.switchOutgoingChannelsToInMemory("schema-sync-out");
env.putAll(props1);
env.putAll(props2);
env.putAll(props3);
env.putAll(props4);
env.putAll(props5);
env.putAll(props6);
env.putAll(props7);
env.putAll(props8);
return env;
}

@Override
public void stop() {
InMemoryConnector.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.HashMap;
import java.util.Map;

public class ElasticsearchTestProfile extends HorreumTestProfile {
public class ElasticsearchTestProfile extends InMemoryAMQTestProfile {

@Override
public Map<String, String> getConfigOverrides() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public boolean disableGlobalTestResources() {
@Override
public List<TestResourceEntry> testResources() {
return Arrays.asList(
new TestResourceEntry(PostgresResource.class), new TestResourceEntry(OidcWiremockTestResource.class));
new TestResourceEntry(PostgresResource.class),
new TestResourceEntry(OidcWiremockTestResource.class));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.hyperfoil.tools.horreum.test;

import java.util.Arrays;
import java.util.List;

import io.quarkus.test.oidc.server.OidcWiremockTestResource;

public class InMemoryAMQTestProfile extends HorreumTestProfile {

@Override
public List<TestResourceEntry> testResources() {
return Arrays.asList(
new TestResourceEntry(PostgresResource.class),
new TestResourceEntry(OidcWiremockTestResource.class),
new TestResourceEntry(AMQPInMemoryResource.class));
}
}

0 comments on commit 0fb4f11

Please sign in to comment.