You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "JiriOndrusek (via GitHub)" <gi...@apache.org> on 2025/03/04 09:34:33 UTC
[PR] Added azure-servicebus local testing [camel-quarkus]
JiriOndrusek opened a new pull request, #7082:
URL: https://github.com/apache/camel-quarkus/pull/7082
fixes https://github.com/apache/camel-quarkus/issues/6946
The servicebus emulator has several limitations:
- only connection string is available (therefore I disabled for mock testing some different authentication methods)
- does not support AMQP_WEB_SOCKET, so I reduced the parametrized test for the mocked testing
<!-- Uncomment and fill this section if your PR is not trivial
[ ] An issue should be filed for the change unless this is a trivial change (fixing a typo or similar). One issue should ideally be fixed by not more than one commit and the other way round, each commit should fix just one issue, without pulling in other changes.
[ ] Each commit in the pull request should have a meaningful and properly spelled subject line and body. Copying the title of the associated issue is typically enough. Please include the issue number in the commit message prefixed by #.
[ ] The pull request description should explain what the pull request does, how, and why. If the info is available in the associated issue or some other external document, a link is enough.
[ ] Phrases like Fix #<issueNumber> or Fixes #<issueNumber> will auto-close the named issue upon merging the pull request. Using them is typically a good idea.
[ ] Please run mvn process-resources -Pformat (and amend the changes if necessary) before sending the pull request.
[ ] Contributor guide is your good friend: https://camel.apache.org/camel-quarkus/latest/contributor-guide.html
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Added azure-servicebus mock testing [camel-quarkus]
Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on PR #7082:
URL: https://github.com/apache/camel-quarkus/pull/7082#issuecomment-2703903765
`azure-grouped` tests failed:
```
Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
```
I have rerun it. Maybe it's a transitive thing / flaky...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Added azure-servicebus mock testing [camel-quarkus]
Posted by "JiriOndrusek (via GitHub)" <gi...@apache.org>.
JiriOndrusek commented on code in PR #7082:
URL: https://github.com/apache/camel-quarkus/pull/7082#discussion_r1979238801
##########
integration-tests-support/azure/src/main/java/org/apache/camel/quarkus/test/support/azure/AzureServiceBusTestResource.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.quarkus.test.support.azure;
+
+import java.io.File;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import io.quarkus.runtime.LaunchMode;
+import io.quarkus.runtime.configuration.ConfigUtils;
+import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
+import io.smallrye.config.SmallRyeConfig;
+import org.apache.camel.quarkus.test.mock.backend.MockBackendUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.ComposeContainer;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.containers.wait.strategy.Wait;
+
+public class AzureServiceBusTestResource implements QuarkusTestResourceLifecycleManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AzureServiceBusTestResource.class);
+ private Map<String, String> initArgs = new LinkedHashMap<>();
+ private ComposeContainer container;
+
+ @Override
+ public void init(Map<String, String> initArgs) {
+ this.initArgs = initArgs;
+ }
+
+ @Override
+ public Map<String, String> start() {
+ final SmallRyeConfig config = ConfigUtils.configBuilder(true, LaunchMode.NORMAL).build();
+
+ final boolean realCredentialsProvided = System.getenv("AZURE_SERVICEBUS_CONNECTION_STRING") != null
+ && System.getenv("AZURE_SERVICEBUS_QUEUE_NAME") != null;
+
+ final boolean startMockBackend = MockBackendUtils.startMockBackend(false);
+ final Map<String, String> result = new LinkedHashMap<>();
+ if (startMockBackend && !realCredentialsProvided) {
+ MockBackendUtils.logMockBackendUsed();
+
+ try {
+ //copy docker-compose to tmp location
+ File dockerComposeFile, configFile;
+ try (InputStream inYaml = getClass().getClassLoader().getResourceAsStream("servicebus-docker-compose.yaml");
+ InputStream inJson = getClass().getClassLoader().getResourceAsStream("servicebus-config.json")) {
+ dockerComposeFile = File.createTempFile("servicebus-docker-compose-", ".yaml");
+ configFile = File.createTempFile("servicebus-config-", ".json");
+ Files.copy(inYaml, dockerComposeFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
+ Files.copy(inJson, configFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
+ }
+
+ container = new ComposeContainer(dockerComposeFile)
+ .withEnv("ACCEPT_EULA", "Y")
+ .withEnv("SERVICEBUS_EMULATOR_IMAGE",
+ config.getValue("servicebus-emulator.container.image", String.class))
+ .withEnv("SQL_EDGE_IMAGE", config.getValue("azure-sql-edge.container.image", String.class))
+ .withEnv("CONFIG_FILE", configFile.getAbsolutePath())
+ .withEnv("MSSQL_SA_PASSWORD", "12345678923456y!43")
+ .withExposedService("emulator", 5672)
+ .withLocalCompose(true)
+ .withLogConsumer("emulator", new Slf4jLogConsumer(LOGGER))
+ .waitingFor("emulator", Wait.forLogMessage(".*Emulator Service is Successfully Up!.*", 1));
+
+ container.start();
+
+ String connectionString = "Endpoint=sb://%s:%d;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;"
+ .formatted(container.getServiceHost("emulator", 5672), container.getServicePort("emulator", 5672));
Review Comment:
Hi, I'm not sure I get it. I need hostname, get by calling `ontainer.getServiceHost("emulator", 5672)` and the port (by calling `container.getServicePort("emulator", 5672)`). Both those values are used in the string `"Endpoint=sb://%s:%d;...`
So I don't see, what could be done differently.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Added azure-servicebus mock testing [camel-quarkus]
Posted by "aldettinger (via GitHub)" <gi...@apache.org>.
aldettinger commented on code in PR #7082:
URL: https://github.com/apache/camel-quarkus/pull/7082#discussion_r1979301574
##########
integration-tests-support/azure/src/main/java/org/apache/camel/quarkus/test/support/azure/AzureServiceBusTestResource.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.quarkus.test.support.azure;
+
+import java.io.File;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import io.quarkus.runtime.LaunchMode;
+import io.quarkus.runtime.configuration.ConfigUtils;
+import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
+import io.smallrye.config.SmallRyeConfig;
+import org.apache.camel.quarkus.test.mock.backend.MockBackendUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.ComposeContainer;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.containers.wait.strategy.Wait;
+
+public class AzureServiceBusTestResource implements QuarkusTestResourceLifecycleManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AzureServiceBusTestResource.class);
+ private Map<String, String> initArgs = new LinkedHashMap<>();
+ private ComposeContainer container;
+
+ @Override
+ public void init(Map<String, String> initArgs) {
+ this.initArgs = initArgs;
+ }
+
+ @Override
+ public Map<String, String> start() {
+ final SmallRyeConfig config = ConfigUtils.configBuilder(true, LaunchMode.NORMAL).build();
+
+ final boolean realCredentialsProvided = System.getenv("AZURE_SERVICEBUS_CONNECTION_STRING") != null
+ && System.getenv("AZURE_SERVICEBUS_QUEUE_NAME") != null;
+
+ final boolean startMockBackend = MockBackendUtils.startMockBackend(false);
+ final Map<String, String> result = new LinkedHashMap<>();
+ if (startMockBackend && !realCredentialsProvided) {
+ MockBackendUtils.logMockBackendUsed();
+
+ try {
+ //copy docker-compose to tmp location
+ File dockerComposeFile, configFile;
+ try (InputStream inYaml = getClass().getClassLoader().getResourceAsStream("servicebus-docker-compose.yaml");
+ InputStream inJson = getClass().getClassLoader().getResourceAsStream("servicebus-config.json")) {
+ dockerComposeFile = File.createTempFile("servicebus-docker-compose-", ".yaml");
+ configFile = File.createTempFile("servicebus-config-", ".json");
+ Files.copy(inYaml, dockerComposeFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
+ Files.copy(inJson, configFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
+ }
+
+ container = new ComposeContainer(dockerComposeFile)
+ .withEnv("ACCEPT_EULA", "Y")
+ .withEnv("SERVICEBUS_EMULATOR_IMAGE",
+ config.getValue("servicebus-emulator.container.image", String.class))
+ .withEnv("SQL_EDGE_IMAGE", config.getValue("azure-sql-edge.container.image", String.class))
+ .withEnv("CONFIG_FILE", configFile.getAbsolutePath())
+ .withEnv("MSSQL_SA_PASSWORD", "12345678923456y!43")
+ .withExposedService("emulator", 5672)
+ .withLocalCompose(true)
+ .withLogConsumer("emulator", new Slf4jLogConsumer(LOGGER))
+ .waitingFor("emulator", Wait.forLogMessage(".*Emulator Service is Successfully Up!.*", 1));
+
+ container.start();
+
+ String connectionString = "Endpoint=sb://%s:%d;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;"
+ .formatted(container.getServiceHost("emulator", 5672), container.getServicePort("emulator", 5672));
Review Comment:
`private static int PORT = 5672` if that make sense. Maybe I'm missing something. Plus that's really details, no big deal :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Added azure-servicebus mock testing [camel-quarkus]
Posted by "JiriOndrusek (via GitHub)" <gi...@apache.org>.
JiriOndrusek commented on PR #7082:
URL: https://github.com/apache/camel-quarkus/pull/7082#issuecomment-2703644082
Let me rebuild again locally (it seems that more changes are added into the PR) after rebase to `main` branch,. which was not intended
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Added azure-servicebus mock testing [camel-quarkus]
Posted by "aldettinger (via GitHub)" <gi...@apache.org>.
aldettinger commented on code in PR #7082:
URL: https://github.com/apache/camel-quarkus/pull/7082#discussion_r1979125552
##########
integration-tests-support/azure/src/main/java/org/apache/camel/quarkus/test/support/azure/AzureServiceBusTestResource.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.quarkus.test.support.azure;
+
+import java.io.File;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import io.quarkus.runtime.LaunchMode;
+import io.quarkus.runtime.configuration.ConfigUtils;
+import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
+import io.smallrye.config.SmallRyeConfig;
+import org.apache.camel.quarkus.test.mock.backend.MockBackendUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.ComposeContainer;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.containers.wait.strategy.Wait;
+
+public class AzureServiceBusTestResource implements QuarkusTestResourceLifecycleManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AzureServiceBusTestResource.class);
+ private Map<String, String> initArgs = new LinkedHashMap<>();
+ private ComposeContainer container;
+
+ @Override
+ public void init(Map<String, String> initArgs) {
+ this.initArgs = initArgs;
+ }
+
+ @Override
+ public Map<String, String> start() {
+ final SmallRyeConfig config = ConfigUtils.configBuilder(true, LaunchMode.NORMAL).build();
+
+ final boolean realCredentialsProvided = System.getenv("AZURE_SERVICEBUS_CONNECTION_STRING") != null
+ && System.getenv("AZURE_SERVICEBUS_QUEUE_NAME") != null;
+
+ final boolean startMockBackend = MockBackendUtils.startMockBackend(false);
+ final Map<String, String> result = new LinkedHashMap<>();
+ if (startMockBackend && !realCredentialsProvided) {
+ MockBackendUtils.logMockBackendUsed();
+
+ try {
+ //copy docker-compose to tmp location
+ File dockerComposeFile, configFile;
+ try (InputStream inYaml = getClass().getClassLoader().getResourceAsStream("servicebus-docker-compose.yaml");
+ InputStream inJson = getClass().getClassLoader().getResourceAsStream("servicebus-config.json")) {
+ dockerComposeFile = File.createTempFile("servicebus-docker-compose-", ".yaml");
+ configFile = File.createTempFile("servicebus-config-", ".json");
+ Files.copy(inYaml, dockerComposeFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
+ Files.copy(inJson, configFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
+ }
+
+ container = new ComposeContainer(dockerComposeFile)
+ .withEnv("ACCEPT_EULA", "Y")
+ .withEnv("SERVICEBUS_EMULATOR_IMAGE",
+ config.getValue("servicebus-emulator.container.image", String.class))
+ .withEnv("SQL_EDGE_IMAGE", config.getValue("azure-sql-edge.container.image", String.class))
+ .withEnv("CONFIG_FILE", configFile.getAbsolutePath())
+ .withEnv("MSSQL_SA_PASSWORD", "12345678923456y!43")
+ .withExposedService("emulator", 5672)
+ .withLocalCompose(true)
+ .withLogConsumer("emulator", new Slf4jLogConsumer(LOGGER))
+ .waitingFor("emulator", Wait.forLogMessage(".*Emulator Service is Successfully Up!.*", 1));
+
+ container.start();
+
+ String connectionString = "Endpoint=sb://%s:%d;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;"
+ .formatted(container.getServiceHost("emulator", 5672), container.getServicePort("emulator", 5672));
Review Comment:
neat: maybe the port could be a single variable ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Added azure-servicebus mock testing [camel-quarkus]
Posted by "JiriOndrusek (via GitHub)" <gi...@apache.org>.
JiriOndrusek commented on code in PR #7082:
URL: https://github.com/apache/camel-quarkus/pull/7082#discussion_r1979350703
##########
integration-tests-support/azure/src/main/java/org/apache/camel/quarkus/test/support/azure/AzureServiceBusTestResource.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.quarkus.test.support.azure;
+
+import java.io.File;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import io.quarkus.runtime.LaunchMode;
+import io.quarkus.runtime.configuration.ConfigUtils;
+import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
+import io.smallrye.config.SmallRyeConfig;
+import org.apache.camel.quarkus.test.mock.backend.MockBackendUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.ComposeContainer;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.containers.wait.strategy.Wait;
+
+public class AzureServiceBusTestResource implements QuarkusTestResourceLifecycleManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AzureServiceBusTestResource.class);
+ private Map<String, String> initArgs = new LinkedHashMap<>();
+ private ComposeContainer container;
+
+ @Override
+ public void init(Map<String, String> initArgs) {
+ this.initArgs = initArgs;
+ }
+
+ @Override
+ public Map<String, String> start() {
+ final SmallRyeConfig config = ConfigUtils.configBuilder(true, LaunchMode.NORMAL).build();
+
+ final boolean realCredentialsProvided = System.getenv("AZURE_SERVICEBUS_CONNECTION_STRING") != null
+ && System.getenv("AZURE_SERVICEBUS_QUEUE_NAME") != null;
+
+ final boolean startMockBackend = MockBackendUtils.startMockBackend(false);
+ final Map<String, String> result = new LinkedHashMap<>();
+ if (startMockBackend && !realCredentialsProvided) {
+ MockBackendUtils.logMockBackendUsed();
+
+ try {
+ //copy docker-compose to tmp location
+ File dockerComposeFile, configFile;
+ try (InputStream inYaml = getClass().getClassLoader().getResourceAsStream("servicebus-docker-compose.yaml");
+ InputStream inJson = getClass().getClassLoader().getResourceAsStream("servicebus-config.json")) {
+ dockerComposeFile = File.createTempFile("servicebus-docker-compose-", ".yaml");
+ configFile = File.createTempFile("servicebus-config-", ".json");
+ Files.copy(inYaml, dockerComposeFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
+ Files.copy(inJson, configFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
+ }
+
+ container = new ComposeContainer(dockerComposeFile)
+ .withEnv("ACCEPT_EULA", "Y")
+ .withEnv("SERVICEBUS_EMULATOR_IMAGE",
+ config.getValue("servicebus-emulator.container.image", String.class))
+ .withEnv("SQL_EDGE_IMAGE", config.getValue("azure-sql-edge.container.image", String.class))
+ .withEnv("CONFIG_FILE", configFile.getAbsolutePath())
+ .withEnv("MSSQL_SA_PASSWORD", "12345678923456y!43")
+ .withExposedService("emulator", 5672)
+ .withLocalCompose(true)
+ .withLogConsumer("emulator", new Slf4jLogConsumer(LOGGER))
+ .waitingFor("emulator", Wait.forLogMessage(".*Emulator Service is Successfully Up!.*", 1));
+
+ container.start();
+
+ String connectionString = "Endpoint=sb://%s:%d;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;"
+ .formatted(container.getServiceHost("emulator", 5672), container.getServicePort("emulator", 5672));
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Added azure-servicebus mock testing [camel-quarkus]
Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton merged PR #7082:
URL: https://github.com/apache/camel-quarkus/pull/7082
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Added azure-servicebus mock testing [camel-quarkus]
Posted by "JiriOndrusek (via GitHub)" <gi...@apache.org>.
JiriOndrusek commented on code in PR #7082:
URL: https://github.com/apache/camel-quarkus/pull/7082#discussion_r1983224718
##########
integration-test-groups/azure/azure-servicebus/src/test/java/org/apache/camel/quarkus/component/azure/servicebus/it/AzureServiceBusTest.java:
##########
@@ -357,7 +366,10 @@ static Stream<Arguments> produceConsumeOptions() {
String[] payloadTypes = { String.class.getSimpleName(), byte[].class.getSimpleName(),
BinaryData.class.getSimpleName() };
- AmqpTransportType[] transportTypes = AmqpTransportType.values();
+ //in mocked backend, the AMQP_WEB_SOCKET is not supported, see https://github.com/Azure/azure-service-bus-emulator-installer/issues/51
+ AmqpTransportType[] transportTypes = Arrays.stream(AmqpTransportType.values())
+ .filter(type -> AzureServiceBusHelper.isMockBackEnd() && type != AmqpTransportType.AMQP_WEB_SOCKETS)
+ .toArray(AmqpTransportType[]::new);
Review Comment:
Thanks for the verifycation with the real cloud! Fix is added to the PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Added azure-servicebus mock testing [camel-quarkus]
Posted by "JiriOndrusek (via GitHub)" <gi...@apache.org>.
JiriOndrusek commented on code in PR #7082:
URL: https://github.com/apache/camel-quarkus/pull/7082#discussion_r1979238801
##########
integration-tests-support/azure/src/main/java/org/apache/camel/quarkus/test/support/azure/AzureServiceBusTestResource.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.quarkus.test.support.azure;
+
+import java.io.File;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import io.quarkus.runtime.LaunchMode;
+import io.quarkus.runtime.configuration.ConfigUtils;
+import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
+import io.smallrye.config.SmallRyeConfig;
+import org.apache.camel.quarkus.test.mock.backend.MockBackendUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.ComposeContainer;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.containers.wait.strategy.Wait;
+
+public class AzureServiceBusTestResource implements QuarkusTestResourceLifecycleManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AzureServiceBusTestResource.class);
+ private Map<String, String> initArgs = new LinkedHashMap<>();
+ private ComposeContainer container;
+
+ @Override
+ public void init(Map<String, String> initArgs) {
+ this.initArgs = initArgs;
+ }
+
+ @Override
+ public Map<String, String> start() {
+ final SmallRyeConfig config = ConfigUtils.configBuilder(true, LaunchMode.NORMAL).build();
+
+ final boolean realCredentialsProvided = System.getenv("AZURE_SERVICEBUS_CONNECTION_STRING") != null
+ && System.getenv("AZURE_SERVICEBUS_QUEUE_NAME") != null;
+
+ final boolean startMockBackend = MockBackendUtils.startMockBackend(false);
+ final Map<String, String> result = new LinkedHashMap<>();
+ if (startMockBackend && !realCredentialsProvided) {
+ MockBackendUtils.logMockBackendUsed();
+
+ try {
+ //copy docker-compose to tmp location
+ File dockerComposeFile, configFile;
+ try (InputStream inYaml = getClass().getClassLoader().getResourceAsStream("servicebus-docker-compose.yaml");
+ InputStream inJson = getClass().getClassLoader().getResourceAsStream("servicebus-config.json")) {
+ dockerComposeFile = File.createTempFile("servicebus-docker-compose-", ".yaml");
+ configFile = File.createTempFile("servicebus-config-", ".json");
+ Files.copy(inYaml, dockerComposeFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
+ Files.copy(inJson, configFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
+ }
+
+ container = new ComposeContainer(dockerComposeFile)
+ .withEnv("ACCEPT_EULA", "Y")
+ .withEnv("SERVICEBUS_EMULATOR_IMAGE",
+ config.getValue("servicebus-emulator.container.image", String.class))
+ .withEnv("SQL_EDGE_IMAGE", config.getValue("azure-sql-edge.container.image", String.class))
+ .withEnv("CONFIG_FILE", configFile.getAbsolutePath())
+ .withEnv("MSSQL_SA_PASSWORD", "12345678923456y!43")
+ .withExposedService("emulator", 5672)
+ .withLocalCompose(true)
+ .withLogConsumer("emulator", new Slf4jLogConsumer(LOGGER))
+ .waitingFor("emulator", Wait.forLogMessage(".*Emulator Service is Successfully Up!.*", 1));
+
+ container.start();
+
+ String connectionString = "Endpoint=sb://%s:%d;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;"
+ .formatted(container.getServiceHost("emulator", 5672), container.getServicePort("emulator", 5672));
Review Comment:
Hi, I'm not sure I get it. I need hostname, got by calling `ontainer.getServiceHost("emulator", 5672)` and the port (by calling `container.getServicePort("emulator", 5672)`). Both those values are used in the string `"Endpoint=sb://%s:%d;...`
So I don't see, what could be done differently.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Added azure-servicebus mock testing [camel-quarkus]
Posted by "JiriOndrusek (via GitHub)" <gi...@apache.org>.
JiriOndrusek commented on code in PR #7082:
URL: https://github.com/apache/camel-quarkus/pull/7082#discussion_r1979344036
##########
integration-tests-support/azure/src/main/java/org/apache/camel/quarkus/test/support/azure/AzureServiceBusTestResource.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.quarkus.test.support.azure;
+
+import java.io.File;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import io.quarkus.runtime.LaunchMode;
+import io.quarkus.runtime.configuration.ConfigUtils;
+import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
+import io.smallrye.config.SmallRyeConfig;
+import org.apache.camel.quarkus.test.mock.backend.MockBackendUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.ComposeContainer;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.containers.wait.strategy.Wait;
+
+public class AzureServiceBusTestResource implements QuarkusTestResourceLifecycleManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AzureServiceBusTestResource.class);
+ private Map<String, String> initArgs = new LinkedHashMap<>();
+ private ComposeContainer container;
+
+ @Override
+ public void init(Map<String, String> initArgs) {
+ this.initArgs = initArgs;
+ }
+
+ @Override
+ public Map<String, String> start() {
+ final SmallRyeConfig config = ConfigUtils.configBuilder(true, LaunchMode.NORMAL).build();
+
+ final boolean realCredentialsProvided = System.getenv("AZURE_SERVICEBUS_CONNECTION_STRING") != null
+ && System.getenv("AZURE_SERVICEBUS_QUEUE_NAME") != null;
+
+ final boolean startMockBackend = MockBackendUtils.startMockBackend(false);
+ final Map<String, String> result = new LinkedHashMap<>();
+ if (startMockBackend && !realCredentialsProvided) {
+ MockBackendUtils.logMockBackendUsed();
+
+ try {
+ //copy docker-compose to tmp location
+ File dockerComposeFile, configFile;
+ try (InputStream inYaml = getClass().getClassLoader().getResourceAsStream("servicebus-docker-compose.yaml");
+ InputStream inJson = getClass().getClassLoader().getResourceAsStream("servicebus-config.json")) {
+ dockerComposeFile = File.createTempFile("servicebus-docker-compose-", ".yaml");
+ configFile = File.createTempFile("servicebus-config-", ".json");
+ Files.copy(inYaml, dockerComposeFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
+ Files.copy(inJson, configFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
+ }
+
+ container = new ComposeContainer(dockerComposeFile)
+ .withEnv("ACCEPT_EULA", "Y")
+ .withEnv("SERVICEBUS_EMULATOR_IMAGE",
+ config.getValue("servicebus-emulator.container.image", String.class))
+ .withEnv("SQL_EDGE_IMAGE", config.getValue("azure-sql-edge.container.image", String.class))
+ .withEnv("CONFIG_FILE", configFile.getAbsolutePath())
+ .withEnv("MSSQL_SA_PASSWORD", "12345678923456y!43")
+ .withExposedService("emulator", 5672)
+ .withLocalCompose(true)
+ .withLogConsumer("emulator", new Slf4jLogConsumer(LOGGER))
+ .waitingFor("emulator", Wait.forLogMessage(".*Emulator Service is Successfully Up!.*", 1));
+
+ container.start();
+
+ String connectionString = "Endpoint=sb://%s:%d;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;"
+ .formatted(container.getServiceHost("emulator", 5672), container.getServicePort("emulator", 5672));
Review Comment:
I see what you mean now, I'll do it:)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Added azure-servicebus mock testing [camel-quarkus]
Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on code in PR #7082:
URL: https://github.com/apache/camel-quarkus/pull/7082#discussion_r1979432868
##########
integration-test-groups/azure/azure-servicebus/src/test/java/org/apache/camel/quarkus/component/azure/servicebus/it/AzureServiceBusTest.java:
##########
@@ -357,7 +366,10 @@ static Stream<Arguments> produceConsumeOptions() {
String[] payloadTypes = { String.class.getSimpleName(), byte[].class.getSimpleName(),
BinaryData.class.getSimpleName() };
- AmqpTransportType[] transportTypes = AmqpTransportType.values();
+ //in mocked backend, the AMQP_WEB_SOCKET is not supported, see https://github.com/Azure/azure-service-bus-emulator-installer/issues/51
+ AmqpTransportType[] transportTypes = Arrays.stream(AmqpTransportType.values())
+ .filter(type -> AzureServiceBusHelper.isMockBackEnd() && type != AmqpTransportType.AMQP_WEB_SOCKETS)
+ .toArray(AmqpTransportType[]::new);
Review Comment:
When testing against the real Azure service this results in an empty array. Maybe simplify to:
```suggestion
AmqpTransportType[] transportTypes;
if (AzureServiceBusHelper.isMockBackEnd()) {
transportTypes = new AmqpTransportType[] { AmqpTransportType.AMQP };
} else {
transportTypes = AmqpTransportType.values();
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org