Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.8] Backports 4th of September #1971

Merged
merged 18 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
check-latest: true
- name: Build with Maven
run: |
mvn -V -B -s .github/mvn-settings.xml verify -Dall-modules -Dvalidate-format -DskipTests -DskipITs -Dquarkus.container-image.build=false -Dquarkus.container-image.push=false
mvn -V -B --no-transfer-progress -s .github/mvn-settings.xml verify -Dall-modules -Dvalidate-format -DskipTests -DskipITs -Dquarkus.container-image.build=false -Dquarkus.container-image.push=false
detect-test-suite-modules:
name: Detect Modules in PR
runs-on: ubuntu-latest
Expand Down Expand Up @@ -52,8 +52,8 @@ jobs:
echo "MODULES_ARG=$MODULES_ARG" >> $GITHUB_OUTPUT
outputs:
MODULES_ARG: ${{ steps.detect-changes.outputs.MODULES_ARG }}
prepare-jvm-latest-modules-mvn-param:
name: Prepare Maven Params For Linux JVM Build
prepare-jvm-native-latest-modules-mvn-param:
name: Prepare Maven Params For Linux JVM and native Build
runs-on: ubuntu-latest
needs: [ detect-test-suite-modules ]
env:
Expand All @@ -63,22 +63,28 @@ jobs:
run: |
if [[ -n ${MODULES_ARG} ]]; then
echo "Running modules: ${MODULES_ARG}"
echo "MODULES_MAVEN_PARAM=[\" -pl ${MODULES_ARG} -Dall-modules\"]" >> $GITHUB_OUTPUT
echo "JVM_MODULES_MAVEN_PARAM=[\" -pl ${MODULES_ARG} -Dall-modules\"]" >> $GITHUB_OUTPUT
echo "NATIVE_MODULES_MAVEN_PARAM=[\" -pl ${MODULES_ARG} -Dall-modules\"]" >> $GITHUB_OUTPUT
else
echo "MODULES_MAVEN_PARAM=[' -P root-modules,cache-modules,spring-modules,http-modules,test-tooling-modules', ' -P security-modules,sql-db-modules,messaging-modules,websockets-modules,monitoring-modules']" >> $GITHUB_OUTPUT
echo "JVM_MODULES_MAVEN_PARAM=[' -P root-modules,cache-modules,spring-modules,http-modules,test-tooling-modules,messaging-modules,monitoring-modules', ' -P security-modules,sql-db-modules,websockets-modules']" >> $GITHUB_OUTPUT
echo "NATIVE_MODULES_MAVEN_PARAM=[' -P root-modules,websockets-modules,test-tooling-modules,nosql-db-modules', ' -P http-modules,cache-modules', ' -P security-modules,spring-modules',
' -P sql-db-modules -pl env-info,sql-db/hibernate,sql-db/sql-app,sql-db/sql-app-compatibility,sql-db/multiple-pus,sql-db/panache-flyway,sql-db/hibernate-reactive',
' -P sql-db-modules -pl env-info,sql-db/reactive-rest-data-panache,sql-db/vertx-sql,sql-db/reactive-vanilla,sql-db/hibernate-fulltext-search,sql-db/narayana-transactions',
' -P messaging-modules,monitoring-modules']" | tr -d -s '\n' ' ' >> $GITHUB_OUTPUT
fi
outputs:
MODULES_MAVEN_PARAM: ${{ steps.prepare-modules-mvn-param.outputs.MODULES_MAVEN_PARAM }}
JVM_MODULES_MAVEN_PARAM: ${{ steps.prepare-modules-mvn-param.outputs.JVM_MODULES_MAVEN_PARAM }}
NATIVE_MODULES_MAVEN_PARAM: ${{ steps.prepare-modules-mvn-param.outputs.NATIVE_MODULES_MAVEN_PARAM }}
linux-build-jvm-latest:
name: PR - Linux - JVM build - 3.8
runs-on: ubuntu-latest
timeout-minutes: 240
needs: prepare-jvm-latest-modules-mvn-param
needs: prepare-jvm-native-latest-modules-mvn-param
strategy:
matrix:
java: [ 17 ]
cli: [ 3.8.6 ]
module-mvn-args: ${{ fromJSON(needs.prepare-jvm-latest-modules-mvn-param.outputs.MODULES_MAVEN_PARAM) }}
module-mvn-args: ${{ fromJSON(needs.prepare-jvm-native-latest-modules-mvn-param.outputs.JVM_MODULES_MAVEN_PARAM) }}
outputs:
has-flaky-tests: ${{steps.flaky-test-detector.outputs.has-flaky-tests}}
steps:
Expand All @@ -101,7 +107,7 @@ jobs:
./quarkus-cli-${{ matrix.cli }}/bin/quarkus version
- name: Build with Maven
run: |
mvn -fae -V -B -s .github/mvn-settings.xml clean verify -Dinclude.quarkus-cli-tests -Dts.quarkus.cli.cmd="${PWD}/quarkus-cli-${{ matrix.cli }}/bin/quarkus"${{ matrix.module-mvn-args }} -am
mvn -fae -V -B --no-transfer-progress -s .github/mvn-settings.xml clean verify -Dinclude.quarkus-cli-tests -Dts.quarkus.cli.cmd="${PWD}/quarkus-cli-${{ matrix.cli }}/bin/quarkus"${{ matrix.module-mvn-args }} -am -DexcludedGroups=long-running
- name: Detect flaky tests
id: flaky-test-detector
if: ${{ hashFiles('**/flaky-run-report.json') != '' }}
Expand All @@ -118,13 +124,12 @@ jobs:
linux-build-native-latest:
name: PR - Linux - Native build - 3.8
runs-on: ubuntu-latest
needs: detect-test-suite-modules
env:
MODULES_ARG: ${{ needs.detect-test-suite-modules.outputs.MODULES_ARG }}
needs: prepare-jvm-native-latest-modules-mvn-param
strategy:
matrix:
java: [ 17 ]
cli: [ 3.8.6 ]
module-mvn-args: ${{ fromJSON(needs.prepare-jvm-native-latest-modules-mvn-param.outputs.NATIVE_MODULES_MAVEN_PARAM) }}
outputs:
has-flaky-tests: ${{steps.flaky-test-detector.outputs.has-flaky-tests}}
steps:
Expand All @@ -147,13 +152,10 @@ jobs:
./quarkus-cli-${{ matrix.cli }}/bin/quarkus version
- name: Build with Maven
run: |
if [[ -n ${MODULES_ARG} ]]; then
echo "Running modules: ${MODULES_ARG}"
mvn -fae -V -B -s .github/mvn-settings.xml -fae -Dall-modules \
mvn -fae -V -B --no-transfer-progress -s .github/mvn-settings.xml -fae \
-Dquarkus.native.native-image-xmx=5g \
-Dinclude.quarkus-cli-tests -Dts.quarkus.cli.cmd="${PWD}/quarkus-cli-${{ matrix.cli }}/bin/quarkus" \
-pl $MODULES_ARG clean verify -Dnative -am
fi
${{ matrix.module-mvn-args }} clean verify -Dnative -am -DexcludedGroups=long-running
- name: Detect flaky tests
id: flaky-test-detector
if: ${{ hashFiles('**/flaky-run-report.json') != '' }}
Expand Down Expand Up @@ -196,7 +198,7 @@ jobs:
MODULES_MAVEN_PARAM="-pl ${MODULES_ARG}"
fi

mvn -B -fae -s .github/mvn-settings.xml clean verify -Dall-modules $MODULES_MAVEN_PARAM -am
mvn -B --no-transfer-progress -fae -s .github/mvn-settings.xml clean verify -Dall-modules $MODULES_MAVEN_PARAM -am -DexcludedGroups=long-running
- name: Detect flaky tests
id: flaky-test-detector
if: ${{ hashFiles('**/flaky-run-report.json') != '' }}
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ The suite uses `org.junit.jupiter.api.Tag` annotation to group similar tests tog
- `serverless`: use Openshift Serverless to deploy the app
- `quarkus-cli`: tests use Quarkus CLI, which needs to be installed ( see https://quarkus.io/guides/cli-tooling for details)
- `podman-incompatible`: tests, which require Docker as a container engine and are not compatible with Podman.
- `long-running`: tests, which run for a long time and therefore are disabled in PR CI

## Running against Red Hat build of Quarkus

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,17 @@ private void validateExtensions(QuarkusCliRestService app, JsonPath json) {
.map(payloadExtension -> mapToGA(payloadExtension.getGroupId(), payloadExtension.getArtifactId()))
.collect(Collectors.toList());
assertEquals(pomDependencyGAs, payloadExtensionGAs);
List<PayloadExtension> extensionsWithMismatchedVersion = payloadExtensions.stream()
.filter(extension -> !QUARKUS_EXTENSION_VERSION_PATTERN.matcher(extension.getVersion()).matches())
.collect(Collectors.toList());
assertEquals(0, extensionsWithMismatchedVersion.size(),
String.format("All extensions versions must match pattern: '%s'. Offending extensions: %s",
QUARKUS_EXTENSION_VERSION_PATTERN.pattern(), extensionsWithMismatchedVersion));

// RHBQ doesn't guarantee the same version of the platform and core extensions
boolean isRHBQ = QuarkusProperties.getVersion().contains("redhat");
if (!isRHBQ) {
List<PayloadExtension> extensionsWithMismatchedVersion = payloadExtensions.stream()
.filter(extension -> !QUARKUS_EXTENSION_VERSION_PATTERN.matcher(extension.getVersion()).matches())
.collect(Collectors.toList());
assertEquals(0, extensionsWithMismatchedVersion.size(),
String.format("All extensions versions must match pattern: '%s'. Offending extensions: %s",
QUARKUS_EXTENSION_VERSION_PATTERN.pattern(), extensionsWithMismatchedVersion));
}
}

private List<Dependency> getPomDependencies(QuarkusCliRestService app) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIfSystemProperty;

import io.quarkus.test.scenarios.OpenShiftDeploymentStrategy;
import io.quarkus.test.scenarios.OpenShiftScenario;
Expand All @@ -28,7 +27,6 @@
import io.quarkus.test.services.knative.eventing.spi.ForwardResponseDTO;
import io.restassured.common.mapper.TypeRef;

@DisabledIfSystemProperty(named = "ts.arm.missing.services.excludes", matches = "true", disabledReason = "https://github.com/quarkus-qe/quarkus-test-suite/issues/1142")
@DisabledOnNative(reason = "https://github.com/quarkusio/quarkus/issues/37142")
@Tag("use-quarkus-openshift-extension")
@Tag("serverless")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.quarkus.ts.http.advanced.reactive;

public class CustomHeaderResponse {
private final String content;

public CustomHeaderResponse(String content) {
this.content = content;
}

public String getContent() {
return content;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package io.quarkus.ts.http.advanced.reactive;

import java.io.File;
import java.util.UUID;

import jakarta.inject.Inject;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.smallrye.mutiny.Uni;
import io.vertx.core.file.OpenOptions;
import io.vertx.mutiny.core.Vertx;

@Path("/download")
public class DownloadResource {

private static final Logger LOGGER = LoggerFactory.getLogger(DownloadResource.class);
private static final String TEST_FILE = System.getProperty("java.io.tmpdir") +
File.separator + "DownloadResource-" + UUID.randomUUID().toString() + "-test.txt";
private static final OpenOptions READ_ONLY = new OpenOptions().setWrite(false).setCreate(false);

@Inject
Vertx vertx;

@POST
@Path("/create")
public Uni<Response> createFile() {
LOGGER.info("Creating test file: {}", TEST_FILE);
return vertx.fileSystem()
.createFile(TEST_FILE)
.onItem().transform(it -> Response.ok(TEST_FILE).build());
}

@DELETE
@Path("/delete")
public Uni<Response> deleteFile() {
LOGGER.info("Deleting test file: {}", TEST_FILE);
return vertx.fileSystem()
.delete(TEST_FILE)
.onItem().transform(it -> Response.noContent().build());
}

@GET
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Uni<Response> downloadFile() {
LOGGER.info("Downloading test file: {}", TEST_FILE);
return vertx.fileSystem()
.open(TEST_FILE, READ_ONLY)
.onItem().transform(it -> Response.ok(it).build());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.quarkus.ts.http.advanced.reactive;

import java.io.IOException;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;

import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.ext.MessageBodyWriter;
import jakarta.ws.rs.ext.Provider;

@Provider
public class HeadersMessageBodyWriter implements MessageBodyWriter<CustomHeaderResponse> {

@Override
public boolean isWriteable(Class aClass, Type type, Annotation[] annotations, MediaType mediaType) {
return CustomHeaderResponse.class.isAssignableFrom(aClass) && MediaType.TEXT_PLAIN_TYPE.isCompatible(mediaType);
}

@Override
public void writeTo(CustomHeaderResponse customHeaderResponse, Class<?> aClass, Type type, Annotation[] annotations,
MediaType mediaType, MultivaluedMap<String, Object> multivaluedMap, OutputStream outputStream)
throws IOException, WebApplicationException {
final String content = "Headers response: " + customHeaderResponse.getContent();
outputStream.write(content.getBytes());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import io.smallrye.mutiny.Uni;
Expand All @@ -28,4 +30,11 @@ public Uni<Response> headersOverride() {
return Uni.createFrom().item(response);
}

@GET
@Path("/no-accept")
@Produces(MediaType.TEXT_PLAIN)
public Uni<Response> noAcceptHeaders() {
return Uni.createFrom().item(Response.ok(new CustomHeaderResponse("ok headers")).build());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package io.quarkus.ts.http.advanced.reactive;

import static io.restassured.RestAssured.given;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.stream.Collectors;

import org.junit.Assert;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;

import io.quarkus.test.bootstrap.RestService;
import io.quarkus.test.scenarios.QuarkusScenario;
import io.quarkus.test.scenarios.annotations.DisabledOnNative;
import io.quarkus.test.services.QuarkusApplication;
import io.restassured.response.Response;

/**
* Test makes sure AsyncFile gets closed, coverage triggered by https://github.com/quarkusio/quarkus/issues/41811
*/
@QuarkusScenario
@DisabledOnNative(reason = "To save resources on CI")
@DisabledOnOs(value = OS.WINDOWS, disabledReason = "No lsof command on Windows")
class DownloadResourceIT {
@QuarkusApplication(classes = { DownloadResource.class }, properties = "oidcdisable.properties")
static RestService app = new RestService();

@Test
void ensureAsyncFileGetsClosed() throws IOException {
Response response = app.given()
.when().post("/download/create")
.then()
.statusCode(200)
.extract().response();
String file = response.getBody().asString();

app.given()
.when().get("/download")
.then()
.statusCode(200);

ProcessBuilder lsofBuilder = new ProcessBuilder("lsof", file);
Process lsofProcess = lsofBuilder.start();
String lsofOutput = new BufferedReader(new InputStreamReader(lsofProcess.getInputStream())).lines()
.collect(Collectors.joining("\n"));

app.given()
.when().delete("/download/delete")
.then()
.statusCode(204);

Assert.assertEquals("AsyncFile is not closed, details:\n" + lsofOutput + "\n", 0, lsofOutput.length());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
import io.quarkus.test.bootstrap.RestService;
import io.quarkus.test.scenarios.QuarkusScenario;
import io.quarkus.test.services.QuarkusApplication;
import io.restassured.http.Header;
import io.restassured.response.ValidatableResponse;

@QuarkusScenario
public class HeadersIT {

@QuarkusApplication(classes = { PathSpecificHeadersResource.class,
HeadersMessageBodyWriter.class,
CustomHeaderResponse.class,
HeadersResource.class }, properties = "headers.properties")
static RestService app = new RestService();

Expand Down Expand Up @@ -100,6 +103,19 @@ private ValidatableResponse whenGet(String path) {
.body(is("ok"));
}

@Test
@Tag("https://github.com/quarkusio/quarkus/pull/41411")
void testWithNoAcceptHeader() {
Header header = new Header("Accept", null);
given()
.when()
.header(header)
.get("/headers/no-accept")
.then()
.statusCode(200)
.body(is("Headers response: ok headers"));
}

/**
* Cache-Control header may be present multiple times in the response, e.g. in an OpenShift deployment. That is why we need
* to look for a specific value among all headers of the same name, and not just match the last one of them, which is what
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
quarkus.oidc.enabled=false
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.quarkus.ts.http.advanced;

public class CustomHeaderResponse {

private final String content;

public CustomHeaderResponse(String content) {
this.content = content;
}

public String getContent() {
return content;
}
}
Loading