Skip to content

Commit

Permalink
Merge branch 'master' into upgrade-slf4j-2.0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
nodece authored Apr 7, 2024
2 parents a942ff1 + 2469b97 commit 1214d8c
Show file tree
Hide file tree
Showing 33 changed files with 449 additions and 270 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/flaky-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
name: Flaky test
title: "Flaky-test: test_class.test_method"
description: Report a flaky test failure
labels: [ "component/test", "flaky-tests" ]
labels: [ "area/test", "type/flaky-tests" ]
body:
- type: markdown
attributes:
Expand Down
6 changes: 0 additions & 6 deletions .github/actions/tune-runner-vm/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@ runs:
# stop Azure Linux agent to save RAM
sudo systemctl stop walinuxagent.service || true
# enable docker experimental mode which is
# required for using "docker build --squash" / "-Ddocker.squash=true"
daemon_json="$(sudo cat /etc/docker/daemon.json | jq '.experimental = true')"
echo "$daemon_json" | sudo tee /etc/docker/daemon.json
# restart docker daemon
sudo systemctl restart docker
echo '::endgroup::'
# show memory
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/pulsar-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,8 @@ jobs:
- name: Build java-test-image docker image
run: |
# build docker image
mvn -B -am -pl docker/pulsar,tests/docker-images/java-test-image install -Pcore-modules,-main,integrationTests,docker \
-Dmaven.test.skip=true -Ddocker.squash=true -DskipSourceReleaseAssembly=true \
DOCKER_CLI_EXPERIMENTAL=enabled mvn -B -am -pl docker/pulsar,tests/docker-images/java-test-image install -Pcore-modules,-main,integrationTests,docker \
-Dmaven.test.skip=true -DskipSourceReleaseAssembly=true \
-Dspotbugs.skip=true -Dlicense.skip=true -Dcheckstyle.skip=true -Drat.skip=true
- name: save docker image apachepulsar/java-test-image:latest to Github artifact cache
Expand Down Expand Up @@ -868,8 +868,8 @@ jobs:
run: |
# build docker image
# include building of Connectors, Offloaders and server distros
mvn -B -am -pl distribution/io,distribution/offloaders,distribution/server,distribution/shell,tests/docker-images/latest-version-image install \
-Pmain,docker -Dmaven.test.skip=true -Ddocker.squash=true \
DOCKER_CLI_EXPERIMENTAL=enabled mvn -B -am -pl distribution/io,distribution/offloaders,distribution/server,distribution/shell,tests/docker-images/latest-version-image install \
-Pmain,docker -Dmaven.test.skip=true \
-Dspotbugs.skip=true -Dlicense.skip=true -Dcheckstyle.skip=true -Drat.skip=true
# check full build artifacts licenses
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ Check https://pulsar.apache.org for documentation and examples.

## Build custom docker images

The commands used in the Apache Pulsar release process can be found in the [release process documentation](https://pulsar.apache.org/contribute/release-process/#stage-docker-images).

Here are some general instructions for building custom docker images:

* Docker images must be built with Java 8 for `branch-2.7` or previous branches because of [ISSUE-8445](https://github.com/apache/pulsar/issues/8445).
* Java 11 is the recommended JDK version in `branch-2.8`, `branch-2.9` and `branch-2.10`.
* Java 17 is the recommended JDK version in `master`.
Expand All @@ -200,6 +204,8 @@ The following command builds the docker images `apachepulsar/pulsar-all:latest`

```bash
mvn clean install -DskipTests
# setting DOCKER_CLI_EXPERIMENTAL=enabled is required in some environments with older docker versions
export DOCKER_CLI_EXPERIMENTAL=enabled
mvn package -Pdocker,-main -am -pl docker/pulsar-all -DskipTests
```

Expand Down
8 changes: 1 addition & 7 deletions build/build_java_test_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$SCRIPT_DIR/.."
SQUASH_PARAM=""
# check if docker experimental mode is enabled which is required for
# using "docker build --squash" for squashing all intermediate layers of the build to a single layer
if [[ "$(docker version -f '{{.Server.Experimental}}' 2>/dev/null)" == "true" ]]; then
SQUASH_PARAM="-Ddocker.squash=true"
fi
mvn -am -pl tests/docker-images/java-test-image -Pcore-modules,-main,integrationTests,docker \
-Dmaven.test.skip=true -DskipSourceReleaseAssembly=true -Dspotbugs.skip=true -Dlicense.skip=true $SQUASH_PARAM \
-Dmaven.test.skip=true -DskipSourceReleaseAssembly=true -Dspotbugs.skip=true -Dlicense.skip=true \
"$@" install
14 changes: 11 additions & 3 deletions build/run_unit_group.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,21 @@ function print_testng_failures() {
function test_group_broker_flaky() {
echo "::endgroup::"
echo "::group::Running quarantined tests"
mvn_test --no-fail-fast -pl pulsar-broker -Dgroups='quarantine' -DexcludedGroups='' -DfailIfNoTests=false \
mvn_test --no-fail-fast -pl pulsar-broker -Dgroups='quarantine' -DexcludedGroups='flaky' -DfailIfNoTests=false \
-DtestForkCount=2 ||
print_testng_failures pulsar-broker/target/surefire-reports/testng-failed.xml "Quarantined test failure in" "Quarantined test failures"
echo "::endgroup::"
echo "::group::Running flaky tests"
mvn_test --no-fail-fast -pl pulsar-broker -Dgroups='flaky' -DtestForkCount=2
mvn_test --no-fail-fast -pl pulsar-broker -Dgroups='flaky' -DexcludedGroups='quarantine' -DtestForkCount=2
echo "::endgroup::"
local modules_with_flaky_tests=$(git grep -l '@Test.*"flaky"' | grep '/src/test/java/' | \
awk -F '/src/test/java/' '{ print $1 }' | grep -v -E 'pulsar-broker' | sort | uniq | \
perl -0777 -p -e 's/\n(\S)/,$1/g')
if [ -n "${modules_with_flaky_tests}" ]; then
echo "::group::Running flaky tests in modules '${modules_with_flaky_tests}'"
mvn_test --no-fail-fast -pl "${modules_with_flaky_tests}" -Dgroups='flaky' -DexcludedGroups='quarantine' -DfailIfNoTests=false
echo "::endgroup::"
fi
}

function test_group_proxy() {
Expand Down Expand Up @@ -179,7 +187,7 @@ function test_group_other() {
perl -0777 -p -e 's/\n(\S)/,$1/g')
if [ -n "${modules_with_quarantined_tests}" ]; then
echo "::group::Running quarantined tests outside of pulsar-broker & pulsar-proxy (if any)"
mvn_test --no-fail-fast -pl "${modules_with_quarantined_tests}" test -Dgroups='quarantine' -DexcludedGroups='' \
mvn_test --no-fail-fast -pl "${modules_with_quarantined_tests}" test -Dgroups='quarantine' -DexcludedGroups='flaky' \
-DfailIfNoTests=false || \
echo "::warning::There were test failures in the 'quarantine' test group."
echo "::endgroup::"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public class AnnotationListener implements IAnnotationTransformer {
private static final long DEFAULT_TEST_TIMEOUT_MILLIS = TimeUnit.MINUTES.toMillis(5);
private static final String OTHER_GROUP = "other";

private static final String FLAKY_GROUP = "flaky";

private static final String QUARANTINE_GROUP = "quarantine";

public AnnotationListener() {
System.out.println("Created annotation listener");
}
Expand All @@ -51,9 +55,27 @@ public void transform(ITestAnnotation annotation,
annotation.setTimeOut(DEFAULT_TEST_TIMEOUT_MILLIS);
}

replaceGroupsIfFlakyOrQuarantineGroupIsIncluded(annotation);
addToOtherGroupIfNoGroupsSpecified(annotation);
}

// A test method will inherit the test groups from the class level and this solution ensures that a test method
// added to the flaky or quarantine group will not be executed as part of other groups.
private void replaceGroupsIfFlakyOrQuarantineGroupIsIncluded(ITestAnnotation annotation) {
if (annotation.getGroups() != null && annotation.getGroups().length > 1) {
for (String group : annotation.getGroups()) {
if (group.equals(QUARANTINE_GROUP)) {
annotation.setGroups(new String[]{QUARANTINE_GROUP});
return;
}
if (group.equals(FLAKY_GROUP)) {
annotation.setGroups(new String[]{FLAKY_GROUP});
return;
}
}
}
}

private void addToOtherGroupIfNoGroupsSpecified(ITestOrConfiguration annotation) {
// Add test to "other" group if there's no specified group
if (annotation.getGroups() == null || annotation.getGroups().length == 0) {
Expand Down
2 changes: 1 addition & 1 deletion docker/pulsar/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,5 @@ ENV PATH=$PATH:$JAVA_HOME/bin:/pulsar/bin

# The UID must be non-zero. Otherwise, it is arbitrary. No logic should rely on its specific value.
ARG DEFAULT_USERNAME=pulsar
RUN adduser ${DEFAULT_USERNAME} -u 10000 -G root -D
RUN adduser ${DEFAULT_USERNAME} -u 10000 -G root -D -H -h /pulsar/data
USER 10000
Original file line number Diff line number Diff line change
Expand Up @@ -355,15 +355,19 @@ private CompletableFuture<Void> computeCursorProperties(
final Function<Map<String, String>, Map<String, String>> updateFunction) {
CompletableFuture<Void> updateCursorPropertiesResult = new CompletableFuture<>();

final Stat lastCursorLedgerStat = ManagedCursorImpl.this.cursorLedgerStat;

Map<String, String> newProperties = updateFunction.apply(ManagedCursorImpl.this.cursorProperties);
if (!isDurable()) {
this.cursorProperties = Collections.unmodifiableMap(newProperties);
updateCursorPropertiesResult.complete(null);
return updateCursorPropertiesResult;
}

ManagedCursorInfo copy = ManagedCursorInfo
.newBuilder(ManagedCursorImpl.this.managedCursorInfo)
.clearCursorProperties()
.addAllCursorProperties(buildStringPropertiesMap(newProperties))
.build();

final Stat lastCursorLedgerStat = ManagedCursorImpl.this.cursorLedgerStat;
ledger.getStore().asyncUpdateCursorInfo(ledger.getName(),
name, copy, lastCursorLedgerStat, new MetaStoreCallback<>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2446,7 +2446,7 @@ public void testRetentionSize() throws Exception {
});
}

@Test
@Test(groups = "flaky")
public void testTimestampOnWorkingLedger() throws Exception {
ManagedLedgerConfig conf = new ManagedLedgerConfig();
conf.setMaxEntriesPerLedger(1);
Expand Down Expand Up @@ -3525,7 +3525,7 @@ public void testLedgerReachMaximumRolloverTime() throws Exception {
.until(() -> firstLedgerId != ml.addEntry("test".getBytes()).getLedgerId());
}

@Test
@Test(groups = "flaky")
public void testLedgerNotRolloverWithoutOpenState() throws Exception {
ManagedLedgerConfig config = new ManagedLedgerConfig();
config.setMaxEntriesPerLedger(2);
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ flexible messaging model and an intuitive client API.</description>
<include>**/Test*.java,**/*Test.java,**/*Tests.java,**/*TestCase.java</include>
<exclude/>
<groups/>
<excludedGroups>quarantine</excludedGroups>
<excludedGroups>quarantine,flaky</excludedGroups>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
Expand Down Expand Up @@ -227,7 +227,7 @@ flexible messaging model and an intuitive client API.</description>
<hppc.version>0.9.1</hppc.version>
<spark-streaming_2.10.version>2.1.0</spark-streaming_2.10.version>
<assertj-core.version>3.24.2</assertj-core.version>
<lombok.version>1.18.30</lombok.version>
<lombok.version>1.18.32</lombok.version>
<javax.annotation-api.version>1.3.2</javax.annotation-api.version>
<jaxb-api>2.3.1</jaxb-api>
<javax.activation.version>1.2.0</javax.activation.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ private CompletableFuture<DecodedJWT> authenticateToken(String token) {
return verifyIssuerAndGetJwk(jwt)
.thenCompose(jwk -> {
try {
if (!jwt.getAlgorithm().equals(jwk.getAlgorithm())) {
// verify the algorithm, if it is set ("alg" is optional in the JWK spec)
if (jwk.getAlgorithm() != null && !jwt.getAlgorithm().equals(jwk.getAlgorithm())) {
incrementFailureMetric(AuthenticationExceptionCode.ALGORITHM_MISMATCH);
return CompletableFuture.failedFuture(
new AuthenticationException("JWK's alg [" + jwk.getAlgorithm()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public class AuthenticationProviderOpenIDIntegrationTest {
// These are the kid values for JWKs in the /keys endpoint
String validJwk = "valid";
String invalidJwk = "invalid";
String validJwkWithoutAlg = "valid_without_alg";

// The valid issuer
String issuer;
Expand Down Expand Up @@ -188,10 +189,16 @@ void beforeClass() throws IOException {
"kty":"RSA",
"n":"invalid-key",
"e":"AQAB"
},
{
"kid":"%s",
"kty":"RSA",
"n":"%s",
"e":"%s"
}
]
}
""".formatted(validJwk, n, e, invalidJwk))));
""".formatted(validJwk, n, e, invalidJwk, validJwkWithoutAlg, n, e))));

server.stubFor(
get(urlEqualTo("/missing-kid/.well-known/openid-configuration"))
Expand Down Expand Up @@ -275,6 +282,14 @@ public void testTokenWithValidJWK() throws Exception {
assertEquals(role, provider.authenticateAsync(new AuthenticationDataCommand(token)).get());
}

@Test
public void testTokenWithValidJWKWithoutAlg() throws Exception {
String role = "superuser";
// test with a key in JWK that does not have an "alg" field. "alg" is optional in the JWK spec
String token = generateToken(validJwkWithoutAlg, issuer, role, "allowed-audience", 0L, 0L, 10000L);
assertEquals(role, provider.authenticateAsync(new AuthenticationDataCommand(token)).get());
}

@Test
public void testTokenWithTrailingSlashAndValidJWK() throws Exception {
String role = "superuser";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private static class StarterArguments {
@Option(names = {"-fwc", "--functions-worker-conf"}, description = "Configuration file for Functions Worker")
private String fnWorkerConfigFile = "conf/functions_worker.yml";

@Option(names = {"-h", "--help"}, description = "Show this help message")
@Option(names = {"-h", "--help"}, usageHelp = true, description = "Show this help message")
private boolean help = false;

@Option(names = {"-g", "--generate-docs"}, description = "Generate docs")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private static class Arguments {
"--proxy-url"}, description = "Proxy-server URL to which to connect.", required = false)
private String clusterProxyUrl;

@Option(names = {"-h", "--help"}, description = "Show this help message")
@Option(names = {"-h", "--help"}, usageHelp = true, description = "Show this help message")
private boolean help = false;

@Option(names = {"-g", "--generate-docs"}, description = "Generate docs")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class PulsarVersionStarter {

@Command(name = "version", showDefaultValues = true, scope = ScopeType.INHERIT)
private static class Arguments {
@Option(names = {"-h", "--help"}, description = "Show this help message")
@Option(names = {"-h", "--help"}, usageHelp = true, description = "Show this help message")
private boolean help = false;

@Option(names = {"-g", "--generate-docs"}, description = "Generate docs")
Expand Down
Loading

0 comments on commit 1214d8c

Please sign in to comment.