Skip to content

Commit

Permalink
Git Actions S3Proxy
Browse files Browse the repository at this point in the history
Setting the environmental variables in actions VM so that more thorough S3 tests can be done.
  • Loading branch information
AvocadoMoon committed Oct 3, 2023
1 parent 97ee3b0 commit 4f24388
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 33 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"



Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
41 changes: 16 additions & 25 deletions src/test/java/org/vcell/vcellfiji/N5ImageHandlerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<String, String> endpointCreds = new HashMap<>();
HashMap<String, String> endpointNoCreds = new HashMap<>();
HashMap<String, String> s3Endpoint = new HashMap<>();
HashMap<String, String> 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);
}


Expand Down

0 comments on commit 4f24388

Please sign in to comment.