Skip to content

Commit f52c656

Browse files
Bump dependencies to remediate CVEs (#126)
* Bump transitive dependencies to mitigate vulnerabilities * Update integration tests to run for pulsar 3.0 and 4.0 * Added a leader readiness check * Updated wait strategy and added a scheduler for polling to check function status * Fix formatting issue --------- Co-authored-by: priyanshu-ctds <ext-priyanshu.pareta@datastax.com>
1 parent 4700955 commit f52c656

5 files changed

Lines changed: 116 additions & 47 deletions

File tree

.github/workflows/github-ci.yml

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ jobs:
3535
- name: Unit tests
3636
run: mvn -B test -DfailIfNoTests=false -pl streaming-ai,pulsar-transformations,pulsar-ai-tools -Dspotbugs.skip -Dlicense.skip -Dfmt.skip -Dxml-format.skip
3737

38-
tests-ls:
39-
name: Integration tests on Luna Streaming
38+
tests-ls-31:
39+
name: Integration tests on Luna Streaming 3.1
4040
runs-on: ubuntu-latest
4141
needs: build
4242
steps:
@@ -58,11 +58,11 @@ jobs:
5858
- name: Build NAR
5959
run: mvn -B clean package -pl streaming-ai,pulsar-transformations -DskipTests -Dspotbugs.skip -Dlicense.skip -Dfmt.skip -Dxml-format.skip
6060

61-
- name: Integration tests on Luna Streaming 2.10
62-
run: mvn -B test -DfailIfNoTests=false -pl tests -Dtest=DockerTest\$LunaStreaming210Test -Dspotbugs.skip -Dlicense.skip -Dfmt.skip -Dxml-format.skip
61+
- name: Integration tests on Luna Streaming 3.1
62+
run: mvn -B test -DfailIfNoTests=false -pl tests -Dtest=DockerTest\$LunaStreaming31Test -Dspotbugs.skip -Dlicense.skip -Dfmt.skip -Dxml-format.skip
6363

64-
tests-pulsar-211:
65-
name: Integration tests on Pulsar 2.11
64+
tests-ls-40:
65+
name: Integration tests on Luna Streaming 4.0
6666
runs-on: ubuntu-latest
6767
needs: build
6868
steps:
@@ -84,10 +84,10 @@ jobs:
8484
- name: Build NAR
8585
run: mvn -B clean package -pl streaming-ai,pulsar-transformations -DskipTests -Dspotbugs.skip -Dlicense.skip -Dfmt.skip -Dxml-format.skip
8686

87-
- name: Integration tests on Pulsar 2.11
88-
run: mvn -B test -DfailIfNoTests=false -pl tests -Dtest=DockerTest\$Pulsar211Test -Dspotbugs.skip -Dlicense.skip -Dfmt.skip -Dxml-format.skip
87+
- name: Integration tests on Luna Streaming 4.0
88+
run: mvn -B test -DfailIfNoTests=false -pl tests -Dtest=DockerTest\$LunaStreaming40Test -Dspotbugs.skip -Dlicense.skip -Dfmt.skip -Dxml-format.skip
8989

90-
tests-pulsar-3:
90+
tests-pulsar-30:
9191
name: Integration tests on Pulsar 3.0
9292
runs-on: ubuntu-latest
9393
needs: build
@@ -112,3 +112,29 @@ jobs:
112112

113113
- name: Integration tests on Pulsar 3.0
114114
run: mvn -B test -DfailIfNoTests=false -pl tests -Dtest=DockerTest\$Pulsar30Test -Dspotbugs.skip -Dlicense.skip -Dfmt.skip -Dxml-format.skip
115+
116+
tests-pulsar-40:
117+
name: Integration tests on Pulsar 4.0
118+
runs-on: ubuntu-latest
119+
needs: build
120+
steps:
121+
- uses: actions/checkout@v2
122+
- name: Set up JDK 11
123+
uses: actions/setup-java@v2
124+
with:
125+
java-version: '11'
126+
distribution: 'adopt'
127+
128+
- name: Cache local Maven repository
129+
uses: actions/cache@v3
130+
with:
131+
path: ~/.m2/repository
132+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
133+
restore-keys: |
134+
${{ runner.os }}-maven-
135+
136+
- name: Build NAR
137+
run: mvn -B clean package -pl streaming-ai,pulsar-transformations -DskipTests -Dspotbugs.skip -Dlicense.skip -Dfmt.skip -Dxml-format.skip
138+
139+
- name: Integration tests on Pulsar 4.0
140+
run: mvn -B test -DfailIfNoTests=false -pl tests -Dtest=DockerTest\$Pulsar40Test -Dspotbugs.skip -Dlicense.skip -Dfmt.skip -Dxml-format.skip

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@
5353
<commons-lang3.version>3.18.0</commons-lang3.version>
5454
<commons-compress.version>1.26.0</commons-compress.version>
5555
<commons-io.version>2.14.0</commons-io.version>
56-
<asynchttpclient.version>2.12.4</asynchttpclient.version>
57-
<aircompressor.version>0.27</aircompressor.version>
58-
<jackson.version>2.15.4</jackson.version>
56+
<asynchttpclient.version>2.14.5</asynchttpclient.version>
57+
<aircompressor.version>2.0.3</aircompressor.version>
58+
<jackson.version>2.21.2</jackson.version>
5959
<snakeyaml.version>2.0</snakeyaml.version>
60-
<netty.version>4.1.129.Final</netty.version>
60+
<netty.version>4.1.132.Final</netty.version>
6161
</properties>
6262
<modules>
6363
<module>streaming-ai</module>

tests/src/test/java/com/datastax/oss/pulsar/functions/transforms/tests/AbstractDockerTest.java

Lines changed: 57 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@
2525
import com.google.gson.Gson;
2626
import com.google.gson.reflect.TypeToken;
2727
import java.math.BigDecimal;
28+
import java.time.Duration;
2829
import java.time.LocalDate;
2930
import java.util.Collections;
3031
import java.util.List;
3132
import java.util.Map;
3233
import java.util.UUID;
33-
import java.util.concurrent.TimeUnit;
34+
import java.util.concurrent.*;
3435
import lombok.Value;
3536
import lombok.extern.slf4j.Slf4j;
3637
import org.apache.avro.Conversions;
@@ -596,29 +597,7 @@ private void deployFunction(
596597
.build();
597598

598599
admin.functions().createFunction(functionConfig, null);
599-
600-
FunctionStatus functionStatus = null;
601-
for (int i = 0; i < 300; i++) {
602-
functionStatus = admin.functions().getFunctionStatus("public", "default", functionName);
603-
if (functionStatus.getNumRunning() == 1) {
604-
break;
605-
}
606-
log.info("Function status: {}", functionStatus);
607-
functionStatus
608-
.getInstances()
609-
.forEach(
610-
f -> {
611-
log.info("Function instance status: {}", f);
612-
if (!StringUtils.isEmpty(f.getStatus().getError())) {
613-
log.error("Function errored out " + f);
614-
}
615-
});
616-
Thread.sleep(100);
617-
}
618-
619-
if (functionStatus.getNumRunning() != 1) {
620-
fail("Function didn't start in time");
621-
}
600+
waitForFunctionRunning(functionName);
622601
}
623602

624603
@Value
@@ -632,4 +611,58 @@ private static class Pojo2 {
632611
String c;
633612
String d;
634613
}
614+
615+
private void waitForFunctionRunning(String functionName) throws InterruptedException {
616+
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
617+
CompletableFuture<Void> future = new CompletableFuture<>();
618+
long deadline = System.currentTimeMillis() + Duration.ofMinutes(5).toMillis();
619+
scheduler.scheduleWithFixedDelay(
620+
() -> {
621+
try {
622+
FunctionStatus status =
623+
admin.functions().getFunctionStatus("public", "default", functionName);
624+
625+
status
626+
.getInstances()
627+
.stream()
628+
.filter(f -> !StringUtils.isEmpty(f.getStatus().getError()))
629+
.findFirst()
630+
.ifPresent(
631+
f ->
632+
future.completeExceptionally(
633+
new RuntimeException("Function errored out: " + f)));
634+
635+
if (future.isCompletedExceptionally()) {
636+
scheduler.shutdown();
637+
return;
638+
}
639+
if (status.getNumRunning() == 1) {
640+
future.complete(null);
641+
scheduler.shutdown();
642+
return;
643+
}
644+
if (System.currentTimeMillis() > deadline) {
645+
future.completeExceptionally(
646+
new RuntimeException("Function didn't start in time. Status: " + status));
647+
scheduler.shutdown();
648+
return;
649+
}
650+
log.info("Function not running yet, status: {}", status);
651+
} catch (PulsarAdminException e) {
652+
future.completeExceptionally(e);
653+
scheduler.shutdown();
654+
}
655+
},
656+
0,
657+
2,
658+
TimeUnit.SECONDS);
659+
660+
try {
661+
future.get();
662+
} catch (ExecutionException e) {
663+
fail(e.getCause().getMessage());
664+
} finally {
665+
scheduler.shutdownNow();
666+
}
667+
}
635668
}

tests/src/test/java/com/datastax/oss/pulsar/functions/transforms/tests/DockerTest.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,20 @@
1717

1818
public class DockerTest {
1919

20-
private static final String IMAGE_LUNASTREAMING210 = "datastax/lunastreaming:2.10_4.7";
21-
private static final String IMAGE_PULSAR211 = "apachepulsar/pulsar:2.11.1";
22-
private static final String IMAGE_PULSAR30 = "apachepulsar/pulsar:3.0.0";
20+
private static final String IMAGE_LUNASTREAMING31 = "datastax/lunastreaming:3.1.4_26";
21+
private static final String IMAGE_LUNASTREAMING40 = "datastax/lunastreaming:4.0.7_7";
22+
private static final String IMAGE_PULSAR30 = "apachepulsar/pulsar:3.0.17";
23+
private static final String IMAGE_PULSAR40 = "apachepulsar/pulsar:4.0.10";
2324

24-
public static class LunaStreaming210Test extends AbstractDockerTest {
25-
LunaStreaming210Test() {
26-
super(IMAGE_LUNASTREAMING210);
25+
public static class LunaStreaming31Test extends AbstractDockerTest {
26+
LunaStreaming31Test() {
27+
super(IMAGE_LUNASTREAMING31);
2728
}
2829
}
2930

30-
public static class Pulsar211Test extends AbstractDockerTest {
31-
Pulsar211Test() {
32-
super(IMAGE_PULSAR211);
31+
public static class LunaStreaming40Test extends AbstractDockerTest {
32+
LunaStreaming40Test() {
33+
super(IMAGE_LUNASTREAMING40);
3334
}
3435
}
3536

@@ -38,4 +39,10 @@ public static class Pulsar30Test extends AbstractDockerTest {
3839
super(IMAGE_PULSAR30);
3940
}
4041
}
42+
43+
public static class Pulsar40Test extends AbstractDockerTest {
44+
Pulsar40Test() {
45+
super(IMAGE_PULSAR40);
46+
}
47+
}
4148
}

tests/src/test/java/com/datastax/oss/pulsar/functions/transforms/tests/PulsarContainer.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ public void start() {
5353
.waitingFor(
5454
(new WaitAllStrategy())
5555
.withStrategy(Wait.defaultWaitStrategy())
56-
.withStrategy(Wait.forLogMessage(".*Created namespace public/default.*", 1)))
56+
.withStrategy(Wait.forLogMessage(".*Created namespace public/default.*", 1))
57+
.withStrategy(Wait.forLogMessage(".*Function worker service started.*", 1))
58+
.withStrategy(
59+
Wait.forLogMessage(".*FunctionMetaDataManager done becoming leader.*", 1)))
5760
.withLogConsumer(
5861
(f) -> {
5962
String text = f.getUtf8String().trim();

0 commit comments

Comments
 (0)