@Test public void waitWaitsForSchemaVersions() throws TException { CassandraClient waitingClient = mock(CassandraClient.class); when(waitingClient.describe_schema_versions()).thenReturn( ImmutableMap.of(), ImmutableMap.of(VERSION_UNREACHABLE, QUORUM_OF_NODES, VERSION_1, REST_OF_NODES), ImmutableMap.of(VERSION_1, QUORUM_OF_NODES, VERSION_UNREACHABLE, REST_OF_NODES), ImmutableMap.of(VERSION_1, ALL_NODES)); CassandraKeyValueServices.waitForSchemaVersions(waitingConfig, waitingClient, TABLE); verify(waitingClient, times(3)).describe_schema_versions(); }
versions = client.describe_schema_versions(); if (uniqueSchemaWithQuorumAgreementAndOtherNodesUnreachable(config, versions)) { return;
@Test public void waitThrowsForQuorumOfUnreachableNodes() throws TException { when(client.describe_schema_versions()) .thenReturn(ImmutableMap.of(VERSION_UNREACHABLE, QUORUM_OF_NODES, VERSION_1, REST_OF_NODES)); assertWaitForSchemaVersionsThrowsAndContainsConfigNodesInformation(); }
@Test public void waitThrowsForDifferentSchemaVersion() throws TException { when(client.describe_schema_versions()) .thenReturn(ImmutableMap.of(VERSION_1, QUORUM_OF_NODES, VERSION_2, REST_OF_NODES)); assertWaitForSchemaVersionsThrowsAndContainsConfigNodesInformation(); }
@Test public void waitSucceedsForQuorumOnlyWithUnknownAndUnreachableSchemaVersion() throws TException { when(client.describe_schema_versions()).thenReturn( ImmutableMap.of(VERSION_1, QUORUM_OF_NODES, VERSION_UNREACHABLE, ImmutableList.of("5"))); assertWaitForSchemaVersionsDoesNotThrow(); }
@Test public void waitSucceedsForSameSchemaVersion() throws TException { when(client.describe_schema_versions()).thenReturn(ImmutableMap.of(VERSION_1, ALL_NODES)); assertWaitForSchemaVersionsDoesNotThrow(); }
@Test public void waitThrowsForFewerThanQuorumOnSameVersion() throws TException { when(client.describe_schema_versions()).thenReturn(ImmutableMap.of(VERSION_1, REST_OF_NODES)); assertWaitForSchemaVersionsThrowsAndContainsConfigNodesInformation(); }
@Test public void waitSucceedsForQuorumOnlyWithUnknownSchemaVersion() throws TException { when(client.describe_schema_versions()).thenReturn(ImmutableMap.of(VERSION_1, QUORUM_OF_NODES)); assertWaitForSchemaVersionsDoesNotThrow(); }
@Test public void waitSucceedsForQuorumOnlyWithUnreachableSchemaVersion() throws TException { when(client.describe_schema_versions()) .thenReturn(ImmutableMap.of(VERSION_1, QUORUM_OF_NODES, VERSION_UNREACHABLE, REST_OF_NODES)); assertWaitForSchemaVersionsDoesNotThrow(); }
@Test public void waitThrowsForAllUnknownSchemaVersion() throws TException { when(client.describe_schema_versions()).thenReturn(ImmutableMap.of()); assertWaitForSchemaVersionsThrowsAndContainsConfigNodesInformation(); }
@Test public void waitThrowsForAllUnreachableSchemaVersion() throws TException { when(client.describe_schema_versions()).thenReturn(ImmutableMap.of(VERSION_UNREACHABLE, ALL_NODES)); assertWaitForSchemaVersionsThrowsAndContainsConfigNodesInformation(); }
versions = client.describe_schema_versions(); if (uniqueSchemaWithQuorumAgreementAndOtherNodesUnreachable(config, versions)) { return;