Merge branch 'cassandra-3.0' into cassandra-3.11
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/61a47afc Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/61a47afc Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/61a47afc Branch: refs/heads/trunk Commit: 61a47afc0f8d467b854b3abadf659039ddeedafe Parents: 6d1c228 d74ed4b Author: Stefan Podkowinski <stefan.podkowin...@1und1.de> Authored: Thu Aug 3 12:50:53 2017 +0200 Committer: Stefan Podkowinski <stefan.podkowin...@1und1.de> Committed: Thu Aug 3 12:52:13 2017 +0200 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../apache/cassandra/service/StartupChecks.java | 32 ++++++- .../cassandra/service/LegacyAuthFailTest.java | 89 ++++++++++++++++++++ 3 files changed, 121 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/61a47afc/CHANGES.txt ---------------------------------------------------------------------- diff --cc CHANGES.txt index 3f8a316,7e518ed..3b0524b --- a/CHANGES.txt +++ b/CHANGES.txt @@@ -1,9 -1,5 +1,10 @@@ -3.0.15 +3.11.1 + * "ignore" option is ignored in sstableloader (CASSANDRA-13721) + * Deadlock in AbstractCommitLogSegmentManager (CASSANDRA-13652) + * Duplicate the buffer before passing it to analyser in SASI operation (CASSANDRA-13512) + * Properly evict pstmts from prepared statements cache (CASSANDRA-13641) +Merged from 3.0: + * Log warn message until legacy auth tables have been migrated (CASSANDRA-13371) * Fix incorrect [2.1 <- 3.0] serialization of counter cells created in 2.0 (CASSANDRA-13691) * Fix invalid writetime for null cells (CASSANDRA-13711) * Fix ALTER TABLE statement to atomically propagate changes to the table and its MVs (CASSANDRA-12952) http://git-wip-us.apache.org/repos/asf/cassandra/blob/61a47afc/src/java/org/apache/cassandra/service/StartupChecks.java ---------------------------------------------------------------------- diff --cc src/java/org/apache/cassandra/service/StartupChecks.java index 89fa12c,e9f99ee..372f5f9 --- a/src/java/org/apache/cassandra/service/StartupChecks.java +++ b/src/java/org/apache/cassandra/service/StartupChecks.java @@@ -34,10 -38,9 +37,12 @@@ import org.apache.cassandra.config.CFMe import org.apache.cassandra.config.Config; import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.config.Schema; +import org.apache.cassandra.config.SchemaConstants; +import org.apache.cassandra.db.ColumnFamilyStore; +import org.apache.cassandra.db.Directories; +import org.apache.cassandra.db.SystemKeyspace; + import org.apache.cassandra.cql3.QueryProcessor; + import org.apache.cassandra.cql3.UntypedResultSet; -import org.apache.cassandra.db.*; import org.apache.cassandra.exceptions.ConfigurationException; import org.apache.cassandra.exceptions.StartupException; import org.apache.cassandra.io.sstable.Descriptor; @@@ -425,4 -411,28 +431,28 @@@ public class StartupCheck } } }; + + public static final StartupCheck checkLegacyAuthTables = () -> checkLegacyAuthTablesMessage().ifPresent(logger::warn); + + static final Set<String> LEGACY_AUTH_TABLES = ImmutableSet.of("credentials", "users", "permissions"); + + @VisibleForTesting + static Optional<String> checkLegacyAuthTablesMessage() + { + List<String> existing = new ArrayList<>(LEGACY_AUTH_TABLES).stream().filter((legacyAuthTable) -> + { + UntypedResultSet result = QueryProcessor.executeOnceInternal(String.format("SELECT table_name FROM %s.%s WHERE keyspace_name='%s' AND table_name='%s'", - SchemaKeyspace.NAME, ++ SchemaConstants.SCHEMA_KEYSPACE_NAME, + "tables", - AuthKeyspace.NAME, ++ SchemaConstants.AUTH_KEYSPACE_NAME, + legacyAuthTable)); + return result != null && !result.isEmpty(); + }).collect(Collectors.toList()); + + if (!existing.isEmpty()) + return Optional.of(String.format("Legacy auth tables %s in keyspace %s still exist and have not been properly migrated.", - Joiner.on(", ").join(existing), AuthKeyspace.NAME)); ++ Joiner.on(", ").join(existing), SchemaConstants.AUTH_KEYSPACE_NAME)); + else + return Optional.empty(); + }; } http://git-wip-us.apache.org/repos/asf/cassandra/blob/61a47afc/test/unit/org/apache/cassandra/service/LegacyAuthFailTest.java ---------------------------------------------------------------------- diff --cc test/unit/org/apache/cassandra/service/LegacyAuthFailTest.java index 0000000,079543f..1e93f31 mode 000000,100644..100644 --- a/test/unit/org/apache/cassandra/service/LegacyAuthFailTest.java +++ b/test/unit/org/apache/cassandra/service/LegacyAuthFailTest.java @@@ -1,0 -1,89 +1,89 @@@ + /* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + package org.apache.cassandra.service; + + import java.util.ArrayList; + import java.util.List; + import java.util.Optional; + + import com.google.common.base.Joiner; + import org.junit.Test; + -import org.apache.cassandra.auth.AuthKeyspace; ++import org.apache.cassandra.config.SchemaConstants; + import org.apache.cassandra.cql3.CQLTester; + + import static java.lang.String.format; + import static org.junit.Assert.assertEquals; + import static org.junit.Assert.assertFalse; + + public class LegacyAuthFailTest extends CQLTester + { + @Test + public void testStartupChecks() throws Throwable + { + createKeyspace(); + + List<String> legacyTables = new ArrayList<>(StartupChecks.LEGACY_AUTH_TABLES); + + // test reporting for individual tables + for (String legacyTable : legacyTables) + { + createLegacyTable(legacyTable); + + Optional<String> errMsg = StartupChecks.checkLegacyAuthTablesMessage(); + assertEquals(format("Legacy auth tables %s in keyspace %s still exist and have not been properly migrated.", + legacyTable, - AuthKeyspace.NAME), errMsg.get()); ++ SchemaConstants.AUTH_KEYSPACE_NAME), errMsg.get()); + dropLegacyTable(legacyTable); + } + + // test reporting of multiple existing tables + for (String legacyTable : legacyTables) + createLegacyTable(legacyTable); + + while (!legacyTables.isEmpty()) + { + Optional<String> errMsg = StartupChecks.checkLegacyAuthTablesMessage(); + assertEquals(format("Legacy auth tables %s in keyspace %s still exist and have not been properly migrated.", + Joiner.on(", ").join(legacyTables), - AuthKeyspace.NAME), errMsg.get()); ++ SchemaConstants.AUTH_KEYSPACE_NAME), errMsg.get()); + + dropLegacyTable(legacyTables.remove(0)); + } + + // no legacy tables found + Optional<String> errMsg = StartupChecks.checkLegacyAuthTablesMessage(); + assertFalse(errMsg.isPresent()); + } + + private void dropLegacyTable(String legacyTable) throws Throwable + { - execute(format("DROP TABLE %s.%s", AuthKeyspace.NAME, legacyTable)); ++ execute(format("DROP TABLE %s.%s", SchemaConstants.AUTH_KEYSPACE_NAME, legacyTable)); + } + + private void createLegacyTable(String legacyTable) throws Throwable + { - execute(format("CREATE TABLE %s.%s (id int PRIMARY KEY, val text)", AuthKeyspace.NAME, legacyTable)); ++ execute(format("CREATE TABLE %s.%s (id int PRIMARY KEY, val text)", SchemaConstants.AUTH_KEYSPACE_NAME, legacyTable)); + } + + private void createKeyspace() throws Throwable + { - execute(format("CREATE KEYSPACE %s WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}", AuthKeyspace.NAME)); ++ execute(format("CREATE KEYSPACE %s WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}", SchemaConstants.AUTH_KEYSPACE_NAME)); + } + } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org