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

[1.5.z] Backport/7.10 #1356

Merged
merged 7 commits into from
Oct 8, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.quarkus.qe;

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.services.GitRepositoryQuarkusApplication;

@DisabledOnOs(value = OS.WINDOWS, disabledReason = "Windows does not support long file paths")
@QuarkusScenario
public class BareMetalQuickstartUsingDefaultsIT extends QuickstartUsingDefaultsIT {

@GitRepositoryQuarkusApplication(repo = "https://github.com/quarkusio/quarkus-quickstarts.git", contextDir = "getting-started")
static final RestService app = new RestService();

@Override
protected RestService getApp() {
return app;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package io.quarkus.qe;

import io.quarkus.test.bootstrap.RestService;
import io.quarkus.test.scenarios.OpenShiftDeploymentStrategy;
import io.quarkus.test.scenarios.OpenShiftScenario;
import io.quarkus.test.services.GitRepositoryQuarkusApplication;

@OpenShiftScenario(deployment = OpenShiftDeploymentStrategy.UsingContainerRegistry)
public class OpenShiftContainerRegistryQuickstartUsingDefaultsIT extends QuickstartUsingDefaultsIT {
@GitRepositoryQuarkusApplication(repo = "https://github.com/quarkusio/quarkus-quickstarts.git", contextDir = "getting-started")
static final RestService app = new RestService();

@Override
protected RestService getApp() {
return app;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
package io.quarkus.qe;

import io.quarkus.test.bootstrap.RestService;
import io.quarkus.test.scenarios.OpenShiftScenario;
import io.quarkus.test.services.GitRepositoryQuarkusApplication;

@OpenShiftScenario
public class OpenShiftS2iQuickstartUsingDefaultsIT extends QuickstartUsingDefaultsIT {

@GitRepositoryQuarkusApplication(repo = "https://github.com/quarkusio/quarkus-quickstarts.git", contextDir = "getting-started")
static final RestService app = new RestService();

@Override
protected RestService getApp() {
return app;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,16 @@

import org.apache.http.HttpStatus;
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.services.GitRepositoryQuarkusApplication;

@QuarkusScenario
@DisabledOnOs(value = OS.WINDOWS, disabledReason = "Windows does not support long file paths")
public class QuickstartUsingDefaultsIT {
public abstract class QuickstartUsingDefaultsIT {

@GitRepositoryQuarkusApplication(repo = "https://github.com/quarkusio/quarkus-quickstarts.git", contextDir = "getting-started")
static final RestService app = new RestService();
protected abstract RestService getApp();

@Test
public void test() {
app.given()
getApp().given()
.get("/hello")
.then()
.statusCode(HttpStatus.SC_OK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import io.restassured.response.Response;

@QuarkusScenario
// todo Merge with LocalIT when https://github.com/quarkusio/quarkus/issues/32225 is fixed
// todo Merge with LocalIT when framework support SSL/TLS on openshift https://github.com/quarkus-qe/quarkus-test-framework/issues/1052
public class LocalTLSIT {

@QuarkusApplication(certificates = @Certificate(configureManagementInterface = true, configureKeystore = true, useTlsRegistry = false))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import io.quarkus.test.scenarios.OpenShiftScenario;

@OpenShiftScenario
@Disabled
// todo delete when https://github.com/quarkusio/quarkus/issues/32225 is fixed
@Disabled("https://github.com/quarkus-qe/quarkus-test-framework/issues/1052")
// todo delete when framework support SSL/TLS on openshift
public class OpenShiftTLSIT extends LocalTLSIT {
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.2.5</version>
<version>3.2.7</version>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ QuarkusCliCommandResult runTlsCommand(List<String> subCmdArgs) {

private static QuarkusCliClient.CreateApplicationRequest getCreateAppReq() {
return QuarkusCliClient.CreateApplicationRequest.defaults()
// TODO: we can drop 'tls-registry' when https://github.com/quarkusio/quarkus/issues/42751 is fixed
.withExtensions("tls-registry", "quarkus-rest");
.withExtensions("quarkus-rest");
}

private static Closeable dontDisableAnalyticsWithProp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public static void changePropertiesInPom(QuarkusCliRestService app, Properties p
*/
public static void setCommunityBomIfNotRunningRHBQ(QuarkusCliRestService app, String communityQuarkusVersion)
throws XmlPullParserException, IOException {
if (!QuarkusProperties.getVersion().contains("redhat")) {
if (!QuarkusProperties.isRHBQ()) {
Properties communityBomProperties = new Properties();
communityBomProperties.put("quarkus.platform.group-id", "io.quarkus.platform");
communityBomProperties.put("quarkus.platform.version", communityQuarkusVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@

String[] command() default {};

long memoryLimitMiB() default 1000;

Class<? extends ManagedResourceBuilder> builder() default KeycloakContainerManagedResourceBuilder.class;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class KeycloakContainerManagedResourceBuilder extends ContainerManagedRes
private int restPort;
private String[] command;
private String expectedLog;
private long memoryLimitMiB;

@Override
protected String getImage() {
Expand All @@ -44,13 +45,18 @@ protected String getExpectedLog() {
return expectedLog;
}

protected Long getMemoryLimitMiB() {
return memoryLimitMiB;
}

@Override
public void init(Annotation annotation) {
KeycloakContainer metadata = (KeycloakContainer) annotation;
this.image = PropertiesUtils.resolveProperty(metadata.image());
this.restPort = metadata.port();
this.expectedLog = PropertiesUtils.resolveProperty(metadata.expectedLog());
this.command = metadata.command();
this.memoryLimitMiB = metadata.memoryLimitMiB();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.quarkus.test.services.containers;

import java.util.Optional;

import org.apache.commons.lang3.StringUtils;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
Expand Down Expand Up @@ -38,6 +40,8 @@ protected GenericContainer<?> initContainer() {
}

container.withCreateContainerCmdModifier(cmd -> cmd.withName(DockerUtils.generateDockerContainerName()));
container.withCreateContainerCmdModifier(cmd -> Optional.ofNullable(cmd.getHostConfig())
.ifPresent(config -> config.withMemory(convertMiBtoBytes(model.getMemoryLimitMiB()))));

if (isReusable()) {
Log.info(model.getContext().getOwner(), "Running container on Reusable mode");
Expand Down Expand Up @@ -66,4 +70,9 @@ protected boolean isReusable() {
private boolean isPrivileged() {
return model.getContext().getOwner().getConfiguration().isTrue(PRIVILEGED_MODE);
}

static long convertMiBtoBytes(long valueInMiB) {
final var exponentMiB = 20;
return (long) (valueInMiB * Math.pow(2, exponentMiB));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.quarkus.test.services.containers;

import static io.quarkus.test.services.containers.KeycloakGenericDockerContainerManagedResource.convertMiBtoBytes;
import static org.hamcrest.MatcherAssert.assertThat;

import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.Test;

public class MemoryLimitTest {

@Test
void convertMiBToBytes() {
assertThat(convertMiBtoBytes(0), CoreMatchers.is(0L));
assertThat(convertMiBtoBytes(-0), CoreMatchers.is(0L));

assertThat(convertMiBtoBytes(1000L), CoreMatchers.is(1048576000L));
assertThat(convertMiBtoBytes(1000), CoreMatchers.is(1048576000L));
assertThat(convertMiBtoBytes(100), CoreMatchers.is(104857600L));
assertThat(convertMiBtoBytes(10), CoreMatchers.is(10485760L));
assertThat(convertMiBtoBytes(1), CoreMatchers.is(1048576L));

assertThat(convertMiBtoBytes(-1000L), CoreMatchers.is(-1048576000L));
assertThat(convertMiBtoBytes(-1000), CoreMatchers.is(-1048576000L));
assertThat(convertMiBtoBytes(-100), CoreMatchers.is(-104857600L));
assertThat(convertMiBtoBytes(-10), CoreMatchers.is(-10485760L));
assertThat(convertMiBtoBytes(-1), CoreMatchers.is(-1048576L));

assertThat(convertMiBtoBytes(2000), CoreMatchers.is(2097152000L));
assertThat(convertMiBtoBytes(20000), CoreMatchers.is(20971520000L));
assertThat(convertMiBtoBytes(200000), CoreMatchers.is(209715200000L));

assertThat(convertMiBtoBytes(999999999999999999L), CoreMatchers.is(Long.MAX_VALUE));

assertThat(convertMiBtoBytes(Integer.MAX_VALUE), CoreMatchers.is((long) Integer.MAX_VALUE << 20));
assertThat(convertMiBtoBytes(Integer.MIN_VALUE), CoreMatchers.is((long) Integer.MIN_VALUE << 20));

assertThat(convertMiBtoBytes(Long.MAX_VALUE), CoreMatchers.is(Long.MAX_VALUE));
assertThat(convertMiBtoBytes(Long.MIN_VALUE), CoreMatchers.is(Long.MIN_VALUE));
}
}