@Override public int hashCode() { return Objects.hash(getStatus(), getMessage()); } }
@Override public boolean equals(final Object o) { if (this == o) { return true; } if (!(o instanceof CommandStatus)) { return false; } final CommandStatus that = (CommandStatus) o; return getStatus() == that.getStatus() && Objects.equals(getMessage(), that.getMessage()); }
@Override public Table buildTable(final CommandStatusEntity entity) { return new Table.Builder() .withColumnHeaders("Message") .withRow(entity.getCommandStatus().getMessage().split("\n", 2)[0]) .build(); } }
dropStreamCommandStatus1 .get() .getMessage(), containsString("io.confluent.ksql.util.KsqlReferentialIntegrityException: Cannot drop PAGEVIEW.")); assertThat( dropStreamCommandStatus1 .get() .getMessage(), containsString("The following queries read from this source: [CTAS_TABLE1_1, CSAS_USER1PV_0].")); assertThat( dropStreamCommandStatus1 .get() .getMessage(), containsString("The following queries write into this source: [].")); assertThat( dropStreamCommandStatus1 .get() .getMessage(), containsString("You need to terminate them before dropping PAGEVIEW.")); assertThat( dropStreamCommandStatus2.get() .getMessage(), containsString( "io.confluent.ksql.util.KsqlReferentialIntegrityException: Cannot drop USER1PV. \n")); assertThat( dropStreamCommandStatus2.get() .getMessage(), containsString(
@Test public void shouldFailInsertIntoIfExceedActivePersistentQueriesLimit() { // Given: createStreamsAndStartTwoPersistentQueries(); // Set limit and prepare to try adding a query that exceeds the limit final KsqlConfig cmdConfig = givenCommandConfig(KsqlConfig.KSQL_ACTIVE_PERSISTENT_QUERY_LIMIT_CONFIG, 1); final Command insertIntoCommand = givenCommand("INSERT INTO user1pv select * from pageview;", cmdConfig); final CommandId insertIntoCommandId = new CommandId(CommandId.Type.STREAM, "_InsertQuery1", CommandId.Action.CREATE); // When: handleStatement(insertIntoCommand, insertIntoCommandId, Optional.empty()); // Then: statement should fail since exceeds limit of 1 active persistent query final CommandStatus commandStatus = getCommandStatus(insertIntoCommandId); assertThat(commandStatus.getStatus(), is(CommandStatus.Status.ERROR)); assertThat( commandStatus.getMessage(), containsString("would cause the number of active, persistent queries " + "to exceed the configured limit")); }
private void printKsqlResponse(final RestResponse<KsqlEntityList> response) throws IOException { if (response.isSuccessful()) { final KsqlEntityList ksqlEntities = response.getResponse(); boolean noErrorFromServer = true; for (final KsqlEntity entity : ksqlEntities) { if (entity instanceof CommandStatusEntity && ( ((CommandStatusEntity) entity).getCommandStatus().getStatus() == CommandStatus.Status.ERROR) ) { final String fullMessage = ((CommandStatusEntity) entity).getCommandStatus().getMessage(); terminal.printError(fullMessage.split("\n")[0], fullMessage); noErrorFromServer = false; } } if (noErrorFromServer) { terminal.printKsqlEntityList(response.getResponse()); } } else { terminal.printErrorMessage(response.getErrorMessage()); } }
@Test public void shouldFailCreateAsSelectIfExceedActivePersistentQueriesLimit() { // Given: createStreamsAndStartTwoPersistentQueries(); // Prepare to try adding a third final KsqlConfig cmdConfig = givenCommandConfig(KsqlConfig.KSQL_ACTIVE_PERSISTENT_QUERY_LIMIT_CONFIG, 2); final Command csasCommand = givenCommand("CREATE STREAM user2pv AS select * from pageview;", cmdConfig); final CommandId csasCommandId = new CommandId(CommandId.Type.STREAM, "_CSASGen2", CommandId.Action.CREATE); // When: handleStatement(csasCommand, csasCommandId, Optional.empty()); // Then: final CommandStatus commandStatus = getCommandStatus(csasCommandId); assertThat("CSAS statement should fail since exceeds limit of 2 active persistent queries", commandStatus.getStatus(), is(CommandStatus.Status.ERROR)); assertThat( commandStatus.getMessage(), containsString("would cause the number of active, persistent queries " + "to exceed the configured limit")); }