You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2020/08/18 07:28:05 UTC

[GitHub] [cassandra] smiklosovic commented on a change in pull request #714: CASSANDRA-16039 - FQL replay has option to ignore DDL statements

smiklosovic commented on a change in pull request #714:
URL: https://github.com/apache/cassandra/pull/714#discussion_r471970739



##########
File path: test/distributed/org/apache/cassandra/distributed/test/FqlReplayDDLExclusionTest.java
##########
@@ -0,0 +1,104 @@
+/*
+ * 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.distributed.test;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+import com.datastax.driver.core.Session;
+import org.apache.cassandra.distributed.Cluster;
+import org.apache.cassandra.distributed.api.IInvokableInstance;
+import org.apache.cassandra.tools.ToolRunner;
+
+import static org.apache.cassandra.distributed.api.Feature.GOSSIP;
+import static org.apache.cassandra.distributed.api.Feature.NATIVE_PROTOCOL;
+import static org.apache.cassandra.distributed.api.Feature.NETWORK;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class FqlReplayDDLExclusionTest extends TestBaseImpl
+{
+    @Rule
+    public final TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+    @Test
+    public void test() throws Throwable
+    {
+        try (final Cluster cluster = init(builder().withNodes(1)
+                                                   .withConfig(updater -> updater.with(NETWORK, GOSSIP, NATIVE_PROTOCOL))
+                                                   .start()))
+        {
+            final IInvokableInstance node = cluster.get(1);
+
+            // using driver path is important because dtest API and query execution does not invoke code
+            // in Cassandra where events are propagated to logger
+            try (com.datastax.driver.core.Cluster c = com.datastax.driver.core.Cluster.builder().addContactPoint("127.0.0.1").build();
+                 Session s = c.connect())
+            {
+                s.execute("CREATE KEYSPACE fql_ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};");
+
+                node.nodetool("enablefullquerylog", "--path", temporaryFolder.getRoot().getAbsolutePath());
+
+                s.execute("CREATE TABLE fql_ks.fql_table (id int primary key);");
+                s.execute("INSERT INTO fql_ks.fql_table (id) VALUES (1)");
+
+                node.nodetool("disablefullquerylog");
+            }
+
+            // here we are dropping and we expect that ddl replay will reconstruct it
+
+            node.executeInternal("DROP TABLE fql_ks.fql_table;");
+
+            final ToolRunner.Runners runners = new ToolRunner.Runners();
+
+            // without --replay-ddl-statements, the replay will fail on insert because underlying table is not there
+            final ToolRunner negativeRunner = runners.invokeClassAsTool("org.apache.cassandra.fqltool.FullQueryLogTool",
+                                                                        "replay",
+                                                                        "--keyspace", "fql_ks",
+                                                                        "--target", "127.0.0.1",
+                                                                        "--", temporaryFolder.getRoot().getAbsolutePath());
+
+            assertEquals(0, negativeRunner.getExitCode());

Review comment:
       yes, it does.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org