JeetKunDoug commented on code in PR #160:
URL: https://github.com/apache/cassandra-sidecar/pull/160#discussion_r1889313274


##########
server/src/test/java/org/apache/cassandra/sidecar/coordination/BestEffortSingleConditionalExecutorParametersTest.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * 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.sidecar.coordination;
+
+import java.util.Collections;
+import java.util.HashMap;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Unit tests for {@link BestEffortSingleConditionalExecutor.Parameters}
+ */
+class BestEffortSingleConditionalExecutorParametersTest
+{
+    @DisplayName("Default values are returned when no configuration is 
provided")
+    @Test
+    void testDefaults()
+    {
+        BestEffortSingleConditionalExecutor.Parameters params = 
BestEffortSingleConditionalExecutor.Parameters.from(Collections.emptyMap());
+        assertThat(params.isEnabled()).as("Enabled by default").isTrue();
+        assertThat(params.delayMillis()).as("Run every minute by 
default").isEqualTo(60_000L);
+        assertThat(params.initialDelayMillis()).as("Wait 1 second before 
starting the process by default").isEqualTo(1_000L);
+    }
+
+    @DisplayName("Ensures that is_enabled cannot be configured with an invalid 
string value")

Review Comment:
   ```suggestion
       @DisplayName("Ensures that is_enabled returns the default value when an 
invalid string value is configured")
   ```



##########
server/src/main/java/org/apache/cassandra/sidecar/db/schema/SidecarSchema.java:
##########
@@ -181,4 +186,23 @@ protected void reportSidecarSchemaInitialized()
     {
         vertx.eventBus().publish(ON_SIDECAR_SCHEMA_INITIALIZED.address(), 
"SidecarSchema initialized");
     }
+
+    /**
+     * Returns true when the schema should be created by this Sidecar 
instance. This currently
+     * depends on whether the election of single instance executor process is 
available, and
+     * the schemas are of type {@link InitializeOnSingleInstanceExecutor}, and 
the local Sidecar
+     * is a single instance executor. For all other types of schemas or if the 
election of leader

Review Comment:
   Do we want to initialize the schema in every instance even if the we can't 
determine that we should be doing it? Could we defer the schema creation in 
that case, as we know (pre-TCM) this can cause significant issues with schema 
mismatches across instances?



##########
server/src/test/java/org/apache/cassandra/sidecar/tasks/PeriodicTaskExecutorTest.java:
##########
@@ -77,4 +80,71 @@ public void close()
         assertThat(isClosed.get()).isTrue();
         assertThat(failuresCount.get()).isEqualTo(totalFailures);
     }
+
+    @Test
+    void testPeriodicTaskOnNonLeader()
+    {
+        CountDownLatch latch = new CountDownLatch(1);
+        SimulatedTask taskThatRunsOnNonLeader = new SimulatedTask(latch);
+        PeriodicTaskExecutor taskExecutorNonLeader = new 
PeriodicTaskExecutor(executorPools,
+                                                                              
TestConditionalExecutors.NEVER_EXECUTE);
+
+        taskExecutorNonLeader.schedule(taskThatRunsOnNonLeader);
+        assertThat(Uninterruptibles.awaitUninterruptibly(latch, 30, 
TimeUnit.SECONDS)).isTrue();
+        assertThat(taskThatRunsOnNonLeader.executionCount.get()).isEqualTo(0);
+    }
+
+    @Test

Review Comment:
   We need to add a test for an executor that returns `INDETERMINATE` at least 
once, and then `EXECUTE`, so we can test the retry of a task that requires a 
conditional executor.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to