diff --git a/.github/workflows/system-tests.yml b/.github/workflows/system-tests.yml index 4c453658d7..2cb2b5d8b5 100644 --- a/.github/workflows/system-tests.yml +++ b/.github/workflows/system-tests.yml @@ -19,6 +19,12 @@ on: # Run every day at 00:00 schedule: - cron: "0 0 * * *" + push: + paths: + - 'nifi-system-tests/**' + pull_request: + paths: + - 'nifi-system-tests/**' env: DEFAULT_MAVEN_OPTS: >- @@ -52,19 +58,12 @@ jobs: steps: - name: Checkout Code uses: actions/checkout@v2 - - name: Cache Maven Dependencies - uses: actions/cache@v2 - with: - path: | - ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - name: Set up Java 11 uses: actions/setup-java@v2 with: distribution: zulu java-version: 11 + cache: 'maven' - name: Build Dependencies env: MAVEN_OPTS: >- @@ -99,19 +98,12 @@ jobs: steps: - name: Checkout Code uses: actions/checkout@v2 - - name: Cache Maven Dependencies - uses: actions/cache@v2 - with: - path: | - ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - name: Set up Java 8 uses: actions/setup-java@v2 with: distribution: zulu java-version: 8 + cache: 'maven' - name: Build Dependencies env: MAVEN_OPTS: >- diff --git a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/StatelessSystemIT.java b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/StatelessSystemIT.java index f0df86133e..aa4e2845b7 100644 --- a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/StatelessSystemIT.java +++ b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/StatelessSystemIT.java @@ -34,11 +34,9 @@ import org.apache.nifi.stateless.engine.StatelessEngineConfiguration; import org.apache.nifi.stateless.flow.DataflowDefinition; import org.apache.nifi.stateless.flow.StatelessDataflow; import org.apache.nifi.stateless.flow.TransactionThresholds; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.rules.TestName; -import org.junit.rules.Timeout; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Timeout; import java.io.File; import java.io.FileInputStream; @@ -53,6 +51,7 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; +@Timeout(value = 5, unit = TimeUnit.MINUTES) public class StatelessSystemIT { private final List createdFlows = new ArrayList<>(); @@ -60,19 +59,12 @@ public class StatelessSystemIT { // up finding a "compatible bundle" and using that, regardless of the specified version. protected static final Bundle SYSTEM_TEST_EXTENSIONS_BUNDLE = new Bundle("org.apache.nifi", "nifi-system-test-extensions-nar", "1.13.0-SNAPSHOT"); - @Rule - public TestName name = new TestName(); - - @Rule - public Timeout defaultTimeout = new Timeout(5, TimeUnit.MINUTES); - - - @Before + @BeforeEach public void clearFlows() { createdFlows.clear(); } - @After + @AfterEach public void shutdownFlows() { createdFlows.forEach(StatelessDataflow::shutdown); } @@ -236,8 +228,4 @@ public class StatelessSystemIT { createdFlows.add(dataflow); return dataflow; } - - protected String getTestName() { - return name.getMethodName(); - } } diff --git a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/VersionedFlowBuilder.java b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/VersionedFlowBuilder.java index 07381daa95..7f38166919 100644 --- a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/VersionedFlowBuilder.java +++ b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/VersionedFlowBuilder.java @@ -43,8 +43,8 @@ import java.util.Set; import java.util.UUID; public class VersionedFlowBuilder { - private VersionedFlowSnapshot flowSnapshot; - private VersionedProcessGroup rootGroup; + private final VersionedFlowSnapshot flowSnapshot; + private final VersionedProcessGroup rootGroup; public VersionedFlowBuilder() { rootGroup = new VersionedProcessGroup(); @@ -146,7 +146,7 @@ public class VersionedFlowBuilder { processor.setSchedulingStrategy("TIMER_DRIVEN"); processor.setRetryCount(0); processor.setBackoffMechanism("PENALIZE_FLOWFILE"); - processor.setRetriedRelationships(Collections.EMPTY_SET); + processor.setRetriedRelationships(Collections.emptySet()); processor.setMaxBackoffPeriod("0 sec"); group.getProcessors().add(processor); diff --git a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/AsyncCommitCallbackIT.java b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/AsyncCommitCallbackIT.java index 52fbf83d11..9a1fefa7e7 100644 --- a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/AsyncCommitCallbackIT.java +++ b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/AsyncCommitCallbackIT.java @@ -27,8 +27,9 @@ import org.apache.nifi.stateless.config.StatelessConfigurationException; import org.apache.nifi.stateless.flow.DataflowTrigger; import org.apache.nifi.stateless.flow.StatelessDataflow; import org.apache.nifi.stateless.flow.TriggerResult; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import java.io.File; import java.io.IOException; @@ -40,15 +41,15 @@ import java.util.List; import java.util.Map; import java.util.function.Consumer; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class AsyncCommitCallbackIT extends StatelessSystemIT { private final File inputFile = new File("target/input.txt"); private final File replacementFile = new File("target/replacement.txt"); - @Before + @BeforeEach public void setup() throws IOException { Files.write(inputFile.toPath(), "Hello World".getBytes(), StandardOpenOption.CREATE); Files.deleteIfExists(replacementFile.toPath()); @@ -98,13 +99,15 @@ public class AsyncCommitCallbackIT extends StatelessSystemIT { assertTrue(failureOutputFile.exists()); } - @Test(timeout = 10_000) + @Timeout(10) + @Test public void testCleanupAfterFlowFilesTerminated() throws IOException, StatelessConfigurationException, InterruptedException { testCleanupAfterFlowFilesTerminated("asynchronous"); } - @Test(timeout = 10_000) - public void testSynchronousCommitCleanupAFterFlowFilesTerminated() throws IOException, StatelessConfigurationException, InterruptedException { + @Timeout(10) + @Test + public void testSynchronousCommitCleanupAfterFlowFilesTerminated() throws IOException, StatelessConfigurationException, InterruptedException { testCleanupAfterFlowFilesTerminated("synchronous"); } diff --git a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/BatchOutputIT.java b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/BatchOutputIT.java index 1a06c31bfe..0b4193471d 100644 --- a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/BatchOutputIT.java +++ b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/BatchOutputIT.java @@ -27,15 +27,15 @@ import org.apache.nifi.stateless.config.StatelessConfigurationException; import org.apache.nifi.stateless.flow.DataflowTrigger; import org.apache.nifi.stateless.flow.StatelessDataflow; import org.apache.nifi.stateless.flow.TriggerResult; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class BatchOutputIT extends StatelessSystemIT { diff --git a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/CancelFlowExecutionIT.java b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/CancelFlowExecutionIT.java index 3fa38fa461..224e8eca08 100644 --- a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/CancelFlowExecutionIT.java +++ b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/CancelFlowExecutionIT.java @@ -26,15 +26,15 @@ import org.apache.nifi.stateless.config.StatelessConfigurationException; import org.apache.nifi.stateless.flow.DataflowTrigger; import org.apache.nifi.stateless.flow.StatelessDataflow; import org.apache.nifi.stateless.flow.TriggerResult; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; import java.util.Optional; import java.util.concurrent.TimeUnit; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CancelFlowExecutionIT extends StatelessSystemIT { diff --git a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/CloneFlowFileIT.java b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/CloneFlowFileIT.java index a236c776c0..442f205fbe 100644 --- a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/CloneFlowFileIT.java +++ b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/CloneFlowFileIT.java @@ -27,16 +27,16 @@ import org.apache.nifi.stateless.config.StatelessConfigurationException; import org.apache.nifi.stateless.flow.DataflowTrigger; import org.apache.nifi.stateless.flow.StatelessDataflow; import org.apache.nifi.stateless.flow.TriggerResult; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; +import java.io.UncheckedIOException; import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CloneFlowFileIT extends StatelessSystemIT { @@ -94,9 +94,7 @@ public class CloneFlowFileIT extends StatelessSystemIT { try { return new String(result.readContentAsByteArray(flowFile), StandardCharsets.UTF_8); } catch (final IOException e) { - e.printStackTrace(); - Assert.fail("Could not read content"); - return null; + throw new UncheckedIOException("Read Content Failed", e); } } } diff --git a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/CreatesFlowFileIT.java b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/CreatesFlowFileIT.java index 4461f4d1fc..5ed91ca68b 100644 --- a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/CreatesFlowFileIT.java +++ b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/CreatesFlowFileIT.java @@ -26,7 +26,7 @@ import org.apache.nifi.stateless.config.StatelessConfigurationException; import org.apache.nifi.stateless.flow.DataflowTrigger; import org.apache.nifi.stateless.flow.StatelessDataflow; import org.apache.nifi.stateless.flow.TriggerResult; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; @@ -34,8 +34,8 @@ import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CreatesFlowFileIT extends StatelessSystemIT { diff --git a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/InputOutputIT.java b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/InputOutputIT.java index 7cd0ae9d4a..a1d78ef75a 100644 --- a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/InputOutputIT.java +++ b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/InputOutputIT.java @@ -28,14 +28,14 @@ import org.apache.nifi.stateless.config.StatelessConfigurationException; import org.apache.nifi.stateless.flow.DataflowTrigger; import org.apache.nifi.stateless.flow.StatelessDataflow; import org.apache.nifi.stateless.flow.TriggerResult; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class InputOutputIT extends StatelessSystemIT { diff --git a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/LoopingIT.java b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/LoopingIT.java index bce362151e..b24e176876 100644 --- a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/LoopingIT.java +++ b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/LoopingIT.java @@ -26,7 +26,7 @@ import org.apache.nifi.stateless.config.StatelessConfigurationException; import org.apache.nifi.stateless.flow.DataflowTrigger; import org.apache.nifi.stateless.flow.StatelessDataflow; import org.apache.nifi.stateless.flow.TriggerResult; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; @@ -34,8 +34,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class LoopingIT extends StatelessSystemIT { diff --git a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/MergingIT.java b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/MergingIT.java index 098ca99f77..b55ef4b929 100644 --- a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/MergingIT.java +++ b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/MergingIT.java @@ -26,7 +26,7 @@ import org.apache.nifi.stateless.config.StatelessConfigurationException; import org.apache.nifi.stateless.flow.DataflowTrigger; import org.apache.nifi.stateless.flow.StatelessDataflow; import org.apache.nifi.stateless.flow.TriggerResult; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; @@ -34,8 +34,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MergingIT extends StatelessSystemIT { diff --git a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/PartitioningContentIT.java b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/PartitioningContentIT.java index fe7073d089..1b6f05befe 100644 --- a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/PartitioningContentIT.java +++ b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/PartitioningContentIT.java @@ -26,7 +26,7 @@ import org.apache.nifi.stateless.config.StatelessConfigurationException; import org.apache.nifi.stateless.flow.DataflowTrigger; import org.apache.nifi.stateless.flow.StatelessDataflow; import org.apache.nifi.stateless.flow.TriggerResult; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; @@ -36,8 +36,8 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class PartitioningContentIT extends StatelessSystemIT { diff --git a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/ProcessorLifecycleIT.java b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/ProcessorLifecycleIT.java index b2596f789a..6eb246a384 100644 --- a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/ProcessorLifecycleIT.java +++ b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/ProcessorLifecycleIT.java @@ -24,7 +24,7 @@ import org.apache.nifi.stateless.config.StatelessConfigurationException; import org.apache.nifi.stateless.flow.DataflowTrigger; import org.apache.nifi.stateless.flow.StatelessDataflow; import org.apache.nifi.stateless.flow.TriggerResult; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/RequiresAdditionalInputIT.java b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/RequiresAdditionalInputIT.java index 4fed60254a..ed4618e86c 100644 --- a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/RequiresAdditionalInputIT.java +++ b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/RequiresAdditionalInputIT.java @@ -29,8 +29,7 @@ import org.apache.nifi.stateless.flow.DataflowTrigger; import org.apache.nifi.stateless.flow.StatelessDataflow; import org.apache.nifi.stateless.flow.TransactionThresholds; import org.apache.nifi.stateless.flow.TriggerResult; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -44,9 +43,9 @@ import java.util.Optional; import java.util.OptionalLong; import java.util.concurrent.TimeUnit; -import static junit.framework.TestCase.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class RequiresAdditionalInputIT extends StatelessSystemIT { @@ -75,11 +74,11 @@ public class RequiresAdditionalInputIT extends StatelessSystemIT { assertTrue(result.isSuccessful()); final List flowFiles = result.getOutputFlowFiles("Out"); - Assert.assertEquals(1, flowFiles.size()); + assertEquals(1, flowFiles.size()); final FlowFile first = flowFiles.get(0); final String outputContent = new String(result.readContentAsByteArray(first)); - Assert.assertEquals("123", outputContent); + assertEquals("123", outputContent); result.acknowledge(); } diff --git a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/RollbackOnExceptionIT.java b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/RollbackOnExceptionIT.java index 8d2eb622cc..4594b574eb 100644 --- a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/RollbackOnExceptionIT.java +++ b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/RollbackOnExceptionIT.java @@ -27,18 +27,20 @@ import org.apache.nifi.stateless.flow.DataflowTrigger; import org.apache.nifi.stateless.flow.FailurePortEncounteredException; import org.apache.nifi.stateless.flow.StatelessDataflow; import org.apache.nifi.stateless.flow.TriggerResult; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import java.io.IOException; import java.util.Collections; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class RollbackOnExceptionIT extends StatelessSystemIT { private static final String EXCEPTION_TEXT = "Intentional Exception to verify behavior in RollbackOnExceptionIT"; - @Test(timeout = 30_000) + @Timeout(30) + @Test public void testFlowFileCompletelyRemovedWhenExceptionThrown() throws IOException, StatelessConfigurationException, InterruptedException { final VersionedFlowBuilder builder = new VersionedFlowBuilder(); final VersionedProcessor generate = builder.createSimpleProcessor("GenerateFlowFile"); diff --git a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/SplittingIT.java b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/SplittingIT.java index 846cc78adb..061cf21e7f 100644 --- a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/SplittingIT.java +++ b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/SplittingIT.java @@ -26,7 +26,7 @@ import org.apache.nifi.stateless.config.StatelessConfigurationException; import org.apache.nifi.stateless.flow.DataflowTrigger; import org.apache.nifi.stateless.flow.StatelessDataflow; import org.apache.nifi.stateless.flow.TriggerResult; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; @@ -34,8 +34,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class SplittingIT extends StatelessSystemIT { @Test diff --git a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/StateStorageIT.java b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/StateStorageIT.java index 43c9ff4001..a4c63b6ebb 100644 --- a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/StateStorageIT.java +++ b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/StateStorageIT.java @@ -27,16 +27,16 @@ import org.apache.nifi.stateless.config.StatelessConfigurationException; import org.apache.nifi.stateless.flow.DataflowTrigger; import org.apache.nifi.stateless.flow.StatelessDataflow; import org.apache.nifi.stateless.flow.TriggerResult; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; import java.util.Map; -import static junit.framework.TestCase.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class StateStorageIT extends StatelessSystemIT { @Test diff --git a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/StatelessRetryIT.java b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/StatelessRetryIT.java index 0a6b8115e4..dd93349497 100644 --- a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/StatelessRetryIT.java +++ b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/basics/StatelessRetryIT.java @@ -26,14 +26,14 @@ import org.apache.nifi.stateless.config.StatelessConfigurationException; import org.apache.nifi.stateless.flow.DataflowTrigger; import org.apache.nifi.stateless.flow.StatelessDataflow; import org.apache.nifi.stateless.flow.TriggerResult; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class StatelessRetryIT extends StatelessSystemIT { private static final int RETRY_COUNT = 2; diff --git a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/classloader/InstanceClassLoaderIT.java b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/classloader/InstanceClassLoaderIT.java index 8e51d0049f..9c9dffc01a 100644 --- a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/classloader/InstanceClassLoaderIT.java +++ b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/classloader/InstanceClassLoaderIT.java @@ -23,7 +23,7 @@ import org.apache.nifi.stateless.StatelessSystemIT; import org.apache.nifi.stateless.VersionedFlowBuilder; import org.apache.nifi.stateless.config.StatelessConfigurationException; import org.apache.nifi.stateless.flow.StatelessDataflow; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.lang.reflect.InvocationTargetException; @@ -33,7 +33,7 @@ import java.util.HashSet; import java.util.Set; import java.util.stream.Collectors; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class InstanceClassLoaderIT extends StatelessSystemIT { diff --git a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/controller/services/StatelessControllerServiceSystemIT.java b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/controller/services/StatelessControllerServiceSystemIT.java index 06ec164449..6fdcb8a4eb 100644 --- a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/controller/services/StatelessControllerServiceSystemIT.java +++ b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/controller/services/StatelessControllerServiceSystemIT.java @@ -29,14 +29,14 @@ import org.apache.nifi.stateless.config.StatelessConfigurationException; import org.apache.nifi.stateless.flow.DataflowTrigger; import org.apache.nifi.stateless.flow.StatelessDataflow; import org.apache.nifi.stateless.flow.TriggerResult; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class StatelessControllerServiceSystemIT extends StatelessSystemIT { diff --git a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/parameters/ParameterContextIT.java b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/parameters/ParameterContextIT.java index 5eeb6e7891..6848ff09e6 100644 --- a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/parameters/ParameterContextIT.java +++ b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/parameters/ParameterContextIT.java @@ -35,8 +35,7 @@ import org.apache.nifi.stateless.flow.DataflowTrigger; import org.apache.nifi.stateless.flow.StatelessDataflow; import org.apache.nifi.stateless.flow.TransactionThresholds; import org.apache.nifi.stateless.flow.TriggerResult; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.ArrayList; @@ -45,8 +44,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ParameterContextIT extends StatelessSystemIT { @@ -105,14 +105,12 @@ public class ParameterContextIT extends StatelessSystemIT { parameterContext.getParameters().add(createVersionedParameter("three", "-1")); // Set value to -1. This should be overridden by the Numeric Parameter Context. flowBuilder.getRootGroup().setParameterContextName("Context 1"); - Assert.assertThrows(IllegalStateException.class, () -> { - loadDataflow(flowSnapshot, Collections.emptyList(), parameterValueProviders, Collections.emptySet(), TransactionThresholds.SINGLE_FLOWFILE); - }); + assertThrows(IllegalStateException.class, () -> loadDataflow(flowSnapshot, Collections.emptyList(), parameterValueProviders, Collections.emptySet(), TransactionThresholds.SINGLE_FLOWFILE)); } @Test - public void testParameterValueProviderWithRequiredPropertyNotSet() throws IOException, StatelessConfigurationException { + public void testParameterValueProviderWithRequiredPropertyNotSet() { final VersionedFlowBuilder flowBuilder = new VersionedFlowBuilder(); final VersionedPort outPort = flowBuilder.createOutputPort("Out"); final VersionedProcessor generate = flowBuilder.createSimpleProcessor("GenerateFlowFile"); @@ -133,9 +131,7 @@ public class ParameterContextIT extends StatelessSystemIT { parameterContext.getParameters().add(createVersionedParameter("three", "1")); // Set value to -1. This should be overridden by the Numeric Parameter Context. flowBuilder.getRootGroup().setParameterContextName("Context 1"); - Assert.assertThrows(IllegalStateException.class, () -> { - loadDataflow(flowSnapshot, Collections.emptyList(), parameterValueProviders, Collections.emptySet(), TransactionThresholds.SINGLE_FLOWFILE); - }); + assertThrows(IllegalStateException.class, () -> loadDataflow(flowSnapshot, Collections.emptyList(), parameterValueProviders, Collections.emptySet(), TransactionThresholds.SINGLE_FLOWFILE)); } @Test diff --git a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/performance/StatelessPerformanceIT.java b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/performance/StatelessPerformanceIT.java index 9056c6f246..55b7732e55 100644 --- a/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/performance/StatelessPerformanceIT.java +++ b/nifi-system-tests/nifi-stateless-system-test-suite/src/test/java/org/apache/nifi/stateless/performance/StatelessPerformanceIT.java @@ -23,15 +23,15 @@ import org.apache.nifi.stateless.VersionedFlowBuilder; import org.apache.nifi.stateless.flow.DataflowTrigger; import org.apache.nifi.stateless.flow.StatelessDataflow; import org.apache.nifi.stateless.flow.TriggerResult; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfSystemProperty; import java.util.ArrayList; import java.util.List; public class StatelessPerformanceIT extends StatelessSystemIT { @Test - @Ignore("For manual testing purposes only") + @EnabledIfSystemProperty(named = "nifi.test.performance", matches = "true") public void testCreateDestroyPerf() throws InterruptedException { System.setProperty("org.slf4j.simpleLogger.log.org.apache.nifi", "WARN"); final VersionedFlowBuilder builder = new VersionedFlowBuilder(); diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiClientUtil.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiClientUtil.java index 0dc64eac5f..c3de536cff 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiClientUtil.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiClientUtil.java @@ -87,7 +87,6 @@ import org.apache.nifi.web.api.entity.VariableEntity; import org.apache.nifi.web.api.entity.VariableRegistryEntity; import org.apache.nifi.web.api.entity.VariableRegistryUpdateRequestEntity; import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity; -import org.junit.Assert; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -105,6 +104,8 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import static org.junit.jupiter.api.Assertions.assertNull; + public class NiFiClientUtil { private static final Logger logger = LoggerFactory.getLogger(NiFiClientUtil.class); @@ -734,7 +735,7 @@ public class NiFiClientUtil { try { Thread.sleep(500L); } catch (final Exception e) { - Assert.fail(e.toString()); + throw new RuntimeException(e); } } } @@ -762,8 +763,7 @@ public class NiFiClientUtil { try { Thread.sleep(500L); } catch (final Exception e) { - e.printStackTrace(); - Assert.fail(e.toString()); + throw new RuntimeException(e); } } } @@ -1039,8 +1039,7 @@ public class NiFiClientUtil { getConnectionClient().deleteListingRequest(connectionId, listingRequestEntity.getListingRequest().getId()); return listingRequestEntity; } catch (final InterruptedException e) { - Assert.fail("Failed to obtain connection status"); - return null; + throw new RuntimeException("Failed to obtain connection status"); } } @@ -1117,16 +1116,13 @@ public class NiFiClientUtil { try { Thread.sleep(100L); } catch (final InterruptedException ie) { - Assert.fail("Interrupted while waiting for variable registry to update"); - return null; + throw new RuntimeException("Interrupted while waiting for variable registry to update"); } updateRequestEntity = nifiClient.getProcessGroupClient().getVariableRegistryUpdateRequest(processGroup.getId(), updateRequestEntity.getRequest().getRequestId()); } - if (updateRequestEntity.getRequest().getFailureReason() != null) { - Assert.fail("Failed to update Variable Registry due to: " + updateRequestEntity.getRequest().getFailureReason()); - } + assertNull(updateRequestEntity.getRequest().getFailureReason()); nifiClient.getProcessGroupClient().deleteVariableRegistryUpdateRequest(processGroup.getId(), updateRequestEntity.getRequest().getRequestId()); return updateRequestEntity; @@ -1192,7 +1188,7 @@ public class NiFiClientUtil { try { responseEntity = waitForComplete(responseEntity); } catch (final InterruptedException ie) { - Assert.fail("Interrupted while waiting for Provenance Query to complete"); + throw new RuntimeException("Interrupted while waiting for Provenance Query to complete"); } nifiClient.getProvenanceClient().deleteProvenanceQuery(responseEntity.getProvenance().getId()); diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiInstanceProvider.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiInstanceProvider.java new file mode 100644 index 0000000000..ab7e3e8851 --- /dev/null +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiInstanceProvider.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.tests.system; + +/** + * Provider for configured NiFi instances + */ +public interface NiFiInstanceProvider { + /** + * Get configured NiFi instance or null when not configured + * + * @return NiFi instance or null when not configured + */ + NiFiInstance getNiFiInstance(); + + /** + * Get NiFi instance factory + * + * @return NiFi Instance Factory + */ + NiFiInstanceFactory getInstanceFactory(); +} diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiSystemIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiSystemIT.java index 2f48f1f7f8..341e384812 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiSystemIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiSystemIT.java @@ -24,15 +24,12 @@ import org.apache.nifi.web.api.dto.NodeDTO; import org.apache.nifi.web.api.entity.ClusteSummaryEntity; import org.apache.nifi.web.api.entity.ClusterEntity; import org.apache.nifi.web.api.entity.ConnectionStatusEntity; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.rules.TestName; -import org.junit.rules.TestWatcher; -import org.junit.rules.Timeout; -import org.junit.runner.Description; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.api.extension.ExtendWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,7 +46,9 @@ import java.util.function.Predicate; import java.util.regex.Matcher; import java.util.regex.Pattern; -public abstract class NiFiSystemIT { +@ExtendWith(TroubleshootingTestWatcher.class) +@Timeout(value = 5, unit = TimeUnit.MINUTES) +public abstract class NiFiSystemIT implements NiFiInstanceProvider { private static final Logger logger = LoggerFactory.getLogger(NiFiSystemIT.class); private final ConcurrentMap lastLogTimestamps = new ConcurrentHashMap<>(); @@ -65,31 +64,16 @@ public abstract class NiFiSystemIT { private static final File LIB_DIR = new File("target/nifi-lib-assembly/lib"); private static volatile String nifiFrameworkVersion = null; - @Rule - public TestName name = new TestName(); - @Rule - public Timeout defaultTimeout = new Timeout(5, TimeUnit.MINUTES); - - @Rule(order = Integer.MIN_VALUE) - public TestWatcher quarantineRule = new TestWatcher() { - @Override - protected void failed(final Throwable t, final Description description) { - final String testName = description.getMethodName(); - try { - final File dir = quarantineTroubleshootingInfo(testName, t); - logger.info("Test failure for <{}>. Successfully wrote troubleshooting info to {}", testName, dir.getAbsolutePath()); - } catch (final Exception e) { - logger.error("Failed to quarantine troubleshooting info for test " + testName, e); - } - } - }; - private NiFiClient nifiClient; private NiFiClientUtil clientUtil; private static final AtomicReference nifiRef = new AtomicReference<>(); - @Before - public void setup() throws IOException { + private TestInfo testInfo; + + @BeforeEach + public void setup(final TestInfo testInfo) throws IOException { + this.testInfo = testInfo; + Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader()); setupClient(); @@ -107,7 +91,7 @@ public abstract class NiFiSystemIT { } } - @AfterClass + @AfterAll public static void cleanup() { final NiFiInstance nifi = nifiRef.get(); nifiRef.set(null); @@ -116,7 +100,7 @@ public abstract class NiFiSystemIT { } } - @After + @AfterEach public void teardown() throws Exception { try { Exception destroyFlowFailure = null; @@ -147,21 +131,23 @@ public abstract class NiFiSystemIT { } } - protected File quarantineTroubleshootingInfo(final String methodName, final Throwable failureCause) throws IOException { - NiFiInstance instance = getNiFiInstance(); + @Override + public NiFiInstance getNiFiInstance() { + return nifiRef.get(); + } - // The @AfterClass may or may not have already run at this point. If it has, the instance will be null. - // In that case, just create a new instance and use it - it will map to the same directories. - if (instance == null) { - instance = getInstanceFactory().createInstance(); - } + @Override + public NiFiInstanceFactory getInstanceFactory() { + return new SpawnedStandaloneNiFiInstanceFactory( + new InstanceConfiguration.Builder() + .bootstrapConfig("src/test/resources/conf/default/bootstrap.conf") + .instanceDirectory("target/standalone-instance") + .overrideNifiProperties(getNifiPropertiesOverrides()) + .build()); + } - final File troubleshooting = new File("target/troubleshooting"); - final File quarantineDir = new File(troubleshooting, methodName); - quarantineDir.mkdirs(); - - instance.quarantineTroubleshootingInfo(quarantineDir, failureCause); - return quarantineDir; + protected String getTestName() { + return testInfo.getDisplayName(); } protected boolean isDestroyEnvironmentAfterEachTest() { @@ -253,11 +239,6 @@ public abstract class NiFiSystemIT { return CLIENT_API_PORT; } - - protected String getTestName() { - return name.getMethodName(); - } - protected NiFiClient getNifiClient() { Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader()); return nifiClient; @@ -283,10 +264,6 @@ public abstract class NiFiSystemIT { throw new IllegalStateException("Could not determine version of NiFi"); } - protected NiFiInstance getNiFiInstance() { - return nifiRef.get(); - } - protected int getNumberOfNodes() { return getNumberOfNodes(true); } @@ -300,15 +277,6 @@ public abstract class NiFiSystemIT { return instance.getNumberOfNodes(includeOnlyAutoStartInstances); } - protected NiFiInstanceFactory getInstanceFactory() { - return new SpawnedStandaloneNiFiInstanceFactory( - new InstanceConfiguration.Builder() - .bootstrapConfig("src/test/resources/conf/default/bootstrap.conf") - .instanceDirectory("target/standalone-instance") - .overrideNifiProperties(getNifiPropertiesOverrides()) - .build()); - } - protected Map getNifiPropertiesOverrides() { return Collections.emptyMap(); } @@ -398,9 +366,7 @@ public abstract class NiFiSystemIT { try { return getNifiClient().getFlowClient().getConnectionStatus(connectionId, true); } catch (final Exception e) { - e.printStackTrace(); - Assert.fail("Failed to obtain connection status"); - return null; + throw new RuntimeException("Failed to obtain connection status"); } } diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/SpawnedStandaloneNiFiInstanceFactory.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/SpawnedStandaloneNiFiInstanceFactory.java index 8b5f2adb02..f14e4d325a 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/SpawnedStandaloneNiFiInstanceFactory.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/SpawnedStandaloneNiFiInstanceFactory.java @@ -38,7 +38,7 @@ import java.util.Collections; import java.util.Map; import java.util.Properties; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; public class SpawnedStandaloneNiFiInstanceFactory implements NiFiInstanceFactory { private static final Logger logger = LoggerFactory.getLogger(SpawnedStandaloneNiFiInstanceFactory.class); diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/TroubleshootingTestWatcher.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/TroubleshootingTestWatcher.java new file mode 100644 index 0000000000..8d71362359 --- /dev/null +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/TroubleshootingTestWatcher.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.tests.system; + +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.TestWatcher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.IOException; +import java.util.Optional; + +/** + * Test Watcher responsible for writing troubleshooting logs + */ +public class TroubleshootingTestWatcher implements TestWatcher { + private static final Logger logger = LoggerFactory.getLogger(TroubleshootingTestWatcher.class); + + @Override + public void testFailed(final ExtensionContext context, final Throwable cause) { + final Optional optionalTestInstance = context.getTestInstance(); + if (optionalTestInstance.isPresent()) { + final Object testInstance = optionalTestInstance.get(); + if (testInstance instanceof NiFiInstanceProvider) { + final NiFiInstanceProvider provider = (NiFiInstanceProvider) testInstance; + final String displayName = context.getDisplayName(); + try { + final File dir = quarantineTroubleshootingInfo(provider, displayName, cause); + logger.info("Test Failed [{}]: Troubleshooting information stored [{}]", displayName, dir.getAbsolutePath()); + } catch (final Exception e) { + logger.error("Test Failed [{}]: Troubleshooting information not stored", displayName, e); + } + } + } + } + + private File quarantineTroubleshootingInfo(final NiFiInstanceProvider provider, final String methodName, final Throwable failureCause) throws IOException { + NiFiInstance instance = provider.getNiFiInstance(); + + // The teardown method may or may not have already run at this point. If it has, the instance will be null. + // In that case, just create a new instance and use it - it will map to the same directories. + if (instance == null) { + instance = provider.getInstanceFactory().createInstance(); + } + + final File troubleshooting = new File("target/troubleshooting"); + final File quarantineDir = new File(troubleshooting, methodName); + quarantineDir.mkdirs(); + + instance.quarantineTroubleshootingInfo(quarantineDir, failureCause); + return quarantineDir; + } +} diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/classloaders/ClassloaderIsolationKeyIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/classloaders/ClassloaderIsolationKeyIT.java index 4c5fb822e5..1f62d9a26d 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/classloaders/ClassloaderIsolationKeyIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/classloaders/ClassloaderIsolationKeyIT.java @@ -21,7 +21,7 @@ import org.apache.nifi.tests.system.NiFiSystemIT; import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException; import org.apache.nifi.web.api.entity.ConnectionEntity; import org.apache.nifi.web.api.entity.ProcessorEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; @@ -29,7 +29,7 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.Collections; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class ClassloaderIsolationKeyIT extends NiFiSystemIT { diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/FlowSynchronizationIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/FlowSynchronizationIT.java index 2a45672597..7a5d89e1a2 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/FlowSynchronizationIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/FlowSynchronizationIT.java @@ -53,7 +53,7 @@ import org.apache.nifi.web.api.entity.ProcessGroupEntity; import org.apache.nifi.web.api.entity.ProcessGroupFlowEntity; import org.apache.nifi.web.api.entity.ProcessorEntity; import org.apache.nifi.web.api.entity.ReportingTaskEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -70,9 +70,9 @@ import java.util.Map; import java.util.Set; import java.util.zip.GZIPInputStream; -import static junit.framework.TestCase.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class FlowSynchronizationIT extends NiFiSystemIT { private static final Logger logger = LoggerFactory.getLogger(FlowSynchronizationIT.class); @@ -84,7 +84,7 @@ public class FlowSynchronizationIT extends NiFiSystemIT { private final ObjectMapper objectMapper = new ObjectMapper(); @Override - protected NiFiInstanceFactory getInstanceFactory() { + public NiFiInstanceFactory getInstanceFactory() { return new SpawnedClusterNiFiInstanceFactory( new InstanceConfiguration.Builder() .bootstrapConfig("src/test/resources/conf/clustered/node1/bootstrap.conf") diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/JoinClusterAdjustStateIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/JoinClusterAdjustStateIT.java index 5849a525bd..6c89de2afb 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/JoinClusterAdjustStateIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/JoinClusterAdjustStateIT.java @@ -23,18 +23,18 @@ import org.apache.nifi.tests.system.NiFiSystemIT; import org.apache.nifi.tests.system.SpawnedClusterNiFiInstanceFactory; import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException; import org.apache.nifi.web.api.entity.ProcessorEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.util.Collections; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; public class JoinClusterAdjustStateIT extends NiFiSystemIT { @Override - protected NiFiInstanceFactory getInstanceFactory() { + public NiFiInstanceFactory getInstanceFactory() { return new SpawnedClusterNiFiInstanceFactory( new InstanceConfiguration.Builder() .bootstrapConfig("src/test/resources/conf/clustered/node1/bootstrap.conf") diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/JoinClusterWithDifferentFlow.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/JoinClusterWithDifferentFlow.java index f6f9ea688e..c53bd0b3d9 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/JoinClusterWithDifferentFlow.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/JoinClusterWithDifferentFlow.java @@ -45,7 +45,7 @@ import org.apache.nifi.web.api.entity.ControllerServicesEntity; import org.apache.nifi.web.api.entity.NodeEntity; import org.apache.nifi.web.api.entity.ParameterEntity; import org.apache.nifi.web.api.entity.ProcessorEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.InputSource; @@ -69,12 +69,12 @@ import java.util.Properties; import java.util.Set; import java.util.zip.GZIPInputStream; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; public class JoinClusterWithDifferentFlow extends NiFiSystemIT { @Override - protected NiFiInstanceFactory getInstanceFactory() { + public NiFiInstanceFactory getInstanceFactory() { final Map propertyOverrides = Collections.singletonMap("nifi.cluster.flow.serialization.format", "XML"); return new SpawnedClusterNiFiInstanceFactory( diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/JoinClusterWithMissingConnectionNoData.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/JoinClusterWithMissingConnectionNoData.java index 37d681ebeb..dc69d12173 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/JoinClusterWithMissingConnectionNoData.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/JoinClusterWithMissingConnectionNoData.java @@ -20,11 +20,11 @@ import org.apache.nifi.tests.system.InstanceConfiguration; import org.apache.nifi.tests.system.NiFiInstanceFactory; import org.apache.nifi.tests.system.NiFiSystemIT; import org.apache.nifi.tests.system.SpawnedClusterNiFiInstanceFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JoinClusterWithMissingConnectionNoData extends NiFiSystemIT { @Override - protected NiFiInstanceFactory getInstanceFactory() { + public NiFiInstanceFactory getInstanceFactory() { return new SpawnedClusterNiFiInstanceFactory( new InstanceConfiguration.Builder() .bootstrapConfig("src/test/resources/conf/clustered/node1/bootstrap.conf") diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/JoinClusterWithMissingConnectionWithData.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/JoinClusterWithMissingConnectionWithData.java index 5d747be67f..d5fcde5625 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/JoinClusterWithMissingConnectionWithData.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/JoinClusterWithMissingConnectionWithData.java @@ -27,7 +27,7 @@ import org.apache.nifi.web.api.dto.flow.FlowDTO; import org.apache.nifi.web.api.entity.ConnectionEntity; import org.apache.nifi.web.api.entity.NodeEntity; import org.apache.nifi.web.api.entity.ProcessorEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; @@ -36,7 +36,7 @@ public class JoinClusterWithMissingConnectionWithData extends NiFiSystemIT { private static final String CONNECTION_UUID = "6be9a991-016e-1000-ffff-fffffebf0217"; @Override - protected NiFiInstanceFactory getInstanceFactory() { + public NiFiInstanceFactory getInstanceFactory() { return new SpawnedClusterNiFiInstanceFactory( new InstanceConfiguration.Builder() .bootstrapConfig("src/test/resources/conf/clustered/node1/bootstrap.conf") diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/NodeRestartWithNewNodeIdIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/NodeRestartWithNewNodeIdIT.java index a1a608b096..a576196b49 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/NodeRestartWithNewNodeIdIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/NodeRestartWithNewNodeIdIT.java @@ -23,20 +23,20 @@ import org.apache.nifi.tests.system.SpawnedClusterNiFiInstanceFactory; import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException; import org.apache.nifi.web.api.dto.NodeDTO; import org.apache.nifi.web.api.entity.ClusteSummaryEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; import java.util.Collection; -import static junit.framework.TestCase.assertTrue; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; public class NodeRestartWithNewNodeIdIT extends NiFiSystemIT { @Override - protected NiFiInstanceFactory getInstanceFactory() { + public NiFiInstanceFactory getInstanceFactory() { return new SpawnedClusterNiFiInstanceFactory( "src/test/resources/conf/clustered/node1/bootstrap.conf", "src/test/resources/conf/clustered/node2/bootstrap.conf"); diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/OffloadIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/OffloadIT.java index e806cefa21..f535325469 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/OffloadIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/OffloadIT.java @@ -26,7 +26,7 @@ import org.apache.nifi.web.api.dto.ProcessorConfigDTO; import org.apache.nifi.web.api.entity.ClusterEntity; import org.apache.nifi.web.api.entity.ConnectionEntity; import org.apache.nifi.web.api.entity.ProcessorEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,7 +37,7 @@ public class OffloadIT extends NiFiSystemIT { private static final Logger logger = LoggerFactory.getLogger(OffloadIT.class); @Override - protected NiFiInstanceFactory getInstanceFactory() { + public NiFiInstanceFactory getInstanceFactory() { return new SpawnedClusterNiFiInstanceFactory( "src/test/resources/conf/clustered/node1/bootstrap.conf", "src/test/resources/conf/clustered/node2/bootstrap.conf"); diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/RestartWithDifferentPort.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/RestartWithDifferentPort.java index c0c5b5dac1..578e6c14c5 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/RestartWithDifferentPort.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/RestartWithDifferentPort.java @@ -24,19 +24,19 @@ import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException; import org.apache.nifi.web.api.dto.NodeDTO; import org.apache.nifi.web.api.entity.ClusteSummaryEntity; import org.apache.nifi.web.api.entity.ClusterEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collection; import java.util.Set; import java.util.stream.Collectors; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class RestartWithDifferentPort extends NiFiSystemIT { @Override - protected NiFiInstanceFactory getInstanceFactory() { + public NiFiInstanceFactory getInstanceFactory() { return new SpawnedClusterNiFiInstanceFactory( "src/test/resources/conf/clustered/node1/bootstrap.conf", "src/test/resources/conf/clustered/node2/bootstrap.conf"); diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/SimpleNodeRestartIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/SimpleNodeRestartIT.java index cb6c48227d..1e15eb8d52 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/SimpleNodeRestartIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/clustering/SimpleNodeRestartIT.java @@ -22,16 +22,16 @@ import org.apache.nifi.tests.system.NiFiInstanceFactory; import org.apache.nifi.tests.system.NiFiSystemIT; import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException; import org.apache.nifi.web.api.entity.ClusteSummaryEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class SimpleNodeRestartIT extends NiFiSystemIT { @Override - protected NiFiInstanceFactory getInstanceFactory() { + public NiFiInstanceFactory getInstanceFactory() { return new SpawnedClusterNiFiInstanceFactory( "src/test/resources/conf/clustered/node1/bootstrap.conf", "src/test/resources/conf/clustered/node2/bootstrap.conf"); diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/controllerservice/ControllerServiceApiValidationIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/controllerservice/ControllerServiceApiValidationIT.java index 7f6f5cea86..5cc6dc07ed 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/controllerservice/ControllerServiceApiValidationIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/controllerservice/ControllerServiceApiValidationIT.java @@ -21,12 +21,12 @@ import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException; import org.apache.nifi.web.api.entity.ControllerServiceEntity; import org.apache.nifi.web.api.entity.ControllerServiceRunStatusEntity; import org.apache.nifi.web.api.entity.ProcessorEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class ControllerServiceApiValidationIT extends NiFiSystemIT { @Test diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/controllerservice/DependentControllerServiceIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/controllerservice/DependentControllerServiceIT.java index 90950f769e..9238297ad0 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/controllerservice/DependentControllerServiceIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/controllerservice/DependentControllerServiceIT.java @@ -24,7 +24,7 @@ import org.apache.nifi.web.api.entity.ControllerServiceReferencingComponentEntit import org.apache.nifi.web.api.entity.ControllerServiceReferencingComponentsEntity; import org.apache.nifi.web.api.entity.ControllerServiceRunStatusEntity; import org.apache.nifi.web.api.entity.UpdateControllerServiceReferenceRequestEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/loadbalance/LoadBalanceIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/loadbalance/LoadBalanceIT.java index 0890f71c0e..2e1b1c0698 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/loadbalance/LoadBalanceIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/loadbalance/LoadBalanceIT.java @@ -34,8 +34,7 @@ import org.apache.nifi.web.api.entity.ConnectionEntity; import org.apache.nifi.web.api.entity.ConnectionStatusEntity; import org.apache.nifi.web.api.entity.FlowFileEntity; import org.apache.nifi.web.api.entity.ProcessorEntity; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -47,14 +46,14 @@ import java.util.LongSummaryStatistics; import java.util.Map; import java.util.Set; -import static junit.framework.TestCase.assertTrue; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; public class LoadBalanceIT extends NiFiSystemIT { private final Logger logger = LoggerFactory.getLogger(getClass()); @Override - protected NiFiInstanceFactory getInstanceFactory() { + public NiFiInstanceFactory getInstanceFactory() { return new SpawnedClusterNiFiInstanceFactory( "src/test/resources/conf/clustered/node1/bootstrap.conf", "src/test/resources/conf/clustered/node2/bootstrap.conf"); @@ -219,7 +218,7 @@ public class LoadBalanceIT extends NiFiSystemIT { assertEquals(10, nodesByAttribute.size()); for (final Map.Entry> entry : nodesByAttribute.entrySet()) { final Set nodes = entry.getValue(); - assertEquals("FlowFile with attribute number=" + entry.getKey() + " went to nodes " + nodes, 1, nodes.size()); + assertEquals(1, nodes.size(), "FlowFile with attribute number=" + entry.getKey() + " went to nodes " + nodes); } } @@ -303,8 +302,7 @@ public class LoadBalanceIT extends NiFiSystemIT { try { return getNifiClient().getFlowClient().getConnectionStatus(connectionId, true); } catch (final Exception e) { - Assert.fail("Failed to obtain connection status"); - return null; + throw new RuntimeException("Failed to obtain connection status"); } } diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/parameters/ClusteredParameterContextIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/parameters/ClusteredParameterContextIT.java index 4f994feaf9..56063310c9 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/parameters/ClusteredParameterContextIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/parameters/ClusteredParameterContextIT.java @@ -24,7 +24,7 @@ import org.apache.nifi.tests.system.NiFiInstanceFactory; */ public class ClusteredParameterContextIT extends ParameterContextIT { @Override - protected NiFiInstanceFactory getInstanceFactory() { + public NiFiInstanceFactory getInstanceFactory() { return new SpawnedClusterNiFiInstanceFactory( "src/test/resources/conf/clustered/node1/bootstrap.conf", "src/test/resources/conf/clustered/node2/bootstrap.conf"); diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/parameters/ParameterContextIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/parameters/ParameterContextIT.java index 4e5e45b88d..9526d62540 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/parameters/ParameterContextIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/parameters/ParameterContextIT.java @@ -31,7 +31,8 @@ import org.apache.nifi.web.api.entity.ParameterContextUpdateRequestEntity; import org.apache.nifi.web.api.entity.ParameterEntity; import org.apache.nifi.web.api.entity.ProcessGroupEntity; import org.apache.nifi.web.api.entity.ProcessorEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import java.io.File; import java.io.IOException; @@ -46,11 +47,11 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ParameterContextIT extends NiFiSystemIT { @Test @@ -181,7 +182,8 @@ public class ParameterContextIT extends NiFiSystemIT { waitForValidProcessor(processorId); } - @Test(timeout=30000) + @Timeout(30) + @Test public void testValidationWithRequiredPropertiesAndNoDefault() throws NiFiClientException, IOException, InterruptedException { final ProcessorEntity generate = getClientUtil().createProcessor("DependOnProperties"); final Map properties = new HashMap<>(); diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/pg/BatchFlowBetweenGroupsIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/pg/BatchFlowBetweenGroupsIT.java index 19851b1771..5c682b07f3 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/pg/BatchFlowBetweenGroupsIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/pg/BatchFlowBetweenGroupsIT.java @@ -25,7 +25,7 @@ import org.apache.nifi.web.api.entity.ConnectionEntity; import org.apache.nifi.web.api.entity.PortEntity; import org.apache.nifi.web.api.entity.ProcessGroupEntity; import org.apache.nifi.web.api.entity.ProcessorEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/pg/SingleFlowFileConcurrencyIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/pg/SingleFlowFileConcurrencyIT.java index 18f9f9ed4f..99a28ec5a0 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/pg/SingleFlowFileConcurrencyIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/pg/SingleFlowFileConcurrencyIT.java @@ -26,15 +26,15 @@ import org.apache.nifi.web.api.entity.FlowFileEntity; import org.apache.nifi.web.api.entity.PortEntity; import org.apache.nifi.web.api.entity.ProcessGroupEntity; import org.apache.nifi.web.api.entity.ProcessorEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class SingleFlowFileConcurrencyIT extends NiFiSystemIT { diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/processor/RetryIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/processor/RetryIT.java index 70787eafb0..f5d9bc88bb 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/processor/RetryIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/processor/RetryIT.java @@ -22,7 +22,7 @@ import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException; import org.apache.nifi.web.api.dto.ProcessorConfigDTO; import org.apache.nifi.web.api.entity.ConnectionEntity; import org.apache.nifi.web.api.entity.ProcessorEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Arrays; @@ -32,7 +32,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class RetryIT extends NiFiSystemIT { private static final int RETRY_COUNT = 2; diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/processor/RunOnceIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/processor/RunOnceIT.java index db6bbc6e9e..bda3ac58ed 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/processor/RunOnceIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/processor/RunOnceIT.java @@ -20,15 +20,17 @@ import org.apache.nifi.tests.system.NiFiSystemIT; import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException; import org.apache.nifi.web.api.entity.ConnectionEntity; import org.apache.nifi.web.api.entity.ProcessorEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import java.io.IOException; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class RunOnceIT extends NiFiSystemIT { - @Test(timeout = 10000L) + @Timeout(10) + @Test public void testRunOnce() throws NiFiClientException, IOException, InterruptedException { ProcessorEntity generate = getClientUtil().createProcessor("GenerateFlowFile"); getClientUtil().updateProcessorSchedulingPeriod(generate, "1 sec"); diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/provenance/ProvenanceRepositoryIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/provenance/ProvenanceRepositoryIT.java index c36fc46fdf..5665a46bf8 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/provenance/ProvenanceRepositoryIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/provenance/ProvenanceRepositoryIT.java @@ -25,7 +25,7 @@ import org.apache.nifi.web.api.dto.provenance.ProvenanceEventDTO; import org.apache.nifi.web.api.dto.provenance.ProvenanceSearchValueDTO; import org.apache.nifi.web.api.entity.ProcessorEntity; import org.apache.nifi.web.api.entity.ProvenanceEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; @@ -34,7 +34,7 @@ import java.util.List; import java.util.Map; import java.util.function.Predicate; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class ProvenanceRepositoryIT extends NiFiSystemIT { diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/reportingtask/ReportingTaskIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/reportingtask/ReportingTaskIT.java index 5b1c75ea45..c9e1fdf69f 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/reportingtask/ReportingTaskIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/reportingtask/ReportingTaskIT.java @@ -21,7 +21,7 @@ import org.apache.nifi.tests.system.NiFiSystemIT; import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException; import org.apache.nifi.web.api.entity.ControllerServiceEntity; import org.apache.nifi.web.api.entity.ReportingTaskEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/repositories/ContentAccessIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/repositories/ContentAccessIT.java index 1a3790fcbb..bca8e1c628 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/repositories/ContentAccessIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/repositories/ContentAccessIT.java @@ -21,7 +21,7 @@ import org.apache.nifi.tests.system.NiFiSystemIT; import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException; import org.apache.nifi.web.api.entity.ConnectionEntity; import org.apache.nifi.web.api.entity.ProcessorEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; @@ -30,7 +30,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * This test is intended to verify that Processors are able to access the content that their FlowFiles represent in several different situations. diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/restart/FlowFileRestorationIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/restart/FlowFileRestorationIT.java index 3cecadb91d..747103cdb7 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/restart/FlowFileRestorationIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/restart/FlowFileRestorationIT.java @@ -23,8 +23,7 @@ import org.apache.nifi.tests.system.NiFiSystemIT; import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException; import org.apache.nifi.web.api.entity.ConnectionEntity; import org.apache.nifi.web.api.entity.ProcessorEntity; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.ByteArrayOutputStream; import java.io.File; @@ -34,10 +33,11 @@ import java.nio.file.Files; import java.nio.file.StandardOpenOption; import java.util.Collections; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; public class FlowFileRestorationIT extends NiFiSystemIT { @@ -72,12 +72,7 @@ public class FlowFileRestorationIT extends NiFiSystemIT { nifiInstance.start(); - try { - getNifiClient().getConnectionClient().getConnection(connection.getId()); - Assert.fail("Didn't expect to retrieve a connection"); - } catch (final NiFiClientException nfce) { - // Expected because the connection no longer exists. - } + assertThrows(NiFiClientException.class, () -> getNifiClient().getConnectionClient().getConnection(connection.getId())); // Stop the instance, restore the flow.xml.gz, and restart nifiInstance.stop(); diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/rpg/ClusteredRemoteProcessGroupIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/rpg/ClusteredRemoteProcessGroupIT.java index 421d41b6d1..a1b98e392f 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/rpg/ClusteredRemoteProcessGroupIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/rpg/ClusteredRemoteProcessGroupIT.java @@ -21,7 +21,7 @@ import org.apache.nifi.tests.system.SpawnedClusterNiFiInstanceFactory; public class ClusteredRemoteProcessGroupIT extends RemoteProcessGroupIT { @Override - protected NiFiInstanceFactory getInstanceFactory() { + public NiFiInstanceFactory getInstanceFactory() { return new SpawnedClusterNiFiInstanceFactory( "src/test/resources/conf/clustered/node1/bootstrap.conf", "src/test/resources/conf/clustered/node2/bootstrap.conf"); diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/rpg/RemoteProcessGroupIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/rpg/RemoteProcessGroupIT.java index 4bc76b6e14..b25f8d1144 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/rpg/RemoteProcessGroupIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/rpg/RemoteProcessGroupIT.java @@ -26,8 +26,7 @@ import org.apache.nifi.web.api.entity.ConnectionEntity; import org.apache.nifi.web.api.entity.PortEntity; import org.apache.nifi.web.api.entity.ProcessorEntity; import org.apache.nifi.web.api.entity.RemoteProcessGroupEntity; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; @@ -82,9 +81,7 @@ public class RemoteProcessGroupIT extends NiFiSystemIT { return false; } catch (Exception e) { - e.printStackTrace(); - Assert.fail("Could not retrieve RPG with ID " + rpgId); - return false; + throw new RuntimeException("Could not retrieve RPG with ID " + rpgId); } }); diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/validation/DependentPropertyValidationIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/validation/DependentPropertyValidationIT.java index 8704de917b..5d58fd4e85 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/validation/DependentPropertyValidationIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/validation/DependentPropertyValidationIT.java @@ -20,7 +20,8 @@ package org.apache.nifi.tests.system.validation; import org.apache.nifi.tests.system.NiFiSystemIT; import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException; import org.apache.nifi.web.api.entity.ProcessorEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import java.io.IOException; import java.util.Collections; @@ -29,7 +30,8 @@ import java.util.Map; public class DependentPropertyValidationIT extends NiFiSystemIT { - @Test(timeout = 20_000) + @Timeout(20) + @Test public void testPropertyDependenciesAreValidatedProperly() throws NiFiClientException, IOException, InterruptedException { final ProcessorEntity processor = getClientUtil().createProcessor("DependOnProperties"); getClientUtil().updateProcessorProperties(processor, Collections.singletonMap("Always Required", "foo")); diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/variables/ProcessGroupVariablesIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/variables/ProcessGroupVariablesIT.java index 908a8a992c..3217a3ae2e 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/variables/ProcessGroupVariablesIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/variables/ProcessGroupVariablesIT.java @@ -22,12 +22,12 @@ import org.apache.nifi.web.api.entity.ConnectionEntity; import org.apache.nifi.web.api.entity.FlowFileEntity; import org.apache.nifi.web.api.entity.ProcessGroupEntity; import org.apache.nifi.web.api.entity.ProcessorEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class ProcessGroupVariablesIT extends NiFiSystemIT { diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/ClusteredVerifiableControllerServiceSystemIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/ClusteredVerifiableControllerServiceSystemIT.java index 3cbfc3edc3..30d1df2727 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/ClusteredVerifiableControllerServiceSystemIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/ClusteredVerifiableControllerServiceSystemIT.java @@ -23,18 +23,18 @@ import org.apache.nifi.tests.system.SpawnedClusterNiFiInstanceFactory; import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException; import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO; import org.apache.nifi.web.api.entity.ControllerServiceEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class ClusteredVerifiableControllerServiceSystemIT extends VerifiableControllerServiceSystemIT { @Override - protected NiFiInstanceFactory getInstanceFactory() { + public NiFiInstanceFactory getInstanceFactory() { return new SpawnedClusterNiFiInstanceFactory( "src/test/resources/conf/clustered/node1/bootstrap.conf", "src/test/resources/conf/clustered/node2/bootstrap.conf"); diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/ClusteredVerifiableProcessorSystemIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/ClusteredVerifiableProcessorSystemIT.java index 3f3a83b58c..8f2502fab5 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/ClusteredVerifiableProcessorSystemIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/ClusteredVerifiableProcessorSystemIT.java @@ -23,19 +23,19 @@ import org.apache.nifi.tests.system.SpawnedClusterNiFiInstanceFactory; import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException; import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO; import org.apache.nifi.web.api.entity.ProcessorEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class ClusteredVerifiableProcessorSystemIT extends VerifiableProcessorSystemIT { @Override - protected NiFiInstanceFactory getInstanceFactory() { + public NiFiInstanceFactory getInstanceFactory() { return new SpawnedClusterNiFiInstanceFactory( "src/test/resources/conf/clustered/node1/bootstrap.conf", "src/test/resources/conf/clustered/node2/bootstrap.conf"); diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/ClusteredVerifiableReportingTaskSystemIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/ClusteredVerifiableReportingTaskSystemIT.java index d24585dc5f..04a25d05a4 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/ClusteredVerifiableReportingTaskSystemIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/ClusteredVerifiableReportingTaskSystemIT.java @@ -23,19 +23,19 @@ import org.apache.nifi.tests.system.SpawnedClusterNiFiInstanceFactory; import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException; import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO; import org.apache.nifi.web.api.entity.ReportingTaskEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class ClusteredVerifiableReportingTaskSystemIT extends VerifiableReportingTaskSystemIT { @Override - protected NiFiInstanceFactory getInstanceFactory() { + public NiFiInstanceFactory getInstanceFactory() { return new SpawnedClusterNiFiInstanceFactory( "src/test/resources/conf/clustered/node1/bootstrap.conf", "src/test/resources/conf/clustered/node2/bootstrap.conf"); diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/VerifiableControllerServiceSystemIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/VerifiableControllerServiceSystemIT.java index 6109f382b5..3a79b0f931 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/VerifiableControllerServiceSystemIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/VerifiableControllerServiceSystemIT.java @@ -22,7 +22,7 @@ import org.apache.nifi.tests.system.NiFiSystemIT; import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException; import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO; import org.apache.nifi.web.api.entity.ControllerServiceEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; @@ -30,8 +30,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class VerifiableControllerServiceSystemIT extends NiFiSystemIT { @@ -88,7 +88,7 @@ public class VerifiableControllerServiceSystemIT extends NiFiSystemIT { // Verify using attributes that should give us a successful verification List resultList = getClientUtil().verifyControllerServiceConfig(service.getId(), properties, goodAttributes); - assertEquals("Got unexpected results: " + resultList, 7, resultList.size()); + assertEquals(7, resultList.size()); // Should have SUCCESS for validation, then 5 successes for the steps. Then 1 skipped for the Fail on Primary Node for (int i=0; i < resultList.size() - 1; i++) { @@ -139,7 +139,7 @@ public class VerifiableControllerServiceSystemIT extends NiFiSystemIT { } @Test - public void testVerificationWithValidConfigWhenComponentRunning() throws InterruptedException, IOException, NiFiClientException { + public void testVerificationWithValidConfigWhenComponentRunning() throws IOException, NiFiClientException { final ControllerServiceEntity service = getClientUtil().createControllerService("EnsureControllerServiceConfigurationCorrect"); final Map properties = Collections.singletonMap("Successful Verification", "true"); @@ -147,9 +147,7 @@ public class VerifiableControllerServiceSystemIT extends NiFiSystemIT { getClientUtil().enableControllerService(service); - assertThrows(NiFiClientException.class, () -> { - getClientUtil().verifyControllerServiceConfig(service.getId(), properties); - }); + assertThrows(NiFiClientException.class, () -> getClientUtil().verifyControllerServiceConfig(service.getId(), properties)); } @@ -179,7 +177,7 @@ public class VerifiableControllerServiceSystemIT extends NiFiSystemIT { assertEquals(1, resultList.size()); // Even though GenerateFlowFile is not connected, it should be valid because connections are not considered when verifying the processor - assertEquals("Unexpected results: " + resultList, Outcome.SUCCESSFUL.name(), resultList.get(0).getOutcome()); + assertEquals(Outcome.SUCCESSFUL.name(), resultList.get(0).getOutcome()); } @Test @@ -189,7 +187,7 @@ public class VerifiableControllerServiceSystemIT extends NiFiSystemIT { final List resultList = getClientUtil().verifyControllerServiceConfig(service.getId(), Collections.singletonMap("Validate Sleep Time", "foo")); assertEquals(1, resultList.size()); - assertEquals("Unexpected results: " + resultList, Outcome.FAILED.name(), resultList.get(0).getOutcome()); + assertEquals(Outcome.FAILED.name(), resultList.get(0).getOutcome()); } } diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/VerifiableProcessorSystemIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/VerifiableProcessorSystemIT.java index dbf1153374..40dc32cfac 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/VerifiableProcessorSystemIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/VerifiableProcessorSystemIT.java @@ -22,7 +22,7 @@ import org.apache.nifi.tests.system.NiFiSystemIT; import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException; import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO; import org.apache.nifi.web.api.entity.ProcessorEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; @@ -30,8 +30,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class VerifiableProcessorSystemIT extends NiFiSystemIT { @@ -89,7 +89,7 @@ public class VerifiableProcessorSystemIT extends NiFiSystemIT { // Verify using attributes that should give us a successful verification List resultList = getClientUtil().verifyProcessorConfig(processor.getId(), properties, goodAttributes); - assertEquals("Got unexpected results: " + resultList, 7, resultList.size()); + assertEquals(7, resultList.size()); // Should have SUCCESS for validation, then 5 successes for the steps. Then 1 skipped for the Fail on Primary Node for (int i=0; i < resultList.size() - 1; i++) { @@ -155,9 +155,7 @@ public class VerifiableProcessorSystemIT extends NiFiSystemIT { getClientUtil().startProcessGroupComponents("root"); getClientUtil().waitForProcessorState(processor.getId(), "RUNNING"); - assertThrows(NiFiClientException.class, () -> { - getClientUtil().verifyProcessorConfig(processor.getId(), properties); - }); + assertThrows(NiFiClientException.class, () -> getClientUtil().verifyProcessorConfig(processor.getId(), properties)); } @Test @@ -210,7 +208,7 @@ public class VerifiableProcessorSystemIT extends NiFiSystemIT { assertEquals(1, resultList.size()); // Even though GenerateFlowFile is not connected, it should be valid because connections are not considered when verifying the processor - assertEquals("Unexpected results: " + resultList, Outcome.SUCCESSFUL.name(), resultList.get(0).getOutcome()); + assertEquals(Outcome.SUCCESSFUL.name(), resultList.get(0).getOutcome()); } @Test @@ -220,7 +218,7 @@ public class VerifiableProcessorSystemIT extends NiFiSystemIT { final List resultList = getClientUtil().verifyProcessorConfig(processor.getId(), Collections.singletonMap("File Size", "foo")); assertEquals(1, resultList.size()); - assertEquals("Unexpected results: " + resultList, Outcome.FAILED.name(), resultList.get(0).getOutcome()); + assertEquals(Outcome.FAILED.name(), resultList.get(0).getOutcome()); } } diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/VerifiableReportingTaskSystemIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/VerifiableReportingTaskSystemIT.java index 4b84297755..bc0f6610a7 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/VerifiableReportingTaskSystemIT.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/verification/VerifiableReportingTaskSystemIT.java @@ -23,7 +23,7 @@ import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException; import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO; import org.apache.nifi.web.api.entity.ReportingTaskEntity; import org.apache.nifi.web.api.entity.ReportingTaskRunStatusEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; @@ -31,8 +31,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class VerifiableReportingTaskSystemIT extends NiFiSystemIT { @@ -154,7 +154,7 @@ public class VerifiableReportingTaskSystemIT extends NiFiSystemIT { assertEquals(1, resultList.size()); // Even though GenerateFlowFile is not connected, it should be valid because connections are not considered when verifying the processor - assertEquals("Unexpected results: " + resultList, Outcome.SUCCESSFUL.name(), resultList.get(0).getOutcome()); + assertEquals(Outcome.SUCCESSFUL.name(), resultList.get(0).getOutcome()); } @Test