mumrah commented on a change in pull request #9986:
URL: https://github.com/apache/kafka/pull/9986#discussion_r572387041



##########
File path: core/src/test/java/kafka/test/annotation/AutoStart.java
##########
@@ -0,0 +1,24 @@
+/*
+ * 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 kafka.test.annotation;
+
+public enum AutoStart {

Review comment:
       Since we can't use `null` as defaults for annotations, I added DEFAULT 
enum constants for cluster type and auto start attributes. When processing the 
`@ClusterTest` method annotations, if we see Type.DEFAULT or AutoStart.DEFAULT, 
we know the test method is saying "use the default". We could simply put the 
defaults right in the `ClusterTest` annotation, but then we would have an issue 
when method-level `@ClusterTest` and class-level `@ClusterTestDefaults` are 
both in use. How would we know which to use? 
   
   I added AutoStart.DEFAULT in order to let the method-level annotation 
explicitly defer to the default. Here's an example:
   
   ```java
   // indicate that for this test, we want to disable auto-start by default
   @ClusterTestDefaults(autoStart = false)
   public class TestClass {
     
     // but this test does want auto start
     @ClusterTest(autoStart = AutoStart.YES)
     public void test1() { }
   
     // this test is unnecessarily setting auto start as false
     @ClusterTest(autoStart = AutoStart.NO)
     public void test2() { }
   
     // this test will get its auto start value from the class level
     @ClusterTest
     public void test3() { }
   }
   ```
   
   An alternative would be to allow for a class-level annotation that 
completely overrides any method-level `@ClusterTest`, but that seems a little 
backwards.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to