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-6776. Cleanup TestSCMSafeModeManager #7272

Merged
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream;

import org.apache.commons.lang3.tuple.Pair;
import org.apache.hadoop.hdds.HddsConfigKeys;
Expand Down Expand Up @@ -63,7 +64,10 @@
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -108,13 +112,10 @@ public void destroyDbStore() throws Exception {
}
}

@Test
public void testSafeModeState() throws Exception {
// Test 1: test for 0 containers
testSafeMode(0);

// Test 2: test for 20 containers
testSafeMode(20);
@ParameterizedTest
@ValueSource(ints = {0, 20})
public void testSafeModeState(int numContainers) throws Exception {
testSafeMode(numContainers);
}

@Test
Expand Down Expand Up @@ -215,34 +216,22 @@ private OzoneConfiguration createConf(double healthyPercent,
return conf;
}

@Test
public void testSafeModeExitRuleWithPipelineAvailabilityCheck1()
throws Exception {
testSafeModeExitRuleWithPipelineAvailabilityCheck(100, 30, 8, 0.90, 1);
}

@Test
public void testSafeModeExitRuleWithPipelineAvailabilityCheck2()
throws Exception {
testSafeModeExitRuleWithPipelineAvailabilityCheck(100, 90, 22, 0.10, 0.9);
}

@Test
public void testSafeModeExitRuleWithPipelineAvailabilityCheck3()
throws Exception {
testSafeModeExitRuleWithPipelineAvailabilityCheck(100, 30, 8, 0, 0.9);
}

@Test
public void testSafeModeExitRuleWithPipelineAvailabilityCheck4()
throws Exception {
testSafeModeExitRuleWithPipelineAvailabilityCheck(100, 90, 22, 0, 0);
private static Stream<Arguments> testCaseForSafeModeExitRuleWithPipelineAvailabilityCheck() {
return Stream.of(
Arguments.of(100, 30, 8, 0.90, 1),
Arguments.of(100, 90, 22, 0.10, 0.9),
Arguments.of(100, 30, 8, 0, 0.9),
Arguments.of(100, 90, 22, 0, 0),
Arguments.of(100, 90, 22, 0, 0.5)
);
}

@Test
public void testSafeModeExitRuleWithPipelineAvailabilityCheck5()
throws Exception {
testSafeModeExitRuleWithPipelineAvailabilityCheck(100, 90, 22, 0, 0.5);
@ParameterizedTest
@MethodSource("testCaseForSafeModeExitRuleWithPipelineAvailabilityCheck")
public void testSafeModeExitRuleWithPipelineAvailabilityCheck1(int containerCount, int nodeCount, int pipelineCount,
double healthyPipelinePercent, double oneReplicaPercent) throws Exception {
testSafeModeExitRuleWithPipelineAvailabilityCheck(containerCount,
nodeCount, pipelineCount, healthyPipelinePercent, oneReplicaPercent);
ivandika3 marked this conversation as resolved.
Show resolved Hide resolved
}

@ParameterizedTest
Expand Down Expand Up @@ -455,12 +444,11 @@ public void testDisableSafeMode() {
assertFalse(scmSafeModeManager.getInSafeMode());
}

@Test
public void testSafeModeDataNodeExitRule() throws Exception {
@ParameterizedTest
@ValueSource(ints = {0, 3, 5})
public void testSafeModeDataNodeExitRule(int numberOfDns) throws Exception {
containers = new ArrayList<>();
testSafeModeDataNodes(0);
testSafeModeDataNodes(3);
testSafeModeDataNodes(5);
testSafeModeDataNodes(numberOfDns);
}

/**
Expand Down
Loading