-
Notifications
You must be signed in to change notification settings - Fork 5
test: Add Docker integration tests #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
db2d39c
Add Docker integration tests.
subkanthi fbdd877
Fixed lint error
subkanthi 1949fbe
- fixed imports, moved config to a separate file, modified withFileSy…
subkanthi 63ff7cb
Fixed lint error
subkanthi 958efdb
Add docker-catalog-config.yaml
subkanthi 79356c2
Added docker login step
subkanthi 57e4f0a
fixed syntax in verify.yaml
subkanthi cd4fc13
move docker integration to a separate job in github action.
subkanthi f7329eb
fix skipping test logic.
subkanthi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
176 changes: 176 additions & 0 deletions
176
ice-rest-catalog/src/test/java/com/altinity/ice/rest/catalog/DockerScenarioBasedIT.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| /* | ||
| * Copyright (c) 2025 Altinity Inc and/or its affiliates. All rights reserved. | ||
| * | ||
| * Licensed 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 | ||
| */ | ||
| package com.altinity.ice.rest.catalog; | ||
|
|
||
| import java.io.File; | ||
| import java.net.URI; | ||
| import java.net.URL; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.nio.file.Paths; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import org.testcontainers.containers.GenericContainer; | ||
| import org.testcontainers.containers.Network; | ||
| import org.testcontainers.containers.wait.strategy.Wait; | ||
| import org.testcontainers.utility.MountableFile; | ||
| import org.testng.annotations.AfterClass; | ||
| import org.testng.annotations.BeforeClass; | ||
| import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; | ||
| import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; | ||
| import software.amazon.awssdk.regions.Region; | ||
| import software.amazon.awssdk.services.s3.S3Client; | ||
| import software.amazon.awssdk.services.s3.model.CreateBucketRequest; | ||
|
|
||
| /** | ||
| * Docker-based integration tests for ICE REST Catalog. | ||
| * | ||
| * <p>Runs the ice-rest-catalog Docker image (specified via system property {@code docker.image}) | ||
| * alongside a MinIO container, then executes scenario-based tests against it. | ||
| */ | ||
| public class DockerScenarioBasedIT extends RESTCatalogTestBase { | ||
|
|
||
| private Network network; | ||
|
|
||
| private GenericContainer<?> minio; | ||
|
|
||
| private GenericContainer<?> catalog; | ||
|
|
||
| @Override | ||
| @BeforeClass | ||
| @SuppressWarnings("resource") | ||
| public void setUp() throws Exception { | ||
| String dockerImage = | ||
| System.getProperty("docker.image", "altinity/ice-rest-catalog:debug-with-ice-0.12.0"); | ||
| logger.info("Using Docker image: {}", dockerImage); | ||
|
|
||
| network = Network.newNetwork(); | ||
|
|
||
| // Start MinIO | ||
| minio = | ||
| new GenericContainer<>("minio/minio:latest") | ||
| .withNetwork(network) | ||
| .withNetworkAliases("minio") | ||
| .withExposedPorts(9000) | ||
| .withEnv("MINIO_ACCESS_KEY", "minioadmin") | ||
| .withEnv("MINIO_SECRET_KEY", "minioadmin") | ||
| .withCommand("server", "/data") | ||
| .waitingFor(Wait.forHttp("/minio/health/live").forPort(9000)); | ||
| minio.start(); | ||
|
|
||
| // Create test bucket via MinIO's host-mapped port | ||
| String minioHostEndpoint = "http://" + minio.getHost() + ":" + minio.getMappedPort(9000); | ||
| try (var s3Client = | ||
| S3Client.builder() | ||
| .endpointOverride(URI.create(minioHostEndpoint)) | ||
| .region(Region.US_EAST_1) | ||
| .credentialsProvider( | ||
| StaticCredentialsProvider.create( | ||
| AwsBasicCredentials.create("minioadmin", "minioadmin"))) | ||
| .forcePathStyle(true) | ||
| .build()) { | ||
| s3Client.createBucket(CreateBucketRequest.builder().bucket("test-bucket").build()); | ||
| logger.info("Created test-bucket in MinIO"); | ||
| } | ||
|
|
||
| // Load YAML config for the catalog container (MinIO via Docker network alias "minio") | ||
| URL configResource = getClass().getClassLoader().getResource("docker-catalog-config.yaml"); | ||
| if (configResource == null) { | ||
| throw new IllegalStateException("docker-catalog-config.yaml not found on classpath"); | ||
| } | ||
| String catalogConfig = Files.readString(Paths.get(configResource.toURI())); | ||
|
|
||
| Path scenariosDir = getScenariosDirectory().toAbsolutePath(); | ||
| if (!Files.exists(scenariosDir) || !Files.isDirectory(scenariosDir)) { | ||
| throw new IllegalStateException( | ||
| "Scenarios directory must exist at " | ||
| + scenariosDir | ||
| + ". Run 'mvn test-compile' or run the test from Maven (e.g. mvn failsafe:integration-test)."); | ||
| } | ||
| Path insertScanInput = scenariosDir.resolve("insert-scan").resolve("input.parquet"); | ||
| if (!Files.exists(insertScanInput)) { | ||
| throw new IllegalStateException( | ||
| "Scenario input not found at " | ||
| + insertScanInput | ||
| + ". Ensure test resources are on the classpath and scenarios/insert-scan/input.parquet exists."); | ||
| } | ||
|
|
||
| // Start the ice-rest-catalog container (debug-with-ice has ice CLI at /usr/local/bin/ice) | ||
| catalog = | ||
| new GenericContainer<>(dockerImage) | ||
| .withNetwork(network) | ||
| .withExposedPorts(5000) | ||
| .withEnv("ICE_REST_CATALOG_CONFIG", "") | ||
| .withEnv("ICE_REST_CATALOG_CONFIG_YAML", catalogConfig) | ||
| .withCopyFileToContainer(MountableFile.forHostPath(scenariosDir), "/scenarios") | ||
| .waitingFor(Wait.forHttp("/v1/config").forPort(5000).forStatusCode(200)); | ||
|
|
||
| try { | ||
| catalog.start(); | ||
| } catch (Exception e) { | ||
| if (catalog != null) { | ||
| logger.error("Catalog container logs (stdout): {}", catalog.getLogs()); | ||
| } | ||
| throw e; | ||
| } | ||
|
|
||
| // Copy CLI config into container so ice CLI can talk to co-located REST server | ||
| File cliConfigHost = File.createTempFile("ice-docker-cli-", ".yaml"); | ||
| try { | ||
| Files.write(cliConfigHost.toPath(), "uri: http://localhost:5000\n".getBytes()); | ||
| catalog.copyFileToContainer( | ||
| MountableFile.forHostPath(cliConfigHost.toPath()), "/tmp/ice-cli.yaml"); | ||
| } finally { | ||
| cliConfigHost.delete(); | ||
| } | ||
|
|
||
| logger.info( | ||
| "Catalog container started at {}:{}", catalog.getHost(), catalog.getMappedPort(5000)); | ||
| } | ||
|
|
||
| @Override | ||
| @AfterClass | ||
| public void tearDown() { | ||
| if (catalog != null) { | ||
| catalog.close(); | ||
| } | ||
| if (minio != null) { | ||
| minio.close(); | ||
| } | ||
| if (network != null) { | ||
| network.close(); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| protected ScenarioTestRunner createScenarioRunner(String scenarioName) throws Exception { | ||
| Path scenariosDir = getScenariosDirectory(); | ||
|
|
||
| String containerId = catalog.getContainerId(); | ||
|
|
||
| // Wrapper script on host: docker exec <container> ice "$@" (CLI runs inside container) | ||
| File wrapperScript = File.createTempFile("ice-docker-exec-", ".sh"); | ||
| wrapperScript.deleteOnExit(); | ||
| String wrapperContent = "#!/bin/sh\n" + "exec docker exec " + containerId + " ice \"$@\"\n"; | ||
| Files.write(wrapperScript.toPath(), wrapperContent.getBytes()); | ||
| if (!wrapperScript.setExecutable(true)) { | ||
| throw new IllegalStateException("Could not set wrapper script executable: " + wrapperScript); | ||
| } | ||
|
|
||
| Map<String, String> templateVars = new HashMap<>(); | ||
| templateVars.put("ICE_CLI", wrapperScript.getAbsolutePath()); | ||
| templateVars.put("CLI_CONFIG", "/tmp/ice-cli.yaml"); | ||
| templateVars.put("SCENARIO_DIR", "/scenarios/" + scenarioName); | ||
| templateVars.put("MINIO_ENDPOINT", ""); | ||
| templateVars.put("CATALOG_URI", "http://localhost:5000"); | ||
|
|
||
| return new ScenarioTestRunner(scenariosDir, templateVars); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.