absurdfarce commented on code in PR #2036:
URL: 
https://github.com/apache/cassandra-java-driver/pull/2036#discussion_r2305404957


##########
core/src/test/java/com/datastax/dse/driver/internal/core/context/DseStartupOptionsBuilderTest.java:
##########
@@ -185,12 +276,72 @@ public void 
should_use_configuration_when_no_programmatic_values_provided() {
   public void should_ignore_configuration_when_programmatic_values_provided() {
     when(defaultProfile.getString(DefaultDriverOption.PROTOCOL_COMPRESSION, 
"none"))
         .thenReturn("none");
+    
when(defaultProfile.getName()).thenReturn(DriverExecutionProfile.DEFAULT_NAME);
 
-    buildContext(null, "Custom_App_Name", "Custom_App_Version");
+    buildContext(
+        null, "Custom_App_Name", "Custom_App_Version", 
ImmutableMap.of("default", "us-west-2"));
     Startup startup = new Startup(driverContext.getStartupOptions());
 
     assertThat(startup.options)
         .containsEntry(StartupOptionsBuilder.APPLICATION_NAME_KEY, 
"Custom_App_Name")
-        .containsEntry(StartupOptionsBuilder.APPLICATION_VERSION_KEY, 
"Custom_App_Version");
+        .containsEntry(StartupOptionsBuilder.APPLICATION_VERSION_KEY, 
"Custom_App_Version")
+        .containsEntry(
+            StartupOptionsBuilder.DRIVER_BAGGAGE,
+            
"{\"default\":{\"DefaultLoadBalancingPolicy\":{\"localDc\":\"us-west-2\"}}}");
+  }
+
+  @Test
+  public void should_include_all_local_dc_in_startup_message() {
+    when(defaultProfile.getString(DefaultDriverOption.PROTOCOL_COMPRESSION, 
"none"))
+        .thenReturn("none");
+    
when(defaultProfile.getName()).thenReturn(DriverExecutionProfile.DEFAULT_NAME);
+
+    buildContext(
+        null,
+        "Custom_App_Name",
+        "Custom_App_Version",
+        ImmutableMap.of("default", "us-west-2", "oltp", "us-east-2", "olap", 
"eu-central-1"));
+    Startup startup = new Startup(driverContext.getStartupOptions());
+
+    assertThat(startup.options)
+        .containsEntry(StartupOptionsBuilder.APPLICATION_NAME_KEY, 
"Custom_App_Name")
+        .containsEntry(StartupOptionsBuilder.APPLICATION_VERSION_KEY, 
"Custom_App_Version")
+        .containsEntry(
+            StartupOptionsBuilder.DRIVER_BAGGAGE,
+            
"{\"default\":{\"DefaultLoadBalancingPolicy\":{\"localDc\":\"us-west-2\"}},"
+                + 
"\"oltp\":{\"DefaultLoadBalancingPolicy\":{\"localDc\":\"us-east-2\"}},"
+                + 
"\"olap\":{\"DefaultLoadBalancingPolicy\":{\"localDc\":\"eu-central-1\"}}}");
+  }
+
+  @Test
+  public void should_include_all_lbp_details_in_startup_message() {
+    when(defaultProfile.getString(DefaultDriverOption.PROTOCOL_COMPRESSION, 
"none"))
+        .thenReturn("none");
+    
when(defaultProfile.getName()).thenReturn(DriverExecutionProfile.DEFAULT_NAME);
+
+    ProgrammaticArguments.Builder builder = ProgrammaticArguments.builder();
+    DefaultDriverContext driverContext =
+        new DefaultDriverContext(configLoader, builder.build()) {
+          @NonNull
+          @Override
+          public Map<String, LoadBalancingPolicy> getLoadBalancingPolicies() {
+            ImmutableMap.Builder<String, LoadBalancingPolicy> map = 
ImmutableMap.builder();
+            map.put(
+                "oltp",
+                mockLoadBalancingPolicy("oltp", "dc1", 2, true, 
ImmutableList.of("dc2", "dc3")));
+            map.put("default", mock(LoadBalancingPolicy.class));
+            return map.build();
+          }
+        };
+    Startup startup = new Startup(driverContext.getStartupOptions());
+
+    assertThat(startup.options)
+        .containsEntry(
+            StartupOptionsBuilder.DRIVER_BAGGAGE,
+            "{\"oltp\":{\"DefaultLoadBalancingPolicy\":{"
+                + "\"localDc\":\"dc1\","
+                + "\"preferredRemoteDcs\":[\"dc2\",\"dc3\"],"
+                + "\"allowDcFailoverForLocalCl\":true,"
+                + "\"maxNodesPerRemoteDc\":2}}}");
   }
 }

Review Comment:
   Semi-nit: there's nothing DSE-specific about this test that I can see.  
Shouldn't this just live in 
[StartupOptionsBuilderTest](https://github.com/apache/cassandra-java-driver/blob/4.19.0/core/src/test/java/com/datastax/oss/driver/internal/core/context/StartupOptionsBuilderTest.java)?



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