You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2022/04/15 00:55:38 UTC
[accumulo] branch main updated: Check for non Junit5 usage in CI (#2630)
This is an automated email from the ASF dual-hosted git repository.
ctubbsii pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push:
new f86f4927a6 Check for non Junit5 usage in CI (#2630)
f86f4927a6 is described below
commit f86f4927a6968fa95d3025f3612858619a46f63c
Author: Dom G <do...@gmail.com>
AuthorDate: Thu Apr 14 20:55:33 2022 -0400
Check for non Junit5 usage in CI (#2630)
* Fix found incorrect assert being used in a test
* Check for both vintage stuff in unapproved classes, as well as jupiter
stuff in the approved vintage classes
Co-authored-by: Christopher Tubbs <ct...@apache.org>
---
.github/workflows/maven.yaml | 2 +
contrib/ci/find-unapproved-junit.sh | 55 ++++++++++++++++++++++
.../test/functional/ServerSideErrorIT.java | 2 +-
3 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/maven.yaml b/.github/workflows/maven.yaml
index 0b063514eb..4c2c4a1db8 100644
--- a/.github/workflows/maven.yaml
+++ b/.github/workflows/maven.yaml
@@ -51,6 +51,8 @@ jobs:
run: git log -n1
- name: Check for unapproved characters
run: contrib/ci/find-unapproved-chars.sh
+ - name: Check for unapproved JUnit API usage
+ run: contrib/ci/find-unapproved-junit.sh
- name: Build with Maven (Fast Build)
timeout-minutes: 20
run: mvn -B -V -e -ntp "-Dstyle.color=always" clean package dependency:resolve -DskipTests -DskipFormat -DverifyFormat
diff --git a/contrib/ci/find-unapproved-junit.sh b/contrib/ci/find-unapproved-junit.sh
new file mode 100755
index 0000000000..a10bea4499
--- /dev/null
+++ b/contrib/ci/find-unapproved-junit.sh
@@ -0,0 +1,55 @@
+#! /usr/bin/env bash
+#
+# 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.
+#
+
+# The purpose of this ci script is to ensure that a pull request doesn't
+# unintentionally add JUnit jupiter APIs to vintage tests, or add vintage
+# APIs to new jupiter tests.
+NUM_EXPECTED=0
+ALLOWED=(
+ server/compaction-coordinator/src/test/java/org/apache/accumulo/coordinator/CompactionCoordinatorTest.java
+ server/compactor/src/test/java/org/apache/accumulo/compactor/CompactorTest.java
+ start/src/test/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoaderTest.java
+)
+
+ALLOWED_PIPE_SEP=$({ for x in "${ALLOWED[@]}"; do echo "$x" ; done; } | paste -sd'|')
+
+function findalljunitproblems() {
+ # -P for perl matching, -R for recursive, -l for matching files
+ local opts='-PRl'
+ if [[ $1 == 'print' ]]; then
+ # -P for perl matching, -R for recursive, -l for matching files, -H for always showing filenames
+ opts='-PRlH'
+ fi
+ # find any new classes using something other than the jupiter API, except those allowed
+ grep "$opts" --include='*.java' 'org[.]junit[.](?!jupiter)' | grep -Pv "^(${ALLOWED_PIPE_SEP//./[.]})\$"
+ # find any uses of the jupiter API in the allowed vintage classes
+ grep "$opts" 'org[.]junit[.]jupiter' "${ALLOWED[@]}"
+}
+
+function comparecounts() {
+ local count; count=$(findalljunitproblems | wc -l)
+ if [[ $NUM_EXPECTED -ne $count ]]; then
+ echo "Expected $NUM_EXPECTED, but found $count classes using the wrong JUnit APIs:"
+ findalljunitproblems 'print'
+ return 1
+ fi
+}
+
+comparecounts && echo "Found exactly $NUM_EXPECTED unapproved JUnit API uses, as expected"
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ServerSideErrorIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ServerSideErrorIT.java
index 8d8a91e39b..d2de6744c6 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ServerSideErrorIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ServerSideErrorIT.java
@@ -19,7 +19,7 @@
package org.apache.accumulo.test.functional;
import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.time.Duration;
import java.util.Collections;