Re: [PR] Added azure-servicebus mock testing [camel-quarkus]

2025-03-06 Thread via GitHub


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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] Added azure-servicebus mock testing [camel-quarkus]

2025-03-06 Thread via GitHub


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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] Added azure-servicebus mock testing [camel-quarkus]

2025-03-06 Thread via GitHub


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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] Added azure-servicebus mock testing [camel-quarkus]

2025-03-06 Thread via GitHub


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 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] Added azure-servicebus mock testing [camel-quarkus]

2025-03-04 Thread via GitHub


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 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] Added azure-servicebus mock testing [camel-quarkus]

2025-03-04 Thread via GitHub


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 initArgs = new LinkedHashMap<>();
+private ComposeContainer container;
+
+@Override
+public void init(Map initArgs) {
+this.initArgs = initArgs;
+}
+
+@Override
+public Map 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 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 

Re: [PR] Added azure-servicebus mock testing [camel-quarkus]

2025-03-04 Thread via GitHub


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 initArgs = new LinkedHashMap<>();
+private ComposeContainer container;
+
+@Override
+public void init(Map initArgs) {
+this.initArgs = initArgs;
+}
+
+@Override
+public Map 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 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 

Re: [PR] Added azure-servicebus mock testing [camel-quarkus]

2025-03-04 Thread via GitHub


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 initArgs = new LinkedHashMap<>();
+private ComposeContainer container;
+
+@Override
+public void init(Map initArgs) {
+this.initArgs = initArgs;
+}
+
+@Override
+public Map 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 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 

Re: [PR] Added azure-servicebus mock testing [camel-quarkus]

2025-03-04 Thread via GitHub


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 initArgs = new LinkedHashMap<>();
+private ComposeContainer container;
+
+@Override
+public void init(Map initArgs) {
+this.initArgs = initArgs;
+}
+
+@Override
+public Map 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 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 

Re: [PR] Added azure-servicebus mock testing [camel-quarkus]

2025-03-04 Thread via GitHub


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 initArgs = new LinkedHashMap<>();
+private ComposeContainer container;
+
+@Override
+public void init(Map initArgs) {
+this.initArgs = initArgs;
+}
+
+@Override
+public Map 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 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 

Re: [PR] Added azure-servicebus mock testing [camel-quarkus]

2025-03-04 Thread via GitHub


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 initArgs = new LinkedHashMap<>();
+private ComposeContainer container;
+
+@Override
+public void init(Map initArgs) {
+this.initArgs = initArgs;
+}
+
+@Override
+public Map 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 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,