kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [kafka] branch trunk updated: KAFKA-7799; Fix flaky test RestServerTest.testCORSEnabled (#6106)
Date Wed, 09 Jan 2019 07:47:40 GMT
This is an automated email from the ASF dual-hosted git repository.

jgus pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 73a9fca  KAFKA-7799; Fix flaky test RestServerTest.testCORSEnabled (#6106)
73a9fca is described below

commit 73a9fcaa4db3f758dd8a16eff5651555ded1b8b7
Author: Jason Gustafson <jason@confluent.io>
AuthorDate: Tue Jan 8 23:47:28 2019 -0800

    KAFKA-7799; Fix flaky test RestServerTest.testCORSEnabled (#6106)
    
    The test always fails if testOptionsDoesNotIncludeWadlOutput is executed before testCORSEnabled.
It seems the problem is the use of the system property. Perhaps there is some static caching
somewhere.
    
    Reviewers: Randall Hauch <rhauch@gmail.com>, Guozhang Wang <wangguoz@gmail.com>
---
 .../org/apache/kafka/connect/runtime/rest/RestServerTest.java  | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/rest/RestServerTest.java
b/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/rest/RestServerTest.java
index a0fb685..39e35cb 100644
--- a/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/rest/RestServerTest.java
+++ b/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/rest/RestServerTest.java
@@ -27,6 +27,7 @@ import org.easymock.Capture;
 import org.easymock.EasyMock;
 import org.junit.After;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.powermock.api.easymock.PowerMock;
@@ -58,6 +59,12 @@ public class RestServerTest {
     private Plugins plugins;
     private RestServer server;
 
+    @Before
+    public void setUp() {
+        // To be able to set the Origin, we need to toggle this flag
+        System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
+    }
+
     @After
     public void tearDown() {
         server.stop();
@@ -185,13 +192,10 @@ public class RestServerTest {
     }
 
     public void checkCORSRequest(String corsDomain, String origin, String expectedHeader,
String method) {
-        // To be able to set the Origin, we need to toggle this flag
-
         Map<String, String> workerProps = baseWorkerProps();
         workerProps.put(WorkerConfig.ACCESS_CONTROL_ALLOW_ORIGIN_CONFIG, corsDomain);
         workerProps.put(WorkerConfig.ACCESS_CONTROL_ALLOW_METHODS_CONFIG, method);
         WorkerConfig workerConfig = new DistributedConfig(workerProps);
-        System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
 
         EasyMock.expect(herder.plugins()).andStubReturn(plugins);
         EasyMock.expect(plugins.newPlugins(Collections.emptyList(),


Mime
View raw message