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

HDDS-9497. Migrate TestRpcClient to JUnit5 #5699

Merged
merged 3 commits into from
Nov 29, 2023
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
7 changes: 7 additions & 0 deletions hadoop-ozone/client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
<description>Apache Ozone Client</description>
<name>Apache Ozone Client</name>
<packaging>jar</packaging>
<properties>
<allow.junit4>false</allow.junit4>
</properties>

<dependencies>
<dependency>
Expand Down Expand Up @@ -57,6 +60,10 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.reload4j</groupId>
<artifactId>reload4j</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,19 @@
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
import org.apache.hadoop.ozone.OzoneManagerVersion;
import org.apache.hadoop.ozone.om.helpers.ServiceInfo;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.Arrays;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import java.util.LinkedList;
import java.util.List;

import static org.apache.hadoop.ozone.client.rpc.RpcClient.validateOmVersion;
import static org.junit.Assert.assertThrows;
import static org.junit.jupiter.api.Assertions.assertThrows;

/**
* Run RPC Client tests.
*/
@RunWith(Parameterized.class)
public class TestRpcClient {
private enum ValidateOmVersionTestCases {
NULL_EXPECTED_NO_OM(
Expand All @@ -62,10 +59,10 @@ private enum ValidateOmVersionTestCases {
true
),
NULL_EXPECTED_ONE_CURRENT_ONE_FUTURE_OM(
null,
OzoneManagerVersion.CURRENT,
OzoneManagerVersion.FUTURE_VERSION,
true
null,
OzoneManagerVersion.CURRENT,
OzoneManagerVersion.FUTURE_VERSION,
true
),
NULL_EXPECTED_TWO_FUTURE_OM(
null,
Expand Down Expand Up @@ -193,19 +190,9 @@ private enum ValidateOmVersionTestCases {
}
}

@Parameterized.Parameters(name = "{0}")
public static Iterable<ValidateOmVersionTestCases> parameters() {
return Arrays.asList(ValidateOmVersionTestCases.values());
}

private ValidateOmVersionTestCases testCase;

public TestRpcClient(ValidateOmVersionTestCases testCase) {
this.testCase = testCase;
}

@Test
public void testValidateOmVersion() {
@ParameterizedTest
@EnumSource(ValidateOmVersionTestCases.class)
public void testValidateOmVersion(ValidateOmVersionTestCases testCase) {
List<ServiceInfo> serviceInfoList = new LinkedList<>();
ServiceInfo.Builder b1 = new ServiceInfo.Builder();
ServiceInfo.Builder b2 = new ServiceInfo.Builder();
Expand All @@ -219,8 +206,9 @@ public void testValidateOmVersion() {
b2.setOmVersion(testCase.om2Version);
serviceInfoList.add(b2.build());
}
Assert.assertEquals("Running test " + testCase, testCase.validation,
validateOmVersion(testCase.expectedVersion, serviceInfoList));
Assertions.assertEquals(testCase.validation,
validateOmVersion(testCase.expectedVersion, serviceInfoList),
"Running test " + testCase);
}

@Test
Expand Down