@Test public void shouldSetProperty() { // Given: final String csas = "CREATE STREAM " + streamName + " AS SELECT * FROM test_stream;"; // When: final List<CommandStatusEntity> results = makeMultipleRequest( "SET '" + KsqlConfig.SINK_NUMBER_OF_REPLICAS_PROPERTY + "' = '2';\n" + csas, CommandStatusEntity.class); // Then: verify(commandStore).enqueueCommand(eq(csas), any(), any(), eq(ImmutableMap.of(KsqlConfig.SINK_NUMBER_OF_REPLICAS_PROPERTY, "2"))); assertThat(results, hasSize(1)); assertThat(results.get(0).getStatementText(), is(csas)); }
@Test public void shouldUnsetProperty() { // Given: final String csas = "CREATE STREAM " + streamName + " AS SELECT * FROM test_stream;"; final Map<String, Object> localOverrides = ImmutableMap.of( KsqlConfig.SINK_NUMBER_OF_REPLICAS_PROPERTY, "2" ); // When: final CommandStatusEntity result = makeSingleRequest( new KsqlRequest("UNSET '" + KsqlConfig.SINK_NUMBER_OF_REPLICAS_PROPERTY + "';\n" + csas, localOverrides, null), CommandStatusEntity.class); // Then: verify(commandStore).enqueueCommand(eq(csas), any(), any(), eq(Collections.emptyMap())); assertThat(result.getStatementText(), is(csas)); }
@Test public void shouldDistributeTerminateQueryWithoutValidation() { // Why? Because currently if the server receives a single request containing two statements: // `CREATE STREAM FOO AS blah;` // `TERMINATE csas_foo_0;` // Then its possible that the terminate line is valid, in that it will terminate the query // started by the first line, but the server can no validate this as the CSAS may not have // be actioned by the StatementExecutor yet. // Given: final String terminateSql = "TERMINATE some_id;"; // When: final CommandStatusEntity result = makeSingleRequest(terminateSql, CommandStatusEntity.class); // Then: verify(commandStore).enqueueCommand(eq(terminateSql), isA(TerminateQuery.class), any(), any()); assertThat(result.getStatementText(), is(terminateSql)); }
@Test public void shouldDistributeTerminateQuery() { // Given: final PersistentQueryMetadata queryMetadata = createQuery( "CREATE STREAM test_explain AS SELECT * FROM test_stream;", Collections.emptyMap()); final String terminateSql = "TERMINATE " + queryMetadata.getQueryId() + ";"; // When: final CommandStatusEntity result = makeSingleRequest(terminateSql, CommandStatusEntity.class); // Then: verify(commandStore).enqueueCommand(eq(terminateSql), isA(TerminateQuery.class), any(), any()); assertThat(result.getStatementText(), is(terminateSql)); }