github-advanced-security[bot] commented on code in PR #19461:
URL: https://github.com/apache/druid/pull/19461#discussion_r3237462290
##########
server/src/test/java/org/apache/druid/server/coordination/SegmentChangeRequestLoadTest.java:
##########
@@ -131,6 +131,54 @@
Assert.assertEquals(Long.valueOf(12345L), reread.getLoadedBytes());
}
+ @Test
+ public void testForAnnouncementBareSegment()
+ {
+ // A segment loaded without a partial-load wrapper produces a plain
announcement with no partial fields.
+ DataSegment segment = new DataSegment(
+ "ds",
+ Intervals.of("2024-01-01/2024-02-01"),
+ "v1",
+ Map.of("type", "local"),
+ List.of("d"),
+ List.of("m"),
+ NoneShardSpec.instance(),
+ IndexIO.CURRENT_VERSION_ID,
+ 100
+ );
+ SegmentChangeRequestLoad announcement =
SegmentChangeRequestLoad.forAnnouncement(segment);
Review Comment:
## CodeQL / Deprecated method or constructor invocation
Invoking [DataSegment.DataSegment](1) should be avoided because it has been
deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11173)
##########
server/src/test/java/org/apache/druid/server/coordination/SegmentChangeRequestLoadTest.java:
##########
@@ -131,6 +131,54 @@
Assert.assertEquals(Long.valueOf(12345L), reread.getLoadedBytes());
}
+ @Test
+ public void testForAnnouncementBareSegment()
+ {
+ // A segment loaded without a partial-load wrapper produces a plain
announcement with no partial fields.
+ DataSegment segment = new DataSegment(
+ "ds",
+ Intervals.of("2024-01-01/2024-02-01"),
+ "v1",
+ Map.of("type", "local"),
+ List.of("d"),
+ List.of("m"),
+ NoneShardSpec.instance(),
+ IndexIO.CURRENT_VERSION_ID,
+ 100
+ );
+ SegmentChangeRequestLoad announcement =
SegmentChangeRequestLoad.forAnnouncement(segment);
+ Assert.assertNull(announcement.getFingerprint());
+ Assert.assertNull(announcement.getLoadedBytes());
+ }
+
+ @Test
+ public void testForAnnouncementPartialProjectionWrapperProducesFullFallback()
+ {
+ // When the segment's loadSpec is a partialProjection wrapper, the
announcement stamps the wrapper's fingerprint
+ // and the segment's full size as loadedBytes — coordinator reads this as
a full-fallback profile and counts the
+ // replica as matching, avoiding reload thrash on historicals that don't
(yet) do real partial loading.
+ Map<String, Object> wrapped = Map.of(
+ "type", "partialProjection",
+ "delegate", Map.of("type", "local", "path", "/var/druid/segments/foo"),
+ "projections", List.of("revenue"),
+ "fingerprint", "v1:abcdef0123456789"
+ );
+ DataSegment segment = new DataSegment(
+ "ds",
+ Intervals.of("2024-01-01/2024-02-01"),
+ "v1",
+ wrapped,
+ List.of("d"),
+ List.of("m"),
+ NoneShardSpec.instance(),
+ IndexIO.CURRENT_VERSION_ID,
+ 12345
+ );
Review Comment:
## CodeQL / Deprecated method or constructor invocation
Invoking [DataSegment.DataSegment](1) should be avoided because it has been
deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11223)
##########
server/src/test/java/org/apache/druid/client/DruidServerPartialLoadTest.java:
##########
@@ -0,0 +1,141 @@
+/*
+ * 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.druid.client;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.druid.java.util.common.Intervals;
+import org.apache.druid.server.coordination.ServerType;
+import org.apache.druid.server.coordinator.loading.PartialLoadProfile;
+import org.apache.druid.timeline.DataSegment;
+import org.apache.druid.timeline.partition.NoneShardSpec;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests {@link DruidServer}'s partial-load profile bookkeeping: profile-aware
{@code currSize} accounting,
+ * profile retrieval, and balanced add/remove of profile state.
+ */
+public class DruidServerPartialLoadTest
+{
+ private static final String FINGERPRINT = "v1:0123456789abcdef";
+
+ private static DruidServer newServer()
+ {
+ return new DruidServer(
+ "test",
+ "localhost:8083",
+ null,
+ 100_000_000L,
+ 100_000_000L,
+ ServerType.HISTORICAL,
+ "_default_tier",
+ 0
+ );
+ }
+
+ private static DataSegment buildSegment(String dataSource, String version,
long size)
+ {
+ return new DataSegment(
+ dataSource,
+ Intervals.of("2024-01-01/2024-02-01"),
+ version,
+ ImmutableMap.of("type", "local", "path", "/var/druid/segments/foo"),
+ null,
+ null,
+ NoneShardSpec.instance(),
+ 9,
+ size
+ );
Review Comment:
## CodeQL / Deprecated method or constructor invocation
Invoking [DataSegment.DataSegment](1) should be avoided because it has been
deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11222)
--
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]