smiklosovic commented on code in PR #2649:
URL: https://github.com/apache/cassandra/pull/2649#discussion_r1311202661


##########
test/unit/org/apache/cassandra/streaming/async/StreamingInboundHandlerTest.java:
##########
@@ -105,13 +108,53 @@ public void 
StreamDeserializingTask_deriveSession_StreamInitMessage()
     }
 
     @Test (expected = UnsupportedOperationException.class)
-    public void StreamDeserializingTask_deriveSession_NoSession()
+    public void StreamDeserializingTask_deriveSession_NoSession() throws 
Exception
     {
         CompleteMessage msg = new CompleteMessage();
         StreamDeserializingTask task = new StreamDeserializingTask(null, 
streamingChannel, MessagingService.current_version);
         task.deriveSession(msg);
     }
 
+    @Test
+    public void StreamDeserializingTask_deriveSession_BulkLoad_Disabled()
+    {
+        try
+        {
+            Guardrails.instance.setBulkLoadEnabled(false);
+            StreamInitMessage msg = new StreamInitMessage(REMOTE_ADDR, 0, 
nextTimeUUID(), StreamOperation.BULK_LOAD, nextTimeUUID(), PreviewKind.ALL);
+            StreamDeserializingTask task = new StreamDeserializingTask(null, 
streamingChannel, MessagingService.current_version);
+            Assertions.assertThatThrownBy(() -> task.deriveSession(msg))
+                      .isInstanceOf(StreamReceiveException.class)
+                      .cause()
+                      .isInstanceOf(RuntimeException.class)
+                      .hasNoCause()
+                      .hasMessage("Bulk load is disabled")
+                      .as("Derive session should fail");
+        }
+        finally
+        {
+            Guardrails.instance.setBulkLoadEnabled(true);
+        }
+    }
+
+    @Test
+    public void 
StreamDeserializingTask_deriveSession_BulkLoad_Disabled_Do_Not_Affect_Non_Bulk_Streaming()
 throws Exception
+    {
+        try
+        {
+            Guardrails.instance.setBulkLoadEnabled(false);
+            // verify that other operation is not affected
+            StreamInitMessage msg = new StreamInitMessage(REMOTE_ADDR, 0, 
nextTimeUUID(), StreamOperation.REPAIR, nextTimeUUID(), PreviewKind.ALL);
+            StreamDeserializingTask task = new StreamDeserializingTask(null, 
streamingChannel, MessagingService.current_version);
+            StreamSession session = task.deriveSession(msg);

Review Comment:
   can be done like `Assert.assertNotNull(task.deriveSession(msg))`



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