Skip to content
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

add TLS and non-TLS tests #1233

Merged
merged 1 commit into from
Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
./gradlew runFunctionalTest
javac -cp api/build/libs/minio-${DEV_VERSION}-all.jar functional/TestUserAgent.java
java -Dversion=${DEV_VERSION} -cp api/build/libs/minio-${DEV_VERSION}-all.jar:functional TestUserAgent
./gradlew clean
harshavardhana marked this conversation as resolved.
Show resolved Hide resolved
./gradlew build -Prelease
javac -cp api/build/libs/minio-${RELEASE_VERSION}-all.jar functional/TestUserAgent.java
java -Dversion=${RELEASE_VERSION} -cp api/build/libs/minio-${RELEASE_VERSION}-all.jar:functional TestUserAgent
Expand Down
138 changes: 95 additions & 43 deletions functional/FunctionalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ public class FunctionalTest {
private static Path dataFile1Kb;
private static Path dataFile6Mb;
private static String endpoint;
private static String endpointTLS;
private static String accessKey;
private static String secretKey;
private static String region;
Expand Down Expand Up @@ -3804,10 +3805,22 @@ public static boolean downloadMinio() throws IOException {
return true;
}

public static Process runMinio() throws Exception {
public static Process runMinio(boolean tls) throws Exception {
File binaryPath = new File(new File(System.getProperty("user.dir")), MINIO_BINARY);
ProcessBuilder pb =
new ProcessBuilder(binaryPath.getPath(), "server", "--config-dir", ".cfg", ".d{1...4}");
ProcessBuilder pb;
if (tls) {
pb =
new ProcessBuilder(
binaryPath.getPath(),
"server",
"--address",
":9001",
"--config-dir",
".cfg",
".d{1...4}");
} else {
pb = new ProcessBuilder(binaryPath.getPath(), "server", ".d{1...4}");
}

Map<String, String> env = pb.environment();
env.put("MINIO_ROOT_USER", "minio");
Expand All @@ -3823,12 +3836,70 @@ public static Process runMinio() throws Exception {
pb.redirectErrorStream(true);
pb.redirectOutput(ProcessBuilder.Redirect.to(new File(MINIO_BINARY + ".log")));

System.out.println("starting minio server");
if (tls) {
System.out.println("starting minio server in TLS");
} else {
System.out.println("starting minio server");
}
Process p = pb.start();
Thread.sleep(10 * 1000); // wait for 10 seconds to do real start.
return p;
}

public static void runEndpointTests(boolean automated) throws Exception {
client = MinioClient.builder().endpoint(endpoint).credentials(accessKey, secretKey).build();
MinioAdminClient adminClient =
MinioAdminClient.builder().endpoint(endpoint).credentials(accessKey, secretKey).build();
adminClientTests = new TestMinioAdminClient(adminClient, mintEnv);
// Enable trace for debugging.
// client.traceOn(System.out);
if (!mintEnv) System.out.println(">>> Running tests:");
FunctionalTest.runTests();

if (automated) {
// Run TLS tests on TLS endpoint
client =
MinioClient.builder().endpoint(endpointTLS).credentials(accessKey, secretKey).build();
client.ignoreCertCheck();
adminClient =
MinioAdminClient.builder()
.endpoint(endpointTLS)
.credentials(accessKey, secretKey)
.httpClient(getUnsafeOkHttpClient())
balamurugana marked this conversation as resolved.
Show resolved Hide resolved
.build();
adminClientTests = new TestMinioAdminClient(adminClient, mintEnv);
// Enable trace for debugging.
// client.traceOn(System.out);
if (!mintEnv) System.out.println(">>> Running TLS tests:");
isSecureEndpoint = true;
FunctionalTest.runTests();
}

if (!mintEnv) {
System.out.println();
System.out.println(">>> Running tests for region:");
isQuickTest = true;
isSecureEndpoint = endpoint.toLowerCase(Locale.US).contains("https://");
// Get new bucket name to avoid minio azure gateway failure.
bucketName = getRandomName();
bucketNameWithLock = getRandomName();
client =
MinioClient.builder()
.endpoint(endpoint)
.credentials(accessKey, secretKey)
.region(region)
.build();
adminClient =
MinioAdminClient.builder()
.endpoint(endpoint)
.credentials(accessKey, secretKey)
.region(region)
.build();
adminClientTests = new TestMinioAdminClient(adminClient, mintEnv);
FunctionalTest.runTests();
}
}

/** main(). */
public static void main(String[] args) throws Exception {
String mintMode = System.getenv("MINT_MODE");
Expand All @@ -3846,10 +3917,13 @@ public static void main(String[] args) throws Exception {
replicationBucketArn = System.getenv("MINIO_JAVA_TEST_REPLICATION_BUCKET_ARN");

Process minioProcess = null;
Process minioProcessTLS = null;

boolean automated = true;
String kmsKeyName = "my-minio-key";
if (args.length != 4) {
endpoint = "https://localhost:9000";
endpoint = "http://localhost:9000";
endpointTLS = "https://localhost:9001";
accessKey = "minio";
secretKey = "minio123";
region = "us-east-1";
Expand All @@ -3859,7 +3933,7 @@ public static void main(String[] args) throws Exception {
System.exit(-1);
}

minioProcess = runMinio();
minioProcess = runMinio(false);
try {
int exitValue = minioProcess.exitValue();
System.out.println("minio server process exited with " + exitValue);
Expand All @@ -3868,6 +3942,16 @@ public static void main(String[] args) throws Exception {
} catch (IllegalThreadStateException e) {
ignore();
}

minioProcessTLS = runMinio(true);
try {
int exitValue = minioProcessTLS.exitValue();
System.out.println("minio server process exited with " + exitValue);
System.out.println("usage: FunctionalTest <ENDPOINT> <ACCESSKEY> <SECRETKEY> <REGION>");
System.exit(-1);
} catch (IllegalThreadStateException e) {
ignore();
}
} else {
kmsKeyName = System.getenv("MINIO_JAVA_TEST_KMS_KEY_NAME");
if (kmsKeyName == null) {
Expand All @@ -3878,6 +3962,7 @@ public static void main(String[] args) throws Exception {
accessKey = args[1];
secretKey = args[2];
region = args[3];
automated = false;
}

isSecureEndpoint = endpoint.toLowerCase(Locale.US).contains("https://");
harshavardhana marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -3889,43 +3974,7 @@ public static void main(String[] args) throws Exception {

int exitValue = 0;
try {
client = MinioClient.builder().endpoint(endpoint).credentials(accessKey, secretKey).build();
client.ignoreCertCheck();
MinioAdminClient adminClient =
MinioAdminClient.builder()
.endpoint(endpoint)
.credentials(accessKey, secretKey)
.httpClient(getUnsafeOkHttpClient())
.build();
adminClientTests = new TestMinioAdminClient(adminClient, mintEnv);
// Enable trace for debugging.
// client.traceOn(System.out);
if (!mintEnv) System.out.println(">>> Running tests:");
FunctionalTest.runTests();
if (!mintEnv) {
System.out.println();
System.out.println(">>> Running tests for region:");
isQuickTest = true;
// Get new bucket name to avoid minio azure gateway failure.
bucketName = getRandomName();
bucketNameWithLock = getRandomName();
client =
MinioClient.builder()
.endpoint(endpoint)
.credentials(accessKey, secretKey)
.region(region)
.build();
client.ignoreCertCheck();
adminClient =
MinioAdminClient.builder()
.endpoint(endpoint)
.credentials(accessKey, secretKey)
.region(region)
.httpClient(getUnsafeOkHttpClient())
.build();
adminClientTests = new TestMinioAdminClient(adminClient, mintEnv);
FunctionalTest.runTests();
}
runEndpointTests(automated);
} catch (Exception e) {
if (!mintEnv) {
e.printStackTrace();
Expand All @@ -3935,6 +3984,9 @@ public static void main(String[] args) throws Exception {
if (minioProcess != null) {
minioProcess.destroy();
}
if (minioProcessTLS != null) {
minioProcessTLS.destroy();
}
}

System.exit(exitValue);
Expand Down