Skip to content

Commit

Permalink
Change waiting strategy for PG imgs from RH registry till FW fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
michalvavrik committed Jun 28, 2024
1 parent 6c00f4d commit c4ca78c
Show file tree
Hide file tree
Showing 13 changed files with 172 additions and 54 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package io.quarkus.ts.external.applications;

import static org.hamcrest.Matchers.is;

import org.apache.http.HttpStatus;
import org.junit.jupiter.api.Test;

import io.quarkus.test.bootstrap.RestService;
import io.quarkus.test.scenarios.annotations.DisabledOnNative;
import io.restassured.http.ContentType;

@DisabledOnNative(reason = "This scenario is using uber-jar, so it's incompatible with Native")
public abstract class AbstractTodoDemoIT {
protected static final String TODO_REPO = "https://github.com/quarkusio/todo-demo-app.git";
protected static final String VERSIONS = "-Dquarkus.platform.group-id=${QUARKUS_PLATFORM_GROUP-ID} -Dquarkus.platform.version=${QUARKUS_PLATFORM_VERSION} ";
protected static final String DEFAULT_OPTIONS = " -DskipTests=true " + VERSIONS;

protected abstract RestService getApp();

protected abstract RestService getReplaced();

@Test
public void startsSuccessfully() {
getApp().given()
.contentType(ContentType.JSON)
.body("{\"title\": \"Use Quarkus\", \"order\": 1, \"url\": \"https://quarkus.io\"}")
.post("/api")
.then()
.statusCode(HttpStatus.SC_CREATED);
}

@Test
public void replacedStartsSuccessfully() {
getReplaced().given()
.accept(ContentType.JSON)
.get("/api")
.then()
.statusCode(HttpStatus.SC_OK)
.body("$.size()", is(1))
.body("title[0]", is("Use Quarkus"));
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,42 @@
package io.quarkus.ts.external.applications;

import io.quarkus.test.bootstrap.PostgresqlService;
import io.quarkus.test.bootstrap.RestService;
import io.quarkus.test.scenarios.OpenShiftScenario;
import io.quarkus.test.scenarios.annotations.DisabledOnNative;
import io.quarkus.test.services.Container;
import io.quarkus.test.services.GitRepositoryQuarkusApplication;

@DisabledOnNative(reason = "Native + s2i not supported")
@OpenShiftScenario
public class OpenShiftTodoDemoIT extends TodoDemoIT {
public class OpenShiftTodoDemoIT extends AbstractTodoDemoIT {

// FIXME: change expected log when https://github.com/quarkus-qe/quarkus-test-framework/issues/1183 is fixed
@Container(image = "${postgresql.latest.image}", port = 5432, expectedLog = "Future log output will appear in directory")
static PostgresqlService database = new PostgresqlService()
// store data in /tmp/psql as in OpenShift we don't have permissions to /var/lib/postgresql/data
.withProperty("PGDATA", "/tmp/psql");

@GitRepositoryQuarkusApplication(repo = TODO_REPO, mavenArgs = "-Dquarkus.package.jar.type=uber-jar" + DEFAULT_OPTIONS)
static final RestService app = new RestService()
.withProperty("quarkus.datasource.username", database.getUser())
.withProperty("quarkus.datasource.password", database.getPassword())
.withProperty("quarkus.datasource.jdbc.url", database::getJdbcUrl);

@GitRepositoryQuarkusApplication(repo = TODO_REPO, artifact = "todo-backend-1.0-SNAPSHOT.jar", mavenArgs = "-Dquarkus.package.jar.type=uber-jar -Dquarkus.package.add-runner-suffix=false"
+ DEFAULT_OPTIONS)
static final RestService replaced = new RestService()
.withProperty("quarkus.datasource.username", database.getUser())
.withProperty("quarkus.datasource.password", database.getPassword())
.withProperty("quarkus.datasource.jdbc.url", database::getJdbcUrl);

@Override
protected RestService getApp() {
return app;
}

@Override
protected RestService getReplaced() {
return replaced;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public class OpenShiftWorkshopHeroesIT {

private static final int POSTGRESQL_PORT = 5432;

@Container(image = "${postgresql.latest.image}", port = POSTGRESQL_PORT, expectedLog = "listening on IPv4 address")
// FIXME: change expected log when https://github.com/quarkus-qe/quarkus-test-framework/issues/1183 is fixed
@Container(image = "${postgresql.latest.image}", port = POSTGRESQL_PORT, expectedLog = "Future log output will appear in directory")
static PostgresqlService database = new PostgresqlService()
.withProperty("PGDATA", "/tmp/psql");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public class OpenShiftWorkshopVillainsIT {

private static final int POSTGRESQL_PORT = 5432;

@Container(image = "${postgresql.latest.image}", port = POSTGRESQL_PORT, expectedLog = "listening on IPv4 address")
// FIXME: change expected log when https://github.com/quarkus-qe/quarkus-test-framework/issues/1183 is fixed
@Container(image = "${postgresql.latest.image}", port = POSTGRESQL_PORT, expectedLog = "Future log output will appear in directory")
static PostgresqlService database = new PostgresqlService()
.withProperty("PGDATA", "/tmp/psql");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
package io.quarkus.ts.external.applications;

import static org.hamcrest.Matchers.is;

import org.apache.http.HttpStatus;
import org.junit.jupiter.api.Test;

import io.quarkus.test.bootstrap.PostgresqlService;
import io.quarkus.test.bootstrap.RestService;
import io.quarkus.test.scenarios.QuarkusScenario;
import io.quarkus.test.scenarios.annotations.DisabledOnNative;
import io.quarkus.test.services.Container;
import io.quarkus.test.services.GitRepositoryQuarkusApplication;
import io.restassured.http.ContentType;

@DisabledOnNative(reason = "This scenario is using uber-jar, so it's incompatible with Native")
@QuarkusScenario
public class TodoDemoIT {
private static final String TODO_REPO = "https://github.com/quarkusio/todo-demo-app.git";
private static final String VERSIONS = "-Dquarkus.platform.group-id=${QUARKUS_PLATFORM_GROUP-ID} -Dquarkus.platform.version=${QUARKUS_PLATFORM_VERSION} ";
private static final String DEFAULT_OPTIONS = " -DskipTests=true " + VERSIONS;
public class TodoDemoIT extends AbstractTodoDemoIT {

@Container(image = "${postgresql.latest.image}", port = 5432, expectedLog = "listening on IPv4 address")
static PostgresqlService database = new PostgresqlService()
Expand All @@ -38,24 +27,13 @@ public class TodoDemoIT {
.withProperty("quarkus.datasource.password", database.getPassword())
.withProperty("quarkus.datasource.jdbc.url", database::getJdbcUrl);

@Test
public void startsSuccessfully() {
app.given()
.contentType(ContentType.JSON)
.body("{\"title\": \"Use Quarkus\", \"order\": 1, \"url\": \"https://quarkus.io\"}")
.post("/api")
.then()
.statusCode(HttpStatus.SC_CREATED);
@Override
protected RestService getApp() {
return app;
}

@Test
public void replacedStartsSuccessfully() {
replaced.given()
.accept(ContentType.JSON)
.get("/api")
.then()
.statusCode(HttpStatus.SC_OK)
.body("$.size()", is(1))
.body("title[0]", is("Use Quarkus"));
@Override
protected RestService getReplaced() {
return replaced;
}
}
36 changes: 22 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -745,20 +745,28 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<ts.redhat.registry.enabled>true</ts.redhat.registry.enabled>
<!-- Product Services -->
<rhbk.image>${rhbk.image}</rhbk.image>
<postgresql.10.image>registry.redhat.io/rhel8/postgresql-10</postgresql.10.image>
<postgresql.latest.image>registry.redhat.io/rhel9/postgresql-15</postgresql.latest.image>
<mariadb.103.image>registry.redhat.io/rhel8/mariadb-103</mariadb.103.image>
<mariadb.105.image>registry.redhat.io/rhel9/mariadb-105</mariadb.105.image>
<amq-streams.image>registry.redhat.io/amq-streams/kafka-35-rhel8</amq-streams.image>
<amq-streams.version>2.6.0</amq-streams.version>
</systemPropertyVariables>
<rerunFailingTestsCount>${oc.reruns}</rerunFailingTestsCount>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemPropertyVariables>
<ts.redhat.registry.enabled>true</ts.redhat.registry.enabled>
<!-- Product Services -->
<rhbk.image>${rhbk.image}</rhbk.image>
<postgresql.10.image>registry.redhat.io/rhel8/postgresql-10</postgresql.10.image>
<postgresql.latest.image>registry.redhat.io/rhel9/postgresql-15</postgresql.latest.image>
<mariadb.103.image>registry.redhat.io/rhel8/mariadb-103</mariadb.103.image>
<mariadb.105.image>registry.redhat.io/rhel9/mariadb-105</mariadb.105.image>
<amq-streams.image>registry.redhat.io/amq-streams/kafka-35-rhel8</amq-streams.image>
<amq-streams.version>2.6.0</amq-streams.version>
</systemPropertyVariables>
<rerunFailingTestsCount>${oc.reruns}</rerunFailingTestsCount>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
public class AbstractDbIT {
static final int POSTGRESQL_PORT = 5432;

@Container(image = "${postgresql.latest.image}", port = POSTGRESQL_PORT, expectedLog = "listening on IPv4 address")
// FIXME: here PG image must not be hardcoded, we need to use ${postgresql.latest.image} system property;
// however using Red Hat image here would require a lot of refactoring
// we need to address https://github.com/quarkus-qe/quarkus-test-framework/issues/1183 first
@Container(image = "docker.io/postgres:16.1", port = POSTGRESQL_PORT, expectedLog = "listening on IPv4 address")
static final PostgresqlService database = new PostgresqlService()
.withProperty("PGDATA", "/tmp/psql");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,37 @@
package io.quarkus.ts.hibernate.reactive.openshift;

import io.quarkus.test.bootstrap.PostgresqlService;
import io.quarkus.test.bootstrap.RestService;
import io.quarkus.test.scenarios.OpenShiftScenario;
import io.quarkus.ts.hibernate.reactive.PostgresqlDatabaseHibernateReactiveIT;
import io.quarkus.test.services.Container;
import io.quarkus.test.services.QuarkusApplication;
import io.quarkus.ts.hibernate.reactive.AbstractDatabaseHibernateReactiveIT;

@OpenShiftScenario
public class OpenShiftPostgresqlHibernateReactiveIT extends PostgresqlDatabaseHibernateReactiveIT {
public class OpenShiftPostgresqlHibernateReactiveIT extends AbstractDatabaseHibernateReactiveIT {

private static final String POSTGRES_USER = "quarkus_test";
private static final String POSTGRES_PASSWORD = "quarkus_test";
private static final String POSTGRES_DATABASE = "quarkus_test";
private static final int POSTGRES_PORT = 5432;

// FIXME: change expected log when https://github.com/quarkus-qe/quarkus-test-framework/issues/1183 is fixed
@Container(image = "${postgresql.latest.image}", port = POSTGRES_PORT, expectedLog = "Future log output will appear in directory")
static PostgresqlService database = new PostgresqlService()
.withUser(POSTGRES_USER)
.withPassword(POSTGRES_PASSWORD)
.withDatabase(POSTGRES_DATABASE)
.withProperty("PGDATA", "/tmp/psql");

@QuarkusApplication
static RestService app = new RestService().withProperties("postgresql.properties")
.withProperty("quarkus.datasource.username", POSTGRES_USER)
.withProperty("quarkus.datasource.password", POSTGRES_PASSWORD)
.withProperty("quarkus.datasource.reactive.url", database::getReactiveUrl);

@Override
protected RestService getApp() {
return app;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public class OpenShiftMultiplePersistenceIT extends AbstractMultiplePersistenceI
@Container(image = "${mariadb.103.image}", port = MYSQL_PORT, expectedLog = "Only MySQL server logs after this point")
static MariaDbService mariadb = new MariaDbService();

@Container(image = "${postgresql.latest.image}", port = POSTGRESQL_PORT, expectedLog = "listening on IPv4 address")
// FIXME: change expected log when https://github.com/quarkus-qe/quarkus-test-framework/issues/1183 is fixed
@Container(image = "${postgresql.latest.image}", port = POSTGRESQL_PORT, expectedLog = "Future log output will appear in directory")
static PostgresqlService postgresql = new PostgresqlService()
.withProperty("PGDATA", "/tmp/psql");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
@OpenShiftScenario
public class OpenShiftPostgresqlTransactionGeneralUsageIT extends AbstractPostgresqlTransactionGeneralUsageIT {

@Container(image = "${postgresql.latest.image}", port = POSTGRESQL_PORT, expectedLog = "listening on IPv4 address")
// FIXME: change expected log when https://github.com/quarkus-qe/quarkus-test-framework/issues/1183 is fixed
@Container(image = "${postgresql.latest.image}", port = POSTGRESQL_PORT, expectedLog = "Future log output will appear in directory")
static final PostgresqlService database = new PostgresqlService()
// following env variable is accepted by PG images from Red Hat registry
.withProperty("POSTGRESQL_MAX_PREPARED_TRANSACTIONS", "100")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
package io.quarkus.ts.reactive.rest.data.panache;

import io.quarkus.test.bootstrap.PostgresqlService;
import io.quarkus.test.bootstrap.RestService;
import io.quarkus.test.scenarios.OpenShiftScenario;
import io.quarkus.test.services.Container;
import io.quarkus.test.services.QuarkusApplication;

@OpenShiftScenario
public class OpenShiftPostgresqlPanacheResourceIT extends PostgresqlPanacheResourceIT {
public class OpenShiftPostgresqlPanacheResourceIT extends AbstractPanacheResourceIT {

private static final int POSTGRESQL_PORT = 5432;

// FIXME: change expected log when https://github.com/quarkus-qe/quarkus-test-framework/issues/1183 is fixed
@Container(image = "${postgresql.latest.image}", port = POSTGRESQL_PORT, expectedLog = "Future log output will appear in directory")
public static final PostgresqlService database = new PostgresqlService()
.withProperty("POSTGRES_DB", "mydb")
.withProperty("PGDATA", "/tmp/psql");

@QuarkusApplication
public static final RestService app = new RestService().withProperties("postgresql.properties")
.withProperty("quarkus.datasource.username", database.getUser())
.withProperty("quarkus.datasource.password", database.getPassword())
.withProperty("quarkus.datasource.jdbc.url", database::getJdbcUrl);

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@QuarkusScenario
public class PostgresqlPanacheResourceIT extends AbstractPanacheResourceIT {

static final int POSTGRESQL_PORT = 5432;
private static final int POSTGRESQL_PORT = 5432;

@Container(image = "${postgresql.latest.image}", port = POSTGRESQL_PORT, expectedLog = "listening on IPv4 address")
public static final PostgresqlService database = new PostgresqlService()
Expand All @@ -21,4 +21,5 @@ public class PostgresqlPanacheResourceIT extends AbstractPanacheResourceIT {
.withProperty("quarkus.datasource.username", database.getUser())
.withProperty("quarkus.datasource.password", database.getPassword())
.withProperty("quarkus.datasource.jdbc.url", database::getJdbcUrl);

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public class OpenShiftPostgresqlDatabaseIT extends AbstractSqlDatabaseIT {

static final int POSTGRESQL_PORT = 5432;

@Container(image = "${postgresql.latest.image}", port = POSTGRESQL_PORT, expectedLog = "listening on IPv4 address")
// FIXME: change expected log when https://github.com/quarkus-qe/quarkus-test-framework/issues/1183 is fixed
@Container(image = "${postgresql.latest.image}", port = POSTGRESQL_PORT, expectedLog = "Future log output will appear in directory")
static PostgresqlService database = new PostgresqlService()
.withProperty("PGDATA", "/tmp/psql");

Expand Down

0 comments on commit c4ca78c

Please sign in to comment.