This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new b72a3beb8950 CAMEL-26625: camel-google-bigquery - run the integration 
tests on Floci GCP (#30191)
b72a3beb8950 is described below

commit b72a3beb89506c731b7aa79589e673b3cb7fa1e4
Author: Andrea Cosentino <[email protected]>
AuthorDate: Tue Nov 17 11:18:06 2026 +0100

    CAMEL-26625: camel-google-bigquery - run the integration tests on Floci GCP 
(#30191)
    
    * CAMEL-26625: camel-google-bigquery - run the integration tests on Floci 
GCP
    * CAMEL-26625: pull the BigQuery engine image when the service starts, fail 
fast on test credentials without the remote mode, ignore a removal already in 
progress
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 .../apache/camel/catalog/test-infra/metadata.json  |  11 ++
 .../camel-google/camel-google-bigquery/pom.xml     |  11 ++
 .../google/bigquery/integration/AsyncIT.java       |   3 -
 .../bigquery/integration/BigQueryITSupport.java    |  74 ++++++++++---
 .../bigquery/integration/DynamicTableIdIT.java     |   3 -
 .../google/bigquery/integration/InsertIdIT.java    |   8 +-
 .../google/bigquery/integration/SingleRowIT.java   |   3 -
 .../integration/sql/SqlQueryFromResourceIT.java    |   3 -
 .../bigquery/integration/sql/SqlQueryIT.java       |   3 -
 .../integration/sql/SqlQuerySelectAndStreamIT.java |   3 -
 test-infra/camel-test-infra-all/pom.xml            |  11 ++
 .../src/generated/resources/META-INF/metadata.json |  11 ++
 .../azure/common/services/FlociAzContainer.java    |   6 +-
 .../camel-test-infra-google-bigquery/pom.xml       |  40 +++++++
 .../bigquery/common/GoogleBigQueryProperties.java} |  12 +--
 .../services/GoogleBigQueryInfraService.java}      |  22 ++--
 .../GoogleBigQueryLocalContainerInfraService.java  | 108 +++++++++++++++++++
 .../services/GoogleBigQueryRemoteInfraService.java |  53 +++++++++
 .../bigquery/services/GoogleBigQueryService.java}  |  16 ++-
 .../services/GoogleBigQueryServiceFactory.java     |  83 +++++++++++++++
 .../src/main/resources/META-INF/MANIFEST.MF        |   0
 .../test/infra/google/common/GoogleProperties.java |   4 +
 .../google/common/services/FlociGcpContainer.java  | 118 +++++++++++++++++++++
 .../google/common/services/container.properties    |   5 +
 test-infra/pom.xml                                 |   1 +
 25 files changed, 554 insertions(+), 58 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/test-infra/metadata.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/test-infra/metadata.json
index c7ce0cd56460..c4b75f5fdf8e 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/test-infra/metadata.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/test-infra/metadata.json
@@ -130,6 +130,17 @@
   "version" : "4.24.0-SNAPSHOT",
   "serviceVersion" : "v1.22.1",
   "uiSupported" : false
+}, {
+  "service" : 
"org.apache.camel.test.infra.google.bigquery.services.GoogleBigQueryInfraService",
+  "description" : "Local Google BigQuery service with Floci GCP",
+  "implementation" : 
"org.apache.camel.test.infra.google.bigquery.services.GoogleBigQueryLocalContainerInfraService",
+  "alias" : [ "google" ],
+  "aliasImplementation" : [ "bigquery" ],
+  "groupId" : "org.apache.camel",
+  "artifactId" : "camel-test-infra-google-bigquery",
+  "version" : "4.24.0-SNAPSHOT",
+  "serviceVersion" : "0.12.0",
+  "uiSupported" : false
 }, {
   "service" : 
"org.apache.camel.test.infra.aws.common.services.AWSInfraService",
   "description" : "Local AWS Services with LocalStack",
diff --git a/components/camel-google/camel-google-bigquery/pom.xml 
b/components/camel-google/camel-google-bigquery/pom.xml
index f62489e1f1ad..ee53deca8ee7 100644
--- a/components/camel-google/camel-google-bigquery/pom.xml
+++ b/components/camel-google/camel-google-bigquery/pom.xml
@@ -33,6 +33,9 @@
     <description>Camel Component for Google Cloud Platform 
BigQuery</description>
 
     <properties>
+        <!-- Floci GCP is not available for these -->
+        <skipITs.ppc64le>true</skipITs.ppc64le>
+        <skipITs.s390x>true</skipITs.s390x>
     </properties>
 
     <dependencies>
@@ -61,6 +64,14 @@
             <artifactId>camel-test-junit6</artifactId>
             <scope>test</scope>
         </dependency>
+
+        <!-- test infra -->
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test-infra-google-bigquery</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-core</artifactId>
diff --git 
a/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/AsyncIT.java
 
b/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/AsyncIT.java
index 94615fffee89..1878d9cf755b 100644
--- 
a/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/AsyncIT.java
+++ 
b/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/AsyncIT.java
@@ -34,10 +34,7 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.support.DefaultExchange;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledIf;
 
-@EnabledIf(value = 
"org.apache.camel.component.google.bigquery.integration.BigQueryITSupport#hasCredentials",
-           disabledReason = "Credentials were not provided")
 public class AsyncIT extends BigQueryITSupport {
     private static final String TABLE_ID = "asynctest";
 
diff --git 
a/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/BigQueryITSupport.java
 
b/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/BigQueryITSupport.java
index 674065ef068c..bb979c4864ac 100644
--- 
a/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/BigQueryITSupport.java
+++ 
b/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/BigQueryITSupport.java
@@ -22,7 +22,11 @@ import java.util.Properties;
 import java.util.UUID;
 import java.util.stream.Collectors;
 
+import com.google.cloud.NoCredentials;
 import com.google.cloud.bigquery.BigQueryException;
+import com.google.cloud.bigquery.BigQueryOptions;
+import com.google.cloud.bigquery.DatasetId;
+import com.google.cloud.bigquery.DatasetInfo;
 import com.google.cloud.bigquery.Field;
 import com.google.cloud.bigquery.FieldList;
 import com.google.cloud.bigquery.JobId;
@@ -41,14 +45,25 @@ import 
org.apache.camel.component.google.bigquery.GoogleBigQueryConfiguration;
 import 
org.apache.camel.component.google.bigquery.GoogleBigQueryConnectionFactory;
 import 
org.apache.camel.component.google.bigquery.sql.GoogleBigQuerySQLComponent;
 import 
org.apache.camel.component.google.bigquery.sql.GoogleBigQuerySQLConfiguration;
+import 
org.apache.camel.test.infra.google.bigquery.services.GoogleBigQueryService;
+import 
org.apache.camel.test.infra.google.bigquery.services.GoogleBigQueryServiceFactory;
 import org.apache.camel.test.junit6.CamelTestSupport;
 import org.apache.camel.test.junit6.TestSupport;
+import org.junit.jupiter.api.extension.RegisterExtension;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
+/**
+ * Runs the integration tests against the BigQuery of Floci GCP, or with 
{@code -Dgoogle.instance.type=remote} against
+ * the one of Google Cloud, with the credentials of {@code simple.properties}. 
Either way, the tests take the project
+ * and the dataset of {@code simple.properties}: Floci GCP accepts any project 
id.
+ */
 public class BigQueryITSupport extends CamelTestSupport {
+    @RegisterExtension
+    public static GoogleBigQueryService service = 
GoogleBigQueryServiceFactory.createSingletonService();
+
     public static final String SERVICE_KEY;
     public static final String SERVICE_ACCOUNT;
     public static final String PROJECT_ID;
@@ -72,20 +87,11 @@ public class BigQueryITSupport extends CamelTestSupport {
         return 
TestSupport.loadExternalPropertiesQuietly(BigQueryITSupport.class.getClassLoader(),
 "simple.properties");
     }
 
-    // This is used by JUnit to to dynamically enable / disable the 
integration tests
-    @SuppressWarnings("unused")
-    private static boolean hasCredentials() {
-        return SERVICE_KEY != null && SERVICE_ACCOUNT != null || 
CREDENTIALS_FILE_LOCATION != null;
-    }
-
     protected void addBigqueryComponent(CamelContext context) {
 
         GoogleBigQueryConfiguration configuration = new 
GoogleBigQueryConfiguration()
                 .setServiceAccountKey(CREDENTIALS_FILE_LOCATION);
 
-        connectionFactory = new GoogleBigQueryConnectionFactory()
-                .setServiceAccountKeyFile(configuration.getServiceAccountKey())
-                .setCamelContext(context);
         configuration.setConnectionFactory(connectionFactory);
 
         GoogleBigQueryComponent component = new 
GoogleBigQueryComponent(configuration);
@@ -99,9 +105,6 @@ public class BigQueryITSupport extends CamelTestSupport {
 
         GoogleBigQuerySQLConfiguration configuration = new 
GoogleBigQuerySQLConfiguration()
                 .setServiceAccountKey(CREDENTIALS_FILE_LOCATION);
-        connectionFactory = new GoogleBigQueryConnectionFactory()
-                .setServiceAccountKeyFile(configuration.getServiceAccountKey())
-                .setCamelContext(context);
         configuration.setConnectionFactory(connectionFactory);
 
         GoogleBigQuerySQLComponent component = new 
GoogleBigQuerySQLComponent(configuration);
@@ -114,11 +117,58 @@ public class BigQueryITSupport extends CamelTestSupport {
     @Override
     protected CamelContext createCamelContext() throws Exception {
         CamelContext context = super.createCamelContext();
+        connectionFactory = createConnectionFactory(context);
         addBigqueryComponent(context);
         addBigquerySqlComponent(context);
+        if (!isRemote()) {
+            createLocalDataset();
+        }
         return context;
     }
 
+    // the BigQuery of Google Cloud with -Dgoogle.instance.type=remote, and 
the one of Floci GCP otherwise
+    private static boolean isRemote() {
+        return "remote".equals(System.getProperty("google.instance.type"));
+    }
+
+    // the credentials that ran the tests against a real project, before they 
ran on Floci GCP
+    private static boolean hasCredentials() {
+        return SERVICE_KEY != null && SERVICE_ACCOUNT != null || 
CREDENTIALS_FILE_LOCATION != null;
+    }
+
+    private static GoogleBigQueryConnectionFactory 
createConnectionFactory(CamelContext context) {
+        if (isRemote()) {
+            return new GoogleBigQueryConnectionFactory()
+                    .setServiceAccountKeyFile(CREDENTIALS_FILE_LOCATION)
+                    .setCamelContext(context);
+        }
+        // so that a run on Floci GCP is not taken for one against the project 
of the credentials
+        if (hasCredentials()) {
+            throw new IllegalStateException(
+                    "simple.properties gives credentials: add 
-Dgoogle.instance.type=remote to run the tests against"
+                                            + " the BigQuery of that project");
+        }
+        // Floci GCP accepts any credentials: the client of the factory would 
take the application default ones
+        return new GoogleBigQueryConnectionFactory(
+                BigQueryOptions.newBuilder()
+                        .setHost(service.endpoint())
+                        .setProjectId(PROJECT_ID)
+                        .setCredentials(NoCredentials.getInstance())
+                        .build()
+                        .getService());
+    }
+
+    // the project of Google Cloud has the dataset of the tests, Floci GCP 
starts without it
+    private void createLocalDataset() throws Exception {
+        try {
+            
getConnectionFactory().getDefaultClient().create(DatasetInfo.of(DatasetId.of(PROJECT_ID,
 DATASET_ID)));
+        } catch (BigQueryException e) {
+            if (e.getCode() != 409) {
+                throw e;
+            }
+        }
+    }
+
     @BindToRegistry("prop")
     public Properties loadRegProperties() throws IOException {
         return loadProperties();
diff --git 
a/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/DynamicTableIdIT.java
 
b/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/DynamicTableIdIT.java
index 459cf8e2a1f6..5aef88702b1f 100644
--- 
a/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/DynamicTableIdIT.java
+++ 
b/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/DynamicTableIdIT.java
@@ -31,10 +31,7 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.support.DefaultExchange;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledIf;
 
-@EnabledIf(value = 
"org.apache.camel.component.google.bigquery.integration.BigQueryITSupport#hasCredentials",
-           disabledReason = "Credentials were not provided")
 public class DynamicTableIdIT extends BigQueryITSupport {
     private static final String TABLE_ID_1 = "dynamic_table_1";
     private static final String TABLE_ID_2 = "dynamic_table_2";
diff --git 
a/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/InsertIdIT.java
 
b/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/InsertIdIT.java
index 3383e8ee2abf..eac5f0d815a2 100644
--- 
a/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/InsertIdIT.java
+++ 
b/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/InsertIdIT.java
@@ -31,10 +31,12 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.support.DefaultExchange;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledIf;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
 
-@EnabledIf(value = 
"org.apache.camel.component.google.bigquery.integration.BigQueryITSupport#hasCredentials",
-           disabledReason = "Credentials were not provided")
+// Floci GCP inserts every row of tabledata.insertAll: it does not drop the 
ones of an insertId already seen, as BigQuery
+// does on a best-effort basis
+@EnabledIfSystemProperty(named = "google.instance.type", matches = "remote",
+                         disabledReason = "Floci GCP does not de-duplicate the 
rows of tabledata.insertAll by insertId")
 public class InsertIdIT extends BigQueryITSupport {
     private static final String TABLE_ID = "insertId";
 
diff --git 
a/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/SingleRowIT.java
 
b/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/SingleRowIT.java
index 3eb8be3f40c3..f5db4f45fed8 100644
--- 
a/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/SingleRowIT.java
+++ 
b/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/SingleRowIT.java
@@ -30,10 +30,7 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.support.DefaultExchange;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledIf;
 
-@EnabledIf(value = 
"org.apache.camel.component.google.bigquery.integration.BigQueryITSupport#hasCredentials",
-           disabledReason = "Credentials were not provided")
 public class SingleRowIT extends BigQueryITSupport {
     private static final String TABLE_ID = "singlerow";
 
diff --git 
a/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/sql/SqlQueryFromResourceIT.java
 
b/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/sql/SqlQueryFromResourceIT.java
index b732ce823124..fa2e16d66bc4 100644
--- 
a/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/sql/SqlQueryFromResourceIT.java
+++ 
b/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/sql/SqlQueryFromResourceIT.java
@@ -31,10 +31,7 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.support.DefaultExchange;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledIf;
 
-@EnabledIf(value = 
"org.apache.camel.component.google.bigquery.integration.BigQueryITSupport#hasCredentials",
-           disabledReason = "Credentials were not provided")
 public class SqlQueryFromResourceIT extends BigQueryITSupport {
     private static final String TABLE_ID = "test_sql_table";
 
diff --git 
a/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/sql/SqlQueryIT.java
 
b/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/sql/SqlQueryIT.java
index aba3c36997dc..e0f3fd8f2a4f 100644
--- 
a/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/sql/SqlQueryIT.java
+++ 
b/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/sql/SqlQueryIT.java
@@ -31,10 +31,7 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.support.DefaultExchange;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledIf;
 
-@EnabledIf(value = 
"org.apache.camel.component.google.bigquery.integration.BigQueryITSupport#hasCredentials",
-           disabledReason = "Credentials were not provided")
 public class SqlQueryIT extends BigQueryITSupport {
     private static final String TABLE_ID = "test_sql_table";
 
diff --git 
a/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/sql/SqlQuerySelectAndStreamIT.java
 
b/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/sql/SqlQuerySelectAndStreamIT.java
index fc22c0bbbf8e..fba19877489c 100644
--- 
a/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/sql/SqlQuerySelectAndStreamIT.java
+++ 
b/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/sql/SqlQuerySelectAndStreamIT.java
@@ -29,7 +29,6 @@ import 
org.apache.camel.component.google.bigquery.integration.BigQueryITSupport;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.TestInstance;
-import org.junit.jupiter.api.condition.EnabledIf;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.InstanceOfAssertFactories.LIST;
@@ -38,8 +37,6 @@ import static 
org.assertj.core.api.InstanceOfAssertFactories.iterator;
 import static org.assertj.core.api.InstanceOfAssertFactories.list;
 import static org.assertj.core.api.InstanceOfAssertFactories.map;
 
-@EnabledIf(value = 
"org.apache.camel.component.google.bigquery.integration.BigQueryITSupport#hasCredentials",
-           disabledReason = "Credentials were not provided")
 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
 public class SqlQuerySelectAndStreamIT extends BigQueryITSupport {
 
diff --git a/test-infra/camel-test-infra-all/pom.xml 
b/test-infra/camel-test-infra-all/pom.xml
index c4a54c5787d5..c6ca9bd42dac 100644
--- a/test-infra/camel-test-infra-all/pom.xml
+++ b/test-infra/camel-test-infra-all/pom.xml
@@ -136,6 +136,11 @@
             <artifactId>camel-test-infra-arangodb</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test-infra-google-bigquery</artifactId>
+            <version>${project.version}</version>
+        </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-test-infra-google-firestore</artifactId>
@@ -523,6 +528,12 @@
                                         
<artifactId>camel-test-infra-artemis</artifactId>
                                     </dependency>
                                 </fileSet>
+                                <fileSet>
+                                    <dependency>
+                                        <groupId>org.apache.camel</groupId>
+                                        
<artifactId>camel-test-infra-google-bigquery</artifactId>
+                                    </dependency>
+                                </fileSet>
                                 <fileSet>
                                     <dependency>
                                         <groupId>org.apache.camel</groupId>
diff --git 
a/test-infra/camel-test-infra-all/src/generated/resources/META-INF/metadata.json
 
b/test-infra/camel-test-infra-all/src/generated/resources/META-INF/metadata.json
index c7ce0cd56460..c4b75f5fdf8e 100644
--- 
a/test-infra/camel-test-infra-all/src/generated/resources/META-INF/metadata.json
+++ 
b/test-infra/camel-test-infra-all/src/generated/resources/META-INF/metadata.json
@@ -130,6 +130,17 @@
   "version" : "4.24.0-SNAPSHOT",
   "serviceVersion" : "v1.22.1",
   "uiSupported" : false
+}, {
+  "service" : 
"org.apache.camel.test.infra.google.bigquery.services.GoogleBigQueryInfraService",
+  "description" : "Local Google BigQuery service with Floci GCP",
+  "implementation" : 
"org.apache.camel.test.infra.google.bigquery.services.GoogleBigQueryLocalContainerInfraService",
+  "alias" : [ "google" ],
+  "aliasImplementation" : [ "bigquery" ],
+  "groupId" : "org.apache.camel",
+  "artifactId" : "camel-test-infra-google-bigquery",
+  "version" : "4.24.0-SNAPSHOT",
+  "serviceVersion" : "0.12.0",
+  "uiSupported" : false
 }, {
   "service" : 
"org.apache.camel.test.infra.aws.common.services.AWSInfraService",
   "description" : "Local AWS Services with LocalStack",
diff --git 
a/test-infra/camel-test-infra-azure-common/src/main/java/org/apache/camel/test/infra/azure/common/services/FlociAzContainer.java
 
b/test-infra/camel-test-infra-azure-common/src/main/java/org/apache/camel/test/infra/azure/common/services/FlociAzContainer.java
index 76839acdf508..63468bdbf107 100644
--- 
a/test-infra/camel-test-infra-azure-common/src/main/java/org/apache/camel/test/infra/azure/common/services/FlociAzContainer.java
+++ 
b/test-infra/camel-test-infra-azure-common/src/main/java/org/apache/camel/test/infra/azure/common/services/FlociAzContainer.java
@@ -26,6 +26,7 @@ import java.util.UUID;
 
 import com.github.dockerjava.api.DockerClient;
 import com.github.dockerjava.api.command.CreateContainerCmd;
+import com.github.dockerjava.api.exception.ConflictException;
 import com.github.dockerjava.api.exception.NotFoundException;
 import com.github.dockerjava.api.model.Bind;
 import com.github.dockerjava.api.model.Container;
@@ -165,8 +166,9 @@ public class FlociAzContainer extends 
GenericContainer<FlociAzContainer> {
             LOG.debug("Removing the container {} that Floci AZ started", 
Arrays.toString(container.getNames()));
             try {
                 
client.removeContainerCmd(container.getId()).withForce(true).withRemoveVolumes(true).exec();
-            } catch (NotFoundException e) {
-                LOG.debug("The container {} was already removed", 
container.getId());
+            } catch (NotFoundException | ConflictException e) {
+                // another stop, such as the one of a shutdown hook, removed 
it or is removing it
+                LOG.debug("The container {} was already removed, or is being 
removed", container.getId());
             }
         }
     }
diff --git a/test-infra/camel-test-infra-google-bigquery/pom.xml 
b/test-infra/camel-test-infra-google-bigquery/pom.xml
new file mode 100644
index 000000000000..1fc236b0634d
--- /dev/null
+++ b/test-infra/camel-test-infra-google-bigquery/pom.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <parent>
+        <artifactId>camel-test-infra-parent</artifactId>
+        <groupId>org.apache.camel</groupId>
+        <relativePath>../camel-test-infra-parent/pom.xml</relativePath>
+        <version>4.24.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <name>Camel :: Test Infra :: Google BigQuery</name>
+    <artifactId>camel-test-infra-google-bigquery</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test-infra-google-common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
+</project>
diff --git 
a/test-infra/camel-test-infra-google-common/src/main/java/org/apache/camel/test/infra/google/common/GoogleProperties.java
 
b/test-infra/camel-test-infra-google-bigquery/src/main/java/org/apache/camel/test/infra/google/bigquery/common/GoogleBigQueryProperties.java
similarity index 73%
copy from 
test-infra/camel-test-infra-google-common/src/main/java/org/apache/camel/test/infra/google/common/GoogleProperties.java
copy to 
test-infra/camel-test-infra-google-bigquery/src/main/java/org/apache/camel/test/infra/google/bigquery/common/GoogleBigQueryProperties.java
index 3a21641a8ec5..3cb4d45f0161 100644
--- 
a/test-infra/camel-test-infra-google-common/src/main/java/org/apache/camel/test/infra/google/common/GoogleProperties.java
+++ 
b/test-infra/camel-test-infra-google-bigquery/src/main/java/org/apache/camel/test/infra/google/bigquery/common/GoogleBigQueryProperties.java
@@ -15,15 +15,13 @@
  * limitations under the License.
  */
 
-package org.apache.camel.test.infra.google.common;
+package org.apache.camel.test.infra.google.bigquery.common;
 
-public final class GoogleProperties {
-    /**
-     * The image of Floci GCP, which runs the local Google Cloud services
-     */
-    public static final String GOOGLE_CONTAINER = "google.container";
+public final class GoogleBigQueryProperties {
+    public static final String PROJECT_ID = "google.bigquery.project.id";
+    public static final String ENDPOINT = "google.bigquery.endpoint";
 
-    private GoogleProperties() {
+    private GoogleBigQueryProperties() {
 
     }
 }
diff --git 
a/test-infra/camel-test-infra-google-common/src/main/java/org/apache/camel/test/infra/google/common/GoogleProperties.java
 
b/test-infra/camel-test-infra-google-bigquery/src/main/java/org/apache/camel/test/infra/google/bigquery/services/GoogleBigQueryInfraService.java
similarity index 59%
copy from 
test-infra/camel-test-infra-google-common/src/main/java/org/apache/camel/test/infra/google/common/GoogleProperties.java
copy to 
test-infra/camel-test-infra-google-bigquery/src/main/java/org/apache/camel/test/infra/google/bigquery/services/GoogleBigQueryInfraService.java
index 3a21641a8ec5..334e3d14d3b1 100644
--- 
a/test-infra/camel-test-infra-google-common/src/main/java/org/apache/camel/test/infra/google/common/GoogleProperties.java
+++ 
b/test-infra/camel-test-infra-google-bigquery/src/main/java/org/apache/camel/test/infra/google/bigquery/services/GoogleBigQueryInfraService.java
@@ -15,15 +15,23 @@
  * limitations under the License.
  */
 
-package org.apache.camel.test.infra.google.common;
+package org.apache.camel.test.infra.google.bigquery.services;
+
+import org.apache.camel.test.infra.common.services.InfrastructureService;
+
+/**
+ * A BigQuery service: the one of Floci GCP, or the one of a real Google Cloud 
project.
+ */
+public interface GoogleBigQueryInfraService extends InfrastructureService {
 
-public final class GoogleProperties {
     /**
-     * The image of Floci GCP, which runs the local Google Cloud services
+     * The id of the project
      */
-    public static final String GOOGLE_CONTAINER = "google.container";
+    String projectId();
 
-    private GoogleProperties() {
-
-    }
+    /**
+     * The address of the BigQuery API, for example {@code 
http://localhost:32768} for Floci GCP or
+     * {@code https://bigquery.googleapis.com} for Google Cloud
+     */
+    String endpoint();
 }
diff --git 
a/test-infra/camel-test-infra-google-bigquery/src/main/java/org/apache/camel/test/infra/google/bigquery/services/GoogleBigQueryLocalContainerInfraService.java
 
b/test-infra/camel-test-infra-google-bigquery/src/main/java/org/apache/camel/test/infra/google/bigquery/services/GoogleBigQueryLocalContainerInfraService.java
new file mode 100644
index 000000000000..ef1ef70762e0
--- /dev/null
+++ 
b/test-infra/camel-test-infra-google-bigquery/src/main/java/org/apache/camel/test/infra/google/bigquery/services/GoogleBigQueryLocalContainerInfraService.java
@@ -0,0 +1,108 @@
+/*
+ * 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.test.infra.google.bigquery.services;
+
+import org.apache.camel.spi.annotations.InfraService;
+import org.apache.camel.test.infra.common.LocalPropertyResolver;
+import org.apache.camel.test.infra.common.services.ContainerEnvironmentUtil;
+import org.apache.camel.test.infra.common.services.ContainerService;
+import 
org.apache.camel.test.infra.google.bigquery.common.GoogleBigQueryProperties;
+import org.apache.camel.test.infra.google.common.GoogleProperties;
+import org.apache.camel.test.infra.google.common.services.FlociGcpContainer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A local BigQuery service on Floci GCP, which runs the queries on 
floci-duck, a SQL engine that it starts as a
+ * container of its own through the Docker socket. Floci GCP accepts any 
credentials, and gives an access token to a
+ * service account of any key at {@code <endpoint>/token}.
+ */
+@InfraService(service = GoogleBigQueryInfraService.class,
+              description = "Local Google BigQuery service with Floci GCP",
+              serviceAlias = "google", serviceImplementationAlias = "bigquery")
+public class GoogleBigQueryLocalContainerInfraService
+        implements GoogleBigQueryInfraService, 
ContainerService<FlociGcpContainer> {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(GoogleBigQueryLocalContainerInfraService.class);
+    private static final String DEFAULT_PROJECT_ID = "test-project";
+
+    private final FlociGcpContainer container;
+
+    public GoogleBigQueryLocalContainerInfraService() {
+        this(LocalPropertyResolver.getProperty(FlociGcpContainer.class, 
GoogleProperties.GOOGLE_CONTAINER));
+    }
+
+    public GoogleBigQueryLocalContainerInfraService(String imageName) {
+        container = initContainer(imageName);
+        String name = ContainerEnvironmentUtil.containerName(this.getClass());
+        if (name != null) {
+            container.withCreateContainerCmdModifier(cmd -> 
cmd.withName(name));
+        }
+    }
+
+    public GoogleBigQueryLocalContainerInfraService(FlociGcpContainer 
container) {
+        this.container = container;
+    }
+
+    protected FlociGcpContainer initContainer(String imageName) {
+        return new FlociGcpContainer(imageName, 
ContainerEnvironmentUtil.isFixedPort(this.getClass()))
+                .withDockerSocket();
+    }
+
+    @Override
+    public void registerProperties() {
+        System.setProperty(GoogleBigQueryProperties.PROJECT_ID, projectId());
+        System.setProperty(GoogleBigQueryProperties.ENDPOINT, endpoint());
+    }
+
+    @Override
+    public void initialize() {
+        // here, and not in the constructor: it pulls the image, so it needs 
Docker, which the tests check for only
+        // after building the service
+        container.withBigQueryEngine();
+        container.start();
+
+        LOG.info("Floci GCP running at address {}", 
container.serviceAddress());
+
+        registerProperties();
+    }
+
+    @Override
+    public void shutdown() {
+        container.stop();
+    }
+
+    @Override
+    public FlociGcpContainer getContainer() {
+        return container;
+    }
+
+    /**
+     * The id of the project, {@code test-project} unless the {@code 
google.bigquery.project.id} system property gives
+     * another one: Floci GCP accepts any
+     */
+    @Override
+    public String projectId() {
+        return System.getProperty(GoogleBigQueryProperties.PROJECT_ID, 
DEFAULT_PROJECT_ID);
+    }
+
+    @Override
+    public String endpoint() {
+        return container.serviceAddress();
+    }
+}
diff --git 
a/test-infra/camel-test-infra-google-bigquery/src/main/java/org/apache/camel/test/infra/google/bigquery/services/GoogleBigQueryRemoteInfraService.java
 
b/test-infra/camel-test-infra-google-bigquery/src/main/java/org/apache/camel/test/infra/google/bigquery/services/GoogleBigQueryRemoteInfraService.java
new file mode 100644
index 000000000000..1eb60e8c8c09
--- /dev/null
+++ 
b/test-infra/camel-test-infra-google-bigquery/src/main/java/org/apache/camel/test/infra/google/bigquery/services/GoogleBigQueryRemoteInfraService.java
@@ -0,0 +1,53 @@
+/*
+ * 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.test.infra.google.bigquery.services;
+
+import 
org.apache.camel.test.infra.google.bigquery.common.GoogleBigQueryProperties;
+
+/**
+ * The BigQuery service of a real Google Cloud project, the one of the {@code 
google.bigquery.project.id} system
+ * property.
+ */
+public class GoogleBigQueryRemoteInfraService implements 
GoogleBigQueryInfraService {
+    private static final String DEFAULT_ENDPOINT = 
"https://bigquery.googleapis.com";;
+
+    @Override
+    public void registerProperties() {
+        // NO-OP
+    }
+
+    @Override
+    public void initialize() {
+        registerProperties();
+    }
+
+    @Override
+    public void shutdown() {
+        // NO-OP
+    }
+
+    @Override
+    public String projectId() {
+        return System.getProperty(GoogleBigQueryProperties.PROJECT_ID);
+    }
+
+    @Override
+    public String endpoint() {
+        return System.getProperty(GoogleBigQueryProperties.ENDPOINT, 
DEFAULT_ENDPOINT);
+    }
+}
diff --git 
a/test-infra/camel-test-infra-google-common/src/main/java/org/apache/camel/test/infra/google/common/GoogleProperties.java
 
b/test-infra/camel-test-infra-google-bigquery/src/main/java/org/apache/camel/test/infra/google/bigquery/services/GoogleBigQueryService.java
similarity index 69%
copy from 
test-infra/camel-test-infra-google-common/src/main/java/org/apache/camel/test/infra/google/common/GoogleProperties.java
copy to 
test-infra/camel-test-infra-google-bigquery/src/main/java/org/apache/camel/test/infra/google/bigquery/services/GoogleBigQueryService.java
index 3a21641a8ec5..23e3b8470d68 100644
--- 
a/test-infra/camel-test-infra-google-common/src/main/java/org/apache/camel/test/infra/google/common/GoogleProperties.java
+++ 
b/test-infra/camel-test-infra-google-bigquery/src/main/java/org/apache/camel/test/infra/google/bigquery/services/GoogleBigQueryService.java
@@ -15,15 +15,13 @@
  * limitations under the License.
  */
 
-package org.apache.camel.test.infra.google.common;
+package org.apache.camel.test.infra.google.bigquery.services;
 
-public final class GoogleProperties {
-    /**
-     * The image of Floci GCP, which runs the local Google Cloud services
-     */
-    public static final String GOOGLE_CONTAINER = "google.container";
+import org.apache.camel.test.infra.common.services.ContainerTestService;
+import org.apache.camel.test.infra.common.services.TestService;
 
-    private GoogleProperties() {
-
-    }
+/**
+ * Test infra service for Google BigQuery
+ */
+public interface GoogleBigQueryService extends GoogleBigQueryInfraService, 
TestService, ContainerTestService {
 }
diff --git 
a/test-infra/camel-test-infra-google-bigquery/src/main/java/org/apache/camel/test/infra/google/bigquery/services/GoogleBigQueryServiceFactory.java
 
b/test-infra/camel-test-infra-google-bigquery/src/main/java/org/apache/camel/test/infra/google/bigquery/services/GoogleBigQueryServiceFactory.java
new file mode 100644
index 000000000000..eb93eb300ef1
--- /dev/null
+++ 
b/test-infra/camel-test-infra-google-bigquery/src/main/java/org/apache/camel/test/infra/google/bigquery/services/GoogleBigQueryServiceFactory.java
@@ -0,0 +1,83 @@
+/*
+ * 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.test.infra.google.bigquery.services;
+
+import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder;
+import org.apache.camel.test.infra.common.services.SingletonService;
+
+/**
+ * Creates the BigQuery service of Floci GCP, or with {@code 
-Dgoogle.instance.type=remote} the one of a real Google
+ * Cloud project.
+ */
+public final class GoogleBigQueryServiceFactory {
+
+    private static class SingletonGoogleBigQueryService extends 
SingletonService<GoogleBigQueryService>
+            implements GoogleBigQueryService {
+        public SingletonGoogleBigQueryService(GoogleBigQueryService service, 
String name) {
+            super(service, name);
+        }
+
+        @Override
+        public String projectId() {
+            return getService().projectId();
+        }
+
+        @Override
+        public String endpoint() {
+            return getService().endpoint();
+        }
+    }
+
+    private GoogleBigQueryServiceFactory() {
+
+    }
+
+    public static SimpleTestServiceBuilder<GoogleBigQueryService> builder() {
+        return new SimpleTestServiceBuilder<>("google");
+    }
+
+    public static GoogleBigQueryService createService() {
+        return builder()
+                .addLocalMapping(GoogleBigQueryLocalContainerService::new)
+                .addRemoteMapping(GoogleBigQueryRemoteService::new)
+                .build();
+    }
+
+    public static GoogleBigQueryService createSingletonService() {
+        return SingletonServiceHolder.INSTANCE;
+    }
+
+    private static class SingletonServiceHolder {
+        static final GoogleBigQueryService INSTANCE;
+        static {
+            SimpleTestServiceBuilder<GoogleBigQueryService> instance = 
builder();
+            // a name of its own: the singleton of another Google service of 
the same JVM must not stand for this one
+            instance.addLocalMapping(
+                    () -> new SingletonGoogleBigQueryService(new 
GoogleBigQueryLocalContainerService(), "google-bigquery"))
+                    .addRemoteMapping(GoogleBigQueryRemoteService::new);
+            INSTANCE = instance.build();
+        }
+    }
+
+    static class GoogleBigQueryLocalContainerService extends 
GoogleBigQueryLocalContainerInfraService
+            implements GoogleBigQueryService {
+    }
+
+    static class GoogleBigQueryRemoteService extends 
GoogleBigQueryRemoteInfraService implements GoogleBigQueryService {
+    }
+}
diff --git 
a/test-infra/camel-test-infra-google-bigquery/src/main/resources/META-INF/MANIFEST.MF
 
b/test-infra/camel-test-infra-google-bigquery/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git 
a/test-infra/camel-test-infra-google-common/src/main/java/org/apache/camel/test/infra/google/common/GoogleProperties.java
 
b/test-infra/camel-test-infra-google-common/src/main/java/org/apache/camel/test/infra/google/common/GoogleProperties.java
index 3a21641a8ec5..73136d3185a8 100644
--- 
a/test-infra/camel-test-infra-google-common/src/main/java/org/apache/camel/test/infra/google/common/GoogleProperties.java
+++ 
b/test-infra/camel-test-infra-google-common/src/main/java/org/apache/camel/test/infra/google/common/GoogleProperties.java
@@ -22,6 +22,10 @@ public final class GoogleProperties {
      * The image of Floci GCP, which runs the local Google Cloud services
      */
     public static final String GOOGLE_CONTAINER = "google.container";
+    /**
+     * The image of floci-duck, the SQL engine that Floci GCP starts for the 
queries of BigQuery
+     */
+    public static final String BIGQUERY_ENGINE_CONTAINER = 
"google.bigquery.engine.container";
 
     private GoogleProperties() {
 
diff --git 
a/test-infra/camel-test-infra-google-common/src/main/java/org/apache/camel/test/infra/google/common/services/FlociGcpContainer.java
 
b/test-infra/camel-test-infra-google-common/src/main/java/org/apache/camel/test/infra/google/common/services/FlociGcpContainer.java
index 9b4dfa597aad..38f8d7bc9ced 100644
--- 
a/test-infra/camel-test-infra-google-common/src/main/java/org/apache/camel/test/infra/google/common/services/FlociGcpContainer.java
+++ 
b/test-infra/camel-test-infra-google-common/src/main/java/org/apache/camel/test/infra/google/common/services/FlociGcpContainer.java
@@ -18,10 +18,31 @@
 package org.apache.camel.test.infra.google.common.services;
 
 import java.time.Duration;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
 
+import com.github.dockerjava.api.DockerClient;
+import com.github.dockerjava.api.command.CreateContainerCmd;
+import com.github.dockerjava.api.exception.ConflictException;
+import com.github.dockerjava.api.exception.NotFoundException;
+import com.github.dockerjava.api.model.Bind;
+import com.github.dockerjava.api.model.Container;
+import com.github.dockerjava.api.model.HostConfig;
+import com.github.dockerjava.api.model.Volume;
+import org.apache.camel.test.infra.common.LocalPropertyResolver;
 import org.apache.camel.test.infra.common.services.ContainerEnvironmentUtil;
+import org.apache.camel.test.infra.google.common.GoogleProperties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.DockerClientFactory;
 import org.testcontainers.containers.GenericContainer;
 import org.testcontainers.containers.wait.strategy.Wait;
+import org.testcontainers.images.RemoteDockerImage;
+import org.testcontainers.utility.DockerImageName;
+import org.testcontainers.utility.ResourceReaper;
 
 /**
  * A container running Floci GCP (https://github.com/floci-io/floci-gcp), a 
local Google Cloud emulator. It serves the
@@ -30,6 +51,15 @@ import org.testcontainers.containers.wait.strategy.Wait;
 public class FlociGcpContainer extends GenericContainer<FlociGcpContainer> {
     public static final int SERVICE_PORT = 4588;
 
+    private static final Logger LOG = 
LoggerFactory.getLogger(FlociGcpContainer.class);
+    // Floci GCP puts this namespace in the name of the containers it starts, 
and in their floci_namespace label
+    private static final String RESOURCE_NAMESPACE_ENV = 
"FLOCI_GCP_DOCKER_RESOURCE_NAMESPACE";
+    private static final String RESOURCE_NAMESPACE_LABEL = "floci_namespace";
+    private static final String DOCKER_SOCKET = "/var/run/docker.sock";
+    private static final String BIGQUERY_ENGINE_IMAGE_ENV = 
"FLOCI_GCP_SERVICES_BIGQUERY_DUCK_DEFAULT_IMAGE";
+
+    private String resourceNamespace;
+
     public FlociGcpContainer(String imageName, boolean fixedPort) {
         super(imageName);
 
@@ -55,4 +85,92 @@ public class FlociGcpContainer extends 
GenericContainer<FlociGcpContainer> {
     public String grpcAddress() {
         return String.format("%s:%d", getHost(), getMappedPort(SERVICE_PORT));
     }
+
+    /**
+     * Lets Floci GCP start containers of its own, such as the SQL engine of 
BigQuery: mounts the Docker socket of the
+     * host, and gives the containers that Floci GCP starts a resource 
namespace of this container, by which
+     * {@link #stop()} removes them. Each container has a namespace of its 
own: when it starts, Floci GCP removes the
+     * containers of its namespace that it finds, as left over.
+     */
+    public FlociGcpContainer withDockerSocket() {
+        resourceNamespace = "camel" + 
UUID.randomUUID().toString().replace("-", "").substring(0, 12);
+        withEnv(RESOURCE_NAMESPACE_ENV, resourceNamespace);
+        return 
withCreateContainerCmdModifier(FlociGcpContainer::bindDockerSocket);
+    }
+
+    /**
+     * Has Floci GCP run the queries of BigQuery on the floci-duck image of
+     * {@link GoogleProperties#BIGQUERY_ENGINE_CONTAINER}, which this method 
pulls as Testcontainers pulls its own
+     * images, so that image substitution and registry authentication apply: 
Floci GCP would pull it itself otherwise.
+     * Needs {@link #withDockerSocket()}.
+     */
+    public FlociGcpContainer withBigQueryEngine() {
+        if (resourceNamespace == null) {
+            throw new IllegalStateException(
+                    "withDockerSocket() must come before withBigQueryEngine(): 
Floci GCP starts the engine through the"
+                                            + " Docker socket");
+        }
+        String image = 
LocalPropertyResolver.getProperty(FlociGcpContainer.class,
+                GoogleProperties.BIGQUERY_ENGINE_CONTAINER);
+        return withEnv(BIGQUERY_ENGINE_IMAGE_ENV, new 
RemoteDockerImage(DockerImageName.parse(image)).get());
+    }
+
+    @Override
+    public void start() {
+        if (resourceNamespace != null) {
+            // Testcontainers does not know the containers that Floci GCP 
starts: have them removed when the JVM exits,
+            // should this container not be stopped
+            
ResourceReaper.instance().registerLabelsFilterForCleanup(Map.of(RESOURCE_NAMESPACE_LABEL,
 resourceNamespace));
+        }
+        super.start();
+    }
+
+    @Override
+    public void stop() {
+        try {
+            super.stop();
+        } finally {
+            if (resourceNamespace != null) {
+                removeStartedContainers();
+            }
+        }
+    }
+
+    // the containers that Floci GCP started are not removed with it
+    private void removeStartedContainers() {
+        DockerClient client = DockerClientFactory.instance().client();
+        List<Container> containers = client.listContainersCmd()
+                .withShowAll(true)
+                .withLabelFilter(Map.of(RESOURCE_NAMESPACE_LABEL, 
resourceNamespace))
+                .exec();
+        for (Container container : containers) {
+            LOG.debug("Removing the container {} that Floci GCP started", 
Arrays.toString(container.getNames()));
+            try {
+                
client.removeContainerCmd(container.getId()).withForce(true).withRemoveVolumes(true).exec();
+            } catch (NotFoundException | ConflictException e) {
+                // another stop, such as the one of a shutdown hook, removed 
it or is removing it
+                LOG.debug("The container {} was already removed, or is being 
removed", container.getId());
+            }
+        }
+    }
+
+    // where SELinux is enforcing, it denies a container the Docker socket of 
the host unless the labeling of the
+    // container is disabled
+    private static void bindDockerSocket(CreateContainerCmd cmd) {
+        HostConfig hostConfig = cmd.getHostConfig();
+
+        List<Bind> binds = new ArrayList<>();
+        if (hostConfig.getBinds() != null) {
+            binds.addAll(Arrays.asList(hostConfig.getBinds()));
+        }
+        binds.add(new 
Bind(DockerClientFactory.instance().getRemoteDockerUnixSocketPath(), new 
Volume(DOCKER_SOCKET)));
+
+        List<String> securityOpts = new ArrayList<>();
+        if (hostConfig.getSecurityOpts() != null) {
+            securityOpts.addAll(hostConfig.getSecurityOpts());
+        }
+        securityOpts.add("label=disable");
+
+        hostConfig.withBinds(binds).withSecurityOpts(securityOpts);
+    }
 }
diff --git 
a/test-infra/camel-test-infra-google-common/src/main/resources/org/apache/camel/test/infra/google/common/services/container.properties
 
b/test-infra/camel-test-infra-google-common/src/main/resources/org/apache/camel/test/infra/google/common/services/container.properties
index b39172195ef1..5745ca75853d 100644
--- 
a/test-infra/camel-test-infra-google-common/src/main/resources/org/apache/camel/test/infra/google/common/services/container.properties
+++ 
b/test-infra/camel-test-infra-google-common/src/main/resources/org/apache/camel/test/infra/google/common/services/container.properties
@@ -17,3 +17,8 @@
 # Floci GCP: the local Google Cloud services
 google.container=mirror.gcr.io/floci/floci-gcp:0.12.0
 google.container.version.exclude=latest,nightly,compat
+# floci-duck: the SQL engine that Floci GCP starts, through the Docker socket, 
for the queries of BigQuery. Floci GCP
+# takes its latest image by default: the version is pinned to one that works 
with the Floci GCP image of
+# google.container, and changes with it.
+google.bigquery.engine.container=mirror.gcr.io/floci/floci-duck:0.4.1
+google.bigquery.engine.container.version.include=0.4.1
diff --git a/test-infra/pom.xml b/test-infra/pom.xml
index 520479cd4ebf..813d8e58b8f2 100644
--- a/test-infra/pom.xml
+++ b/test-infra/pom.xml
@@ -68,6 +68,7 @@
         <module>camel-test-infra-apicurio-registry</module>
         <module>camel-test-infra-consul</module>
         <module>camel-test-infra-google-common</module>
+        <module>camel-test-infra-google-bigquery</module>
         <module>camel-test-infra-google-firestore</module>
         <module>camel-test-infra-google-pubsub</module>
         <module>camel-test-infra-google-secret-manager</module>

Reply via email to