Skip to content

Commit 62cb6c5

Browse files
committed
[FLINK-39408][tests] Fix TestNameProvider broken after JUnit 5 migration
TestNameProvider is a JUnit 4 TestRule that stores the test name in a ThreadLocal. After FLINK-39124 migrated modules to JUnit 5, the @rule is never triggered, so PseudoRandomValueSelector.randomize() always gets null from getCurrentTestName(), causing all boolean config randomizations to select the same fixed value. Fix: add TestNameProviderExtension (JUnit 5 BeforeEachCallback / AfterEachCallback) that delegates to TestNameProvider's static methods. TestNameProvider itself does not depend on JUnit 5 APIs, avoiding ClassNotFoundException in non-test runtime environments (e.g. PyFlink). Register TestNameProviderExtension globally via META-INF/services in all modules.
1 parent 795a36e commit 62cb6c5

57 files changed

Lines changed: 155 additions & 44 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

flink-clients/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
# limitations under the License.
1515

1616
org.apache.flink.util.TestLoggerExtension
17+
org.apache.flink.util.TestNameProviderExtension

flink-connectors/flink-connector-base/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
# limitations under the License.
1515

1616
org.apache.flink.util.TestLoggerExtension
17+
org.apache.flink.util.TestNameProviderExtension

flink-connectors/flink-connector-files/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
org.apache.flink.util.TestLoggerExtension
16+
org.apache.flink.util.TestLoggerExtension
17+
org.apache.flink.util.TestNameProviderExtension

flink-connectors/flink-file-sink-common/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
org.apache.flink.util.TestLoggerExtension
16+
org.apache.flink.util.TestLoggerExtension
17+
org.apache.flink.util.TestNameProviderExtension

flink-connectors/flink-hadoop-compatibility/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
# limitations under the License.
1515

1616
org.apache.flink.util.TestLoggerExtension
17+
org.apache.flink.util.TestNameProviderExtension

flink-container/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
org.apache.flink.util.TestLoggerExtension
16+
org.apache.flink.util.TestLoggerExtension
17+
org.apache.flink.util.TestNameProviderExtension

flink-core/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
org.apache.flink.util.TestLoggerExtension
16+
org.apache.flink.util.TestLoggerExtension
17+
org.apache.flink.util.TestNameProviderExtension

flink-docs/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
# limitations under the License.
1515

1616
org.apache.flink.util.TestLoggerExtension
17+
org.apache.flink.util.TestNameProviderExtension

flink-examples/flink-examples-table/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
org.apache.flink.util.TestLoggerExtension
16+
org.apache.flink.util.TestLoggerExtension
17+
org.apache.flink.util.TestNameProviderExtension

flink-external-resources/flink-external-resource-gpu/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
org.apache.flink.util.TestLoggerExtension
16+
org.apache.flink.util.TestLoggerExtension
17+
org.apache.flink.util.TestNameProviderExtension

0 commit comments

Comments
 (0)