You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2022/08/02 01:24:51 UTC
[james-project] branch master updated: JAMES-3791 Integration test for RemoteDelivery concurrency
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
The following commit(s) were added to refs/heads/master by this push:
new 191ec82a42 JAMES-3791 Integration test for RemoteDelivery concurrency
191ec82a42 is described below
commit 191ec82a4287e49a3ccdf6e9e97f657fb13d004a
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Aug 1 11:39:24 2022 +0700
JAMES-3791 Integration test for RemoteDelivery concurrency
Reliably reproduce the issue and would prevent regressions.
---
.../GatewayRemoteDeliveryIntegrationTest.java | 47 ++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/GatewayRemoteDeliveryIntegrationTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/GatewayRemoteDeliveryIntegrationTest.java
index 2c702654a4..ac539c5b7f 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/GatewayRemoteDeliveryIntegrationTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/GatewayRemoteDeliveryIntegrationTest.java
@@ -25,10 +25,14 @@ import static org.apache.james.mailets.configuration.Constants.DEFAULT_DOMAIN;
import static org.apache.james.mailets.configuration.Constants.LOCALHOST_IP;
import static org.apache.james.mailets.configuration.Constants.PASSWORD;
import static org.apache.james.mailets.configuration.Constants.awaitAtMostOneMinute;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import java.io.File;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.IntStream;
import org.apache.james.dnsservice.api.DNSService;
import org.apache.james.dnsservice.api.InMemoryDNSService;
@@ -50,6 +54,9 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.io.TempDir;
+import org.testcontainers.shaded.com.google.common.collect.ImmutableList;
+
+import com.github.fge.lambdas.Throwing;
class GatewayRemoteDeliveryIntegrationTest {
private static final String JAMES_ANOTHER_DOMAIN = "james.com";
@@ -107,6 +114,46 @@ class GatewayRemoteDeliveryIntegrationTest {
.untilAsserted(this::assertMessageReceivedByTheSmtpServer);
}
+ @Test
+ void mailFromShouldBePreservedUponConcurrency(@TempDir File temporaryFolder) throws Exception {
+ String gatewayProperty = fakeSmtp.getContainer().getContainerIp();
+
+ jamesServer = TemporaryJamesServer.builder()
+ .withBase(SMTP_ONLY_MODULE)
+ .withMailetContainer(generateMailetContainerConfiguration(gatewayProperty))
+ .withSmtpConfiguration(SmtpConfiguration.builder()
+ .doNotVerifyIdentity()
+ .withAutorizedAddresses("0.0.0.0/0.0.0.0")
+ .build())
+ .build(temporaryFolder);
+ jamesServer.start();
+
+ dataProbe = jamesServer.getProbe(DataProbeImpl.class);
+ dataProbe.addDomain(DEFAULT_DOMAIN);
+ dataProbe.addUser(FROM, PASSWORD);
+
+ messageSender.connect(LOCALHOST_IP, jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort());
+
+ int mailCount = 100;
+ IntStream.range(0, mailCount)
+ .forEach(Throwing.intConsumer(i -> messageSender
+ .sendMessageWithHeaders("from" + i + "@" + DEFAULT_DOMAIN, ImmutableList.of(RECIPIENT),
+ "Subject: " + i + "\r\n\r\nBODY")));
+
+ awaitAtMostOneMinute
+ .untilAsserted(() ->
+ fakeSmtp.assertEmailReceived(response -> response
+ .body("", hasSize(100))));
+
+ fakeSmtp.assertEmailReceived(response -> {
+ List<Map<String, Object>> receivedMails = response.extract().body().jsonPath().getList("");
+
+ receivedMails.stream()
+ .forEach(map -> assertThat(map.get("from"))
+ .isEqualTo("from" + map.get("subject") + "@" + DEFAULT_DOMAIN));
+ });
+ }
+
@Test
void outgoingMailShouldTransitThroughGatewayWhenPort(@TempDir File temporaryFolder) throws Exception {
String gatewayProperty = fakeSmtp.getContainer().getContainerIp() + ":25";
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org