chia7712 commented on code in PR #17019: URL: https://github.com/apache/kafka/pull/17019#discussion_r1734895192
########## .github/workflows/deflake.yml: ########## @@ -0,0 +1,77 @@ +# 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. + +name: 'Deflake a test' +on: + workflow_dispatch: + inputs: + test-module: + description: 'Gradle sub-module which contains the test being de-flaked. Should be like :core' + required: true + type: string + test-pattern: + description: 'Test class to de-flake. Should be like *SomeTest*' + required: true + type: string + test-repeat: + description: 'Number of times to invoke the test' Review Comment: Should we remind users that it works only for `ClusterTest`/`ClusterTemplate`/`ClusterTests`? ########## .github/workflows/deflake.yml: ########## @@ -0,0 +1,77 @@ +# 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. + +name: 'Deflake a test' +on: + workflow_dispatch: + inputs: + test-module: + description: 'Gradle sub-module which contains the test being de-flaked. Should be like :core' + required: true + type: string + test-pattern: + description: 'Test class to de-flake. Should be like *SomeTest*' + required: true + type: string + test-repeat: + description: 'Number of times to invoke the test' + required: true + type: number + default: 1 + java-version: + description: 'Java version to use.' + required: true + type: string + default: '17' + +jobs: + deflake: + runs-on: ubuntu-latest + name: Deflake JUnit tests + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Setup Gradle + uses: ./.github/actions/setup-gradle + with: + java-version: ${{ inputs.java-version }} + gradle-cache-read-only: true + develocity-access-key: ${{ secrets.GE_ACCESS_TOKEN }} + - name: Test + timeout-minutes: 60 + run: | + ./gradlew --build-cache --scan --continue \ + -PtestLoggingEvents=started,passed,skipped,failed \ + -PignoreFailures=true -PmaxParallelForks=2 \ + -PmaxTestRetries=1 -PmaxTestRetryFailures=10 \ Review Comment: Why we need this retry when we are going to loop them? ########## build.gradle: ########## @@ -476,6 +476,8 @@ subprojects { maxHeapSize = defaultMaxHeapSize jvmArgs = defaultJvmArgs + systemProperty("kafka.cluster.test.repeat", project.findProperty("kafka.cluster.test.repeat")) Review Comment: Could you add comment for this project variable? ########## core/src/test/java/kafka/test/junit/ClusterTestExtensions.java: ########## @@ -241,6 +241,26 @@ private List<TestTemplateInvocationContext> processClusterTestInternal(Extension .collect(Collectors.toList()); } + private List<TestTemplateInvocationContext> repeatTestContexts( + List<TestTemplateInvocationContext> contexts + ) { + int count; + try { + String repeatCount = System.getProperty("kafka.cluster.test.repeat", "1"); + count = Integer.parseInt(repeatCount); + } catch (NumberFormatException e) { + count = 1; + } + if (count <= 1) { + return contexts; + } + List<TestTemplateInvocationContext> repeatedContexts = new ArrayList<>(contexts.size() * count); + for (int i = 0; i < count; i++) { + repeatedContexts.addAll(contexts); Review Comment: We don't create copy of contexts, so those contexts must a kind of immutable objects to avoid corruption caused by other run. Hence, could you add comments to `ZkClusterInvocationContext` and `RaftClusterInvocationContext` to highlight the requisite. Also, could you please move the `clusterReference` of `ZkClusterInvocationContext` to be a local variable to make `ZkClusterInvocationContext` be immutable. https://github.com/apache/kafka/blob/trunk/core/src/test/java/kafka/test/junit/ZkClusterInvocationContext.java#L78 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
