From 4f24388164af5f67455e0ff1105df34568853213 Mon Sep 17 00:00:00 2001 From: Ezequiel Valencia Date: Tue, 3 Oct 2023 12:05:40 -0400 Subject: [PATCH] Git Actions S3Proxy Setting the environmental variables in actions VM so that more thorough S3 tests can be done. --- .github/workflows/maven.yml | 17 ++++---- .../vcell/vcellfiji/N5ImageHandlerTest.java | 41 ++++++++----------- 2 files changed, 25 insertions(+), 33 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index a559f6f..b2c08c5 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -21,6 +21,11 @@ jobs: build: runs-on: ubuntu-latest + env: + AWS_ACCESS_KEY_ID: jj + AWS_SECRET_ACCESS_KEY: jj + AWS_DEFAULT_REGION: 'site2-low' + AWS_ENDPOINT_URL: "http://127.0.0.1:4000" @@ -36,10 +41,10 @@ jobs: JCLOUDS_REGIONS: site2-low S3PROXY_IDENTITY: jj S3PROXY_CREDENTIAL: jj - S3PROXY_AUTHORIZATION: none - + LOG_LEVEL: info S3PROXY_ENDPOINT: http://0.0.0.0:80 + S3PROXY_AUTHORIZATION: "aws-v2-or-v4" S3PROXY_VIRTUALHOST: "" S3PROXY_KEYSTORE_PATH: keystore.jks S3PROXY_KEYSTORE_PASSWORD: password @@ -67,12 +72,8 @@ jobs: - name: Put test resources in S3Proxy Container run: | - aws --endpoint-url=http://127.0.0.1:4000 --region site2-low s3 mb s3://nfive - aws --endpoint-url=http://127.0.0.1:4000 --region site2-low s3 cp ${{ github.workspace }}/src/test/resources/nfive s3://nfive --recursive - env: - AWS_ACCESS_KEY_ID: jj - AWS_SECRET_ACCESS_KEY: jj - AWS_DEFAULT_REGION: 'site2-low' + aws s3 mb s3://nfive + aws s3 cp ${{ github.workspace }}/src/test/resources/nfive s3://nfive --recursive - name: Set up JDK 8 uses: actions/setup-java@v3 diff --git a/src/test/java/org/vcell/vcellfiji/N5ImageHandlerTest.java b/src/test/java/org/vcell/vcellfiji/N5ImageHandlerTest.java index e6448e6..be81c5f 100644 --- a/src/test/java/org/vcell/vcellfiji/N5ImageHandlerTest.java +++ b/src/test/java/org/vcell/vcellfiji/N5ImageHandlerTest.java @@ -26,15 +26,8 @@ public class N5ImageHandlerTest { - private final String s3AccessKey = "access"; - private final String s3SecretKey = "secret"; private final String n5FileName = "nfive/test_image.n5"; -// private final String s3CredsEndpoint = "http://127.0.0.1:9999"; - private final String s3NoCredsEndpoint = "http://127.0.0.1:4000"; - - private final String testBucketName = "nfive"; - private File getTestResourceFiles(String filePath){ try { URL url = ClassLoader.getSystemClassLoader().getResource(filePath); @@ -64,36 +57,34 @@ public void testGettingImgPlus() throws IOException { @Test // Create client without creds, with cred no endpoint, endpoint no creds, endpoint and creds, then test whether they can handle images as expected public void testS3Client() throws IOException { -// HashMap endpointCreds = new HashMap<>(); - HashMap endpointNoCreds = new HashMap<>(); + HashMap s3Endpoint = new HashMap<>(); HashMap credentials = new HashMap<>(); -// endpointCreds.put("Endpoint", this.s3CredsEndpoint); -// endpointCreds.put("Region", Regions.US_EAST_1.getName()); + s3Endpoint.put("Endpoint", "http://127.0.0.1:4000"); + s3Endpoint.put("Region", Regions.US_EAST_1.getName()); - endpointNoCreds.put("Endpoint", this.s3NoCredsEndpoint); - endpointNoCreds.put("Region", Regions.US_EAST_1.getName()); + credentials.put("AccessKey", "jj"); + credentials.put("SecretKey", "jj"); - credentials.put("AccessKey", this.s3AccessKey); - credentials.put("SecretKey", this.s3SecretKey); - - final String s3KeyPath = "s3://" + this.testBucketName + "/test_image.n5"; + String testBucketName = "nfive"; + final String s3KeyPath = "s3://" + testBucketName + "/test_image.n5"; final String s3ProxyURL = "/" + this.n5FileName; N5ImageHandler n5ImageHandler = new N5ImageHandler(); + // Environment variables are set in github actions VM -// n5ImageHandler.createS3Client(s3NoCredsEndpoint + s3ProxyURL, null, null); -// this.remoteN5ImgPlusTests(n5ImageHandler); -// - n5ImageHandler.createS3Client(s3ProxyURL, null, endpointNoCreds); + n5ImageHandler.createS3Client(s3ProxyURL, null, null); this.remoteN5ImgPlusTests(n5ImageHandler); -// n5ImageHandler.createS3Client(this.s3CredsEndpoint + keyPath, credentials, null); -// this.remoteN5ImgPlusTests(n5ImageHandler); + n5ImageHandler.createS3Client(s3ProxyURL, null, s3Endpoint); + this.remoteN5ImgPlusTests(n5ImageHandler); -// n5ImageHandler.createS3Client(keyPath, credentials, endpointCreds); -// this.remoteN5ImgPlusTests(n5ImageHandler); + n5ImageHandler.createS3Client(s3ProxyURL, credentials, null); + this.remoteN5ImgPlusTests(n5ImageHandler); + + n5ImageHandler.createS3Client(s3ProxyURL, credentials, s3Endpoint); + this.remoteN5ImgPlusTests(n5ImageHandler); }