Skip to content

Commit 5bb6ff7

Browse files
authored
Refactor ClusterTestHarness to extend generic SR test harness (#4007)
1 parent 61d7c21 commit 5bb6ff7

File tree

71 files changed

+1055
-1017
lines changed

Some content is hidden

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

71 files changed

+1055
-1017
lines changed

client-encryption/src/test/java/io/confluent/kafka/schemaregistry/encryption/RestApiFieldEncryptionTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public RestApiFieldEncryptionTest() {
8282
protected abstract EncryptionProperties getFieldEncryptionProperties(List<String> ruleNames);
8383

8484
@Override
85-
protected Properties getSchemaRegistryProperties() throws Exception {
85+
public Properties getSchemaRegistryProperties() throws Exception {
8686
Properties props = new Properties();
8787
props.setProperty("resource.extension.class", DekRegistryResourceExtension.class.getName());
8888
Object testClient = getFieldEncryptionProperties(null).getTestClient();
@@ -93,7 +93,7 @@ protected Properties getSchemaRegistryProperties() throws Exception {
9393
}
9494

9595
@Override
96-
protected void setUp() throws Exception {
96+
public void setUp() throws Exception {
9797
super.setUp();
9898
restApp.schemaRegistry().setRuleSetHandler(new RuleSetHandler() {
9999
public void handle(String subject, ConfigUpdateRequest request) {

client-encryption/src/test/java/io/confluent/kafka/schemaregistry/rules/WidgetBytesProto.java

Lines changed: 16 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client-encryption/src/test/java/io/confluent/kafka/schemaregistry/rules/WidgetProto.java

Lines changed: 14 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/src/test/java/io/confluent/kafka/schemaregistry/ClusterTestHarness.java

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
*/
7878
@Tag("IntegrationTest")
7979
@DisplayNameGeneration(AddKraftQuorum.class)
80-
public abstract class ClusterTestHarness {
80+
public abstract class ClusterTestHarness implements SchemaRegistryTestHarness {
8181

8282
private static final Logger log = LoggerFactory.getLogger(ClusterTestHarness.class);
8383

@@ -109,9 +109,10 @@ public static int[] choosePorts(int count) {
109109
/**
110110
* Choose an available port
111111
*/
112-
public static int choosePort() {
113-
return choosePorts(1)[0];
114-
}
112+
@Override
113+
public int choosePort() {
114+
return choosePorts(1)[0];
115+
}
115116

116117
private final int numBrokers;
117118
private final boolean setupRestApp;
@@ -156,7 +157,7 @@ public void setUpTest(TestInfo testInfo) throws Exception {
156157
log.info("Completed setup of {}", getClass().getSimpleName());
157158
}
158159

159-
protected void setUp() throws Exception {
160+
public void setUp() throws Exception {
160161
checkState(testInfo != null);
161162
log.info("Starting controller of {}", getClass().getSimpleName());
162163
// start controller
@@ -175,8 +176,7 @@ protected void setUp() throws Exception {
175176
setupAcls();
176177

177178
if (setupRestApp) {
178-
if (schemaRegistryPort == null)
179-
schemaRegistryPort = choosePort();
179+
schemaRegistryPort = getSchemaRegistryPort();
180180
Properties schemaRegistryProps = getSchemaRegistryProperties();
181181
if (!schemaRegistryProps.containsKey(SchemaRegistryConfig.LISTENERS_CONFIG)) {
182182
schemaRegistryProps.put(SchemaRegistryConfig.LISTENERS_CONFIG, getSchemaRegistryProtocol() +
@@ -189,17 +189,18 @@ protected void setUp() throws Exception {
189189
}
190190
}
191191

192-
protected void setupRestApp(Properties schemaRegistryProps) throws Exception {
192+
public void setupRestApp(Properties schemaRegistryProps) throws Exception {
193193
restApp = new RestApp(schemaRegistryPort, null, brokerList, KAFKASTORE_TOPIC,
194194
compatibilityType, true, schemaRegistryProps);
195195
restApp.start();
196196
}
197197

198-
protected Properties getSchemaRegistryProperties() throws Exception {
198+
public Properties getSchemaRegistryProperties() throws Exception {
199199
return new Properties();
200200
}
201201

202-
protected void injectProperties(Properties props) {
202+
@Override
203+
public void injectProperties(Properties props) {
203204
// Make sure that broker only role is "broker"
204205
props.setProperty("process.roles", "broker");
205206
props.setProperty("message.max.bytes", String.valueOf(MAX_MESSAGE_SIZE));
@@ -236,18 +237,36 @@ protected KafkaConfig getKafkaConfig(int brokerId) {
236237
return KafkaConfig.fromProps(props);
237238
}
238239

239-
protected SecurityProtocol getBrokerSecurityProtocol() {
240+
public SecurityProtocol getBrokerSecurityProtocol() {
240241
return SecurityProtocol.PLAINTEXT;
241242
}
242243

243-
protected String getSchemaRegistryProtocol() {
244+
@Override
245+
public String getSchemaRegistryProtocol() {
244246
return SchemaRegistryConfig.HTTP;
245247
}
246248

247-
protected Time brokerTime(int brokerId) {
249+
public Time brokerTime(int brokerId) {
248250
return Time.SYSTEM;
249251
}
250252

253+
@Override
254+
public String getBrokerList() {
255+
return brokerList;
256+
}
257+
258+
@Override
259+
public RestApp getRestApp() {
260+
return restApp;
261+
}
262+
263+
@Override
264+
public Integer getSchemaRegistryPort() {
265+
if (schemaRegistryPort == null)
266+
schemaRegistryPort = choosePort();
267+
return schemaRegistryPort;
268+
}
269+
251270
private void startBrokersConcurrently(int numBrokers) {
252271
log.info("Starting concurrently {} brokers for {}", numBrokers, getClass().getSimpleName());
253272
configs =

core/src/test/java/io/confluent/kafka/schemaregistry/SASLClusterTestHarness.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ public SASLClusterTestHarness() {
5151
}
5252

5353
@Override
54-
protected SecurityProtocol getBrokerSecurityProtocol() {
54+
public SecurityProtocol getBrokerSecurityProtocol() {
5555
return SecurityProtocol.SASL_PLAINTEXT;
5656
}
5757

5858
@Override
59-
protected void setUp() throws Exception {
59+
public void setUp() throws Exception {
6060
// Important if tests leak consumers, producers or brokers.
6161
LoginManager.closeAll();
6262

core/src/test/java/io/confluent/kafka/schemaregistry/SSLClusterTestHarness.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public SSLClusterTestHarness() {
3636
}
3737

3838
@Override
39-
protected SecurityProtocol getBrokerSecurityProtocol() {
39+
public SecurityProtocol getBrokerSecurityProtocol() {
4040
return SecurityProtocol.SSL;
4141
}
4242

0 commit comments

Comments
 (0)