Search in sources :

Example 1 with KsqlRestClient

use of io.confluent.ksql.rest.client.KsqlRestClient in project ksql by confluentinc.

the class CliTest method shouldPrintErrorIfCantConnectToRestServer.

@Test
public void shouldPrintErrorIfCantConnectToRestServer() {
    new Cli(1L, 1L, new KsqlRestClient("xxxx", Collections.emptyMap()), terminal);
    assertThat(terminal.getOutputString(), containsString("Remote server address may not be valid"));
}
Also used : Cli(io.confluent.ksql.cli.Cli) KsqlRestClient(io.confluent.ksql.rest.client.KsqlRestClient) IntegrationTest(io.confluent.common.utils.IntegrationTest) Test(org.junit.Test)

Example 2 with KsqlRestClient

use of io.confluent.ksql.rest.client.KsqlRestClient in project ksql by confluentinc.

the class CliTest method shouldRegisterRemoteCommand.

@Test
public void shouldRegisterRemoteCommand() {
    new Cli(1L, 1L, new KsqlRestClient("xxxx", Collections.emptyMap()), terminal);
    assertThat(terminal.getCliSpecificCommands().get("server"), instanceOf(Cli.RemoteServerSpecificCommand.class));
}
Also used : Cli(io.confluent.ksql.cli.Cli) KsqlRestClient(io.confluent.ksql.rest.client.KsqlRestClient) IntegrationTest(io.confluent.common.utils.IntegrationTest) Test(org.junit.Test)

Example 3 with KsqlRestClient

use of io.confluent.ksql.rest.client.KsqlRestClient in project ksql by confluentinc.

the class CliTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    KsqlRestClient restClient = new KsqlRestClient(LOCAL_REST_SERVER_ADDR);
    // TODO: Fix Properties Setup in Local().getCli()
    // Local local =  new Local().getCli();
    // LocalCli localCli = local.getCli(restClient, terminal);
    // TODO: add remote cli test cases
    terminal = new TestTerminal(CLI_OUTPUT_FORMAT, restClient);
    KsqlRestConfig restServerConfig = new KsqlRestConfig(defaultServerProperties());
    commandTopicName = restServerConfig.getCommandTopic(KsqlConfig.KSQL_SERVICE_ID_DEFAULT);
    orderDataProvider = new OrderDataProvider();
    CLUSTER.createTopic(orderDataProvider.topicName());
    KsqlRestApplication restServer = KsqlRestApplication.buildApplication(restServerConfig, false, EasyMock.mock(VersionCheckerAgent.class));
    restServer.start();
    localCli = new Cli(STREAMED_QUERY_ROW_LIMIT, STREAMED_QUERY_TIMEOUT_MS, restClient, terminal);
    TestRunner.setup(localCli, terminal);
    topicProducer = new TopicProducer(CLUSTER);
    topicConsumer = new TopicConsumer(CLUSTER);
    testListOrShowCommands();
    produceInputStream(orderDataProvider);
}
Also used : KsqlRestClient(io.confluent.ksql.rest.client.KsqlRestClient) KsqlRestApplication(io.confluent.ksql.rest.server.KsqlRestApplication) Cli(io.confluent.ksql.cli.Cli) KsqlRestConfig(io.confluent.ksql.rest.server.KsqlRestConfig) VersionCheckerAgent(io.confluent.ksql.version.metrics.VersionCheckerAgent) BeforeClass(org.junit.BeforeClass)

Example 4 with KsqlRestClient

use of io.confluent.ksql.rest.client.KsqlRestClient in project ksql by confluentinc.

the class Ksql method main.

public static void main(String[] args) throws IOException {
    final Options options = args.length == 0 ? Options.parse("http://localhost:8088") : Options.parse(args);
    if (options == null) {
        System.exit(-1);
    }
    final Properties properties = loadProperties(options.getConfigFile());
    final KsqlRestClient restClient = new KsqlRestClient(options.getServer(), properties);
    options.getUserNameAndPassword().ifPresent(creds -> restClient.setupAuthenticationCredentials(creds.left, creds.right));
    final KsqlVersionCheckerAgent versionChecker = new KsqlVersionCheckerAgent();
    versionChecker.start(KsqlModuleType.REMOTE_CLI, properties);
    try (final Cli cli = new Cli(options.getStreamedQueryRowLimit(), options.getStreamedQueryTimeoutMs(), restClient, new JLineTerminal(options.getOutputFormat(), restClient))) {
        cli.runInteractively();
    }
}
Also used : JLineTerminal(io.confluent.ksql.cli.console.JLineTerminal) Options(io.confluent.ksql.cli.Options) KsqlRestClient(io.confluent.ksql.rest.client.KsqlRestClient) Cli(io.confluent.ksql.cli.Cli) Properties(java.util.Properties) KsqlVersionCheckerAgent(io.confluent.ksql.version.metrics.KsqlVersionCheckerAgent)

Example 5 with KsqlRestClient

use of io.confluent.ksql.rest.client.KsqlRestClient in project ksql by confluentinc.

the class RemoteCliSpecificCommandTest method shouldPrintErrorOnErrorResponseFromRestClient.

@Test
public void shouldPrintErrorOnErrorResponseFromRestClient() {
    final Cli.RemoteServerSpecificCommand command = new Cli.RemoteServerSpecificCommand(new KsqlRestClient("xxxx", Collections.emptyMap()) {

        @Override
        public RestResponse<ServerInfo> getServerInfo() {
            return RestResponse.erroneous(new ErrorMessage("it is broken", Collections.emptyList()));
        }
    }, new PrintWriter(out));
    command.execute("http://localhost:8088");
    assertThat(out.toString(), containsString("it is broken"));
}
Also used : KsqlRestClient(io.confluent.ksql.rest.client.KsqlRestClient) RestResponse(io.confluent.ksql.rest.client.RestResponse) ErrorMessage(io.confluent.ksql.rest.entity.ErrorMessage) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Aggregations

KsqlRestClient (io.confluent.ksql.rest.client.KsqlRestClient)5 Cli (io.confluent.ksql.cli.Cli)4 Test (org.junit.Test)3 IntegrationTest (io.confluent.common.utils.IntegrationTest)2 Options (io.confluent.ksql.cli.Options)1 JLineTerminal (io.confluent.ksql.cli.console.JLineTerminal)1 RestResponse (io.confluent.ksql.rest.client.RestResponse)1 ErrorMessage (io.confluent.ksql.rest.entity.ErrorMessage)1 KsqlRestApplication (io.confluent.ksql.rest.server.KsqlRestApplication)1 KsqlRestConfig (io.confluent.ksql.rest.server.KsqlRestConfig)1 KsqlVersionCheckerAgent (io.confluent.ksql.version.metrics.KsqlVersionCheckerAgent)1 VersionCheckerAgent (io.confluent.ksql.version.metrics.VersionCheckerAgent)1 PrintWriter (java.io.PrintWriter)1 Properties (java.util.Properties)1 BeforeClass (org.junit.BeforeClass)1