-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Make sure internal client is configured for TLS (#5059)
- Loading branch information
Showing
11 changed files
with
179 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
...st/java/io/confluent/ksql/rest/integration/ShowQueriesMultiNodeWithTlsFunctionalTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* | ||
* Copyright 2020 Confluent Inc. | ||
* | ||
* Licensed under the Confluent Community License (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.confluent.io/confluent-community-license | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package io.confluent.ksql.rest.integration; | ||
|
||
import static io.confluent.ksql.test.util.AssertEventually.assertThatEventually; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
import io.confluent.common.utils.IntegrationTest; | ||
import io.confluent.ksql.integration.IntegrationTestHarness; | ||
import io.confluent.ksql.integration.Retry; | ||
import io.confluent.ksql.rest.entity.KsqlEntity; | ||
import io.confluent.ksql.rest.entity.Queries; | ||
import io.confluent.ksql.rest.entity.RunningQuery; | ||
import io.confluent.ksql.rest.server.KsqlRestConfig; | ||
import io.confluent.ksql.rest.server.TestKsqlRestApp; | ||
import io.confluent.ksql.serde.FormatFactory; | ||
import io.confluent.ksql.test.util.secure.ServerKeyStore; | ||
import io.confluent.ksql.util.PageViewDataProvider; | ||
import java.util.List; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.function.Supplier; | ||
import kafka.zookeeper.ZooKeeperClientException; | ||
import org.junit.BeforeClass; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
import org.junit.rules.RuleChain; | ||
|
||
@Category({IntegrationTest.class}) | ||
public class ShowQueriesMultiNodeWithTlsFunctionalTest { | ||
|
||
private static final PageViewDataProvider PAGE_VIEWS_PROVIDER = new PageViewDataProvider(); | ||
private static final String PAGE_VIEW_TOPIC = PAGE_VIEWS_PROVIDER.topicName(); | ||
private static final String PAGE_VIEW_STREAM = PAGE_VIEWS_PROVIDER.kstreamName(); | ||
private static final IntegrationTestHarness TEST_HARNESS = IntegrationTestHarness.build(); | ||
private static final TestKsqlRestApp REST_APP_0 = TestKsqlRestApp | ||
.builder(TEST_HARNESS::kafkaBootstrapServers) | ||
.withProperty(KsqlRestConfig.LISTENERS_CONFIG, | ||
"http://localhost:8088,https://localhost:8089") | ||
.withProperty(KsqlRestConfig.ADVERTISED_LISTENER_CONFIG, "https://localhost:8089") | ||
.withProperties(ServerKeyStore.keyStoreProps()) | ||
.withEnabledKsqlClient() | ||
.build(); | ||
private static final TestKsqlRestApp REST_APP_1 = TestKsqlRestApp | ||
.builder(TEST_HARNESS::kafkaBootstrapServers) | ||
.withProperty(KsqlRestConfig.LISTENERS_CONFIG, | ||
"http://localhost:8098,https://localhost:8099") | ||
.withProperty(KsqlRestConfig.ADVERTISED_LISTENER_CONFIG, "https://localhost:8099") | ||
.withProperties(ServerKeyStore.keyStoreProps()) | ||
.withEnabledKsqlClient() | ||
.build(); | ||
|
||
@ClassRule | ||
public static final RuleChain CHAIN = RuleChain | ||
.outerRule(Retry.of(3, ZooKeeperClientException.class, 3, TimeUnit.SECONDS)) | ||
.around(TEST_HARNESS) | ||
.around(REST_APP_0) | ||
.around(REST_APP_1); | ||
|
||
@BeforeClass | ||
public static void setUpClass() { | ||
TEST_HARNESS.ensureTopics(2, PAGE_VIEW_TOPIC); | ||
TEST_HARNESS.produceRows(PAGE_VIEW_TOPIC, PAGE_VIEWS_PROVIDER, FormatFactory.JSON); | ||
RestIntegrationTestUtil.createStream(REST_APP_0, PAGE_VIEWS_PROVIDER); | ||
RestIntegrationTestUtil.makeKsqlRequest( | ||
REST_APP_0, | ||
"CREATE STREAM S AS SELECT * FROM " + PAGE_VIEW_STREAM + ";" | ||
); | ||
} | ||
|
||
@Test | ||
public void shouldShowAllQueries() { | ||
// When: | ||
final Supplier<String> app0Response = () -> getShowQueriesResult(REST_APP_0); | ||
final Supplier<String> app1Response = () -> getShowQueriesResult(REST_APP_1); | ||
|
||
// Then: | ||
assertThatEventually("App0", app0Response, is("RUNNING:2")); | ||
assertThatEventually("App1", app1Response, is("RUNNING:2")); | ||
} | ||
|
||
private static String getShowQueriesResult(final TestKsqlRestApp restApp) { | ||
final List<KsqlEntity> results = RestIntegrationTestUtil.makeKsqlRequest( | ||
restApp, | ||
"Show Queries;" | ||
); | ||
|
||
if (results.size() != 1) { | ||
return "Expected 1 response, got " + results.size(); | ||
} | ||
|
||
final KsqlEntity result = results.get(0); | ||
|
||
if (!(result instanceof Queries)) { | ||
return "Expected Queries, got " + result; | ||
} | ||
|
||
final List<RunningQuery> runningQueries = ((Queries) result) | ||
.getQueries(); | ||
|
||
if (runningQueries.size() != 1) { | ||
return "Expected 1 running query, got " + runningQueries.size(); | ||
} | ||
|
||
return runningQueries.get(0).getState().orElse("N/A"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.