Enable persistent sessions by default

Run CI with the feature disabled to test also the old settings
Closes #32265

Signed-off-by: Michal Hajas <mhajas@redhat.com>
This commit is contained in:
Michal Hajas 2024-08-20 12:36:26 +02:00 committed by Alexander Schwartz
parent 607ab01405
commit f5b2775939
9 changed files with 59 additions and 74 deletions

View file

@ -322,16 +322,12 @@ jobs:
with: with:
job-id: jdk-integration-tests-${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.version }} job-id: jdk-integration-tests-${{ matrix.os }}-${{ matrix.dist }}-${{ matrix.version }}
persistent-sessions-tests: volatile-sessions-tests:
name: Persistent Sessions IT name: Volatile Sessions IT
needs: [build, conditional] needs: [build, conditional]
if: needs.conditional.outputs.ci-store == 'true' if: needs.conditional.outputs.ci-store == 'true'
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 150 timeout-minutes: 150
strategy:
matrix:
variant: [ "pus-ec", "pus-rc" ]
fail-fast: false
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@ -341,22 +337,9 @@ jobs:
- name: Run base tests - name: Run base tests
run: | run: |
TESTS=`testsuite/integration-arquillian/tests/base/testsuites/suite.sh persistent-sessions` TESTS=`testsuite/integration-arquillian/tests/base/testsuites/suite.sh volatile-sessions`
echo "Tests: $TESTS" echo "Tests: $TESTS"
case "${{ matrix.variant }}" in ./mvnw test ${{ env.SUREFIRE_RETRY }} -Pauth-server-quarkus "-Dwebdriver.chrome.driver=$CHROMEWEBDRIVER/chromedriver" -Dauth.server.feature.disable=persistent-user-sessions -Dtest=$TESTS -pl testsuite/integration-arquillian/tests/base 2>&1 | misc/log/trimmer.sh
pus-ec)
VARIANT="-Dauth.server.feature=persistent-user-sessions"
;;
pus-rc)
VARIANT="-Pinfinispan-server -Dauth.server.feature=persistent-user-sessions,multi-site,remote-cache"
;;
*)
echo "Unknown Matrix element"
exit 1
;;
esac
echo "Variant: $VARIANT"
./mvnw test ${{ env.SUREFIRE_RETRY }} -Pauth-server-quarkus "-Dwebdriver.chrome.driver=$CHROMEWEBDRIVER/chromedriver" $VARIANT -Dtest=$TESTS -pl testsuite/integration-arquillian/tests/base 2>&1 | misc/log/trimmer.sh
- name: Upload JVM Heapdumps - name: Upload JVM Heapdumps
if: always() if: always()
@ -403,7 +386,7 @@ jobs:
run: | run: |
TESTS=`testsuite/integration-arquillian/tests/base/testsuites/suite.sh remote-cache` TESTS=`testsuite/integration-arquillian/tests/base/testsuites/suite.sh remote-cache`
echo "Tests: $TESTS" echo "Tests: $TESTS"
./mvnw test ${{ env.SUREFIRE_RETRY }} -Pauth-server-quarkus -Pinfinispan-server -Dauth.server.feature=${{ matrix.variant }} -Dtest=$TESTS -pl testsuite/integration-arquillian/tests/base 2>&1 | misc/log/trimmer.sh ./mvnw test ${{ env.SUREFIRE_RETRY }} -Pauth-server-quarkus -Pinfinispan-server -Dauth.server.feature=${{ matrix.variant }} -Dauth.server.feature.disable=persistent-user-sessions -Dtest=$TESTS -pl testsuite/integration-arquillian/tests/base 2>&1 | misc/log/trimmer.sh
- name: Upload JVM Heapdumps - name: Upload JVM Heapdumps
if: always() if: always()
@ -973,7 +956,7 @@ jobs:
- quarkus-integration-tests - quarkus-integration-tests
- jdk-integration-tests - jdk-integration-tests
- store-integration-tests - store-integration-tests
- persistent-sessions-tests - volatile-sessions-tests
- store-model-tests - store-model-tests
- clustering-integration-tests - clustering-integration-tests
- fips-unit-tests - fips-unit-tests

View file

@ -111,7 +111,7 @@ public class Profile {
HOSTNAME_V1("Hostname Options V1", Type.DEPRECATED, 1), HOSTNAME_V1("Hostname Options V1", Type.DEPRECATED, 1),
HOSTNAME_V2("Hostname Options V2", Type.DEFAULT, 2), HOSTNAME_V2("Hostname Options V2", Type.DEFAULT, 2),
PERSISTENT_USER_SESSIONS("Persistent online user sessions across restarts and upgrades", Type.PREVIEW), PERSISTENT_USER_SESSIONS("Persistent online user sessions across restarts and upgrades", Type.DEFAULT),
OID4VC_VCI("Support for the OID4VCI protocol as part of OID4VC.", Type.EXPERIMENTAL), OID4VC_VCI("Support for the OID4VCI protocol as part of OID4VC.", Type.EXPERIMENTAL),

View file

@ -236,9 +236,10 @@ public abstract class AbstractQuarkusDeployableContainer implements DeployableCo
} }
protected void addFeaturesOption(List<String> commands) { protected void addFeaturesOption(List<String> commands) {
String defaultFeatures = configuration.getDefaultFeatures(); String enabledFeatures = configuration.getEnabledFeatures();
String disabledFeatures = configuration.getDisabledFeatures();
if (StringUtil.isBlank(defaultFeatures)) { if (StringUtil.isBlank(enabledFeatures) && StringUtil.isBlank(disabledFeatures)) {
return; return;
} }
@ -246,24 +247,32 @@ public abstract class AbstractQuarkusDeployableContainer implements DeployableCo
return; return;
} }
StringBuilder featuresOption = new StringBuilder("--features=").append(defaultFeatures); if (!StringUtil.isBlank(enabledFeatures)) {
Iterator<String> iterator = commands.iterator(); appendOrAddCommand(commands, "--features=", enabledFeatures);
while (iterator.hasNext()) {
String command = iterator.next();
if (command.startsWith("--features")) {
featuresOption = new StringBuilder(command);
featuresOption.append(",").append(defaultFeatures);
iterator.remove();
break;
} }
if (!StringUtil.isBlank(disabledFeatures)) {
appendOrAddCommand(commands, "--features-disabled=", disabledFeatures);
} }
// enabling or disabling features requires rebuilding the image // enabling or disabling features requires rebuilding the image
prepareCommandsForRebuilding(commands); prepareCommandsForRebuilding(commands);
}
commands.add(featuresOption.toString()); private void appendOrAddCommand(List<String> commands, String command, String addition) {
Iterator<String> iterator = commands.iterator();
while (iterator.hasNext()) {
String existingCommand = iterator.next();
if (existingCommand.startsWith(command)) {
iterator.remove();
commands.add(existingCommand + "," + addition);
return;
}
}
commands.add(command + addition);
} }
protected List<String> configureArgs(List<String> commands) { protected List<String> configureArgs(List<String> commands) {
@ -425,7 +434,7 @@ public abstract class AbstractQuarkusDeployableContainer implements DeployableCo
} }
private Collection<String> getDefaultFeatures() { private Collection<String> getDefaultFeatures() {
var features = configuration.getDefaultFeatures(); var features = configuration.getEnabledFeatures();
if (features == null || features.isBlank()) { if (features == null || features.isBlank()) {
return List.of(); return List.of();
} }

View file

@ -48,7 +48,8 @@ public class KeycloakQuarkusConfiguration implements ContainerConfiguration {
private FipsMode fipsMode = FipsMode.valueOfOption(System.getProperty("auth.server.fips.mode")); private FipsMode fipsMode = FipsMode.valueOfOption(System.getProperty("auth.server.fips.mode"));
private String defaultFeatures; private String enabledFeatures;
private String disabledFeatures;
@Override @Override
public void validate() throws ConfigurationException { public void validate() throws ConfigurationException {
@ -241,11 +242,19 @@ public class KeycloakQuarkusConfiguration implements ContainerConfiguration {
this.fipsMode = fipsMode; this.fipsMode = fipsMode;
} }
public void setDefaultFeatures(String defaultFeatures) { public void setEnabledFeatures(String enabledFeatures) {
this.defaultFeatures = defaultFeatures; this.enabledFeatures = enabledFeatures;
} }
public String getDefaultFeatures() { public String getEnabledFeatures() {
return defaultFeatures; return enabledFeatures;
}
public String getDisabledFeatures() {
return disabledFeatures;
}
public void setDisabledFeatures(String disabledFeatures) {
this.disabledFeatures = disabledFeatures;
} }
} }

View file

@ -636,7 +636,8 @@
<property name="javaOpts">-Xms512m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=512m <property name="javaOpts">-Xms512m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=512m
-Djava.net.preferIPv4Stack=true -Dauth.server.db.host=some -Djava.net.preferIPv4Stack=true -Dauth.server.db.host=some
</property> </property>
<property name="defaultFeatures">${auth.server.feature}</property> <property name="enabledFeatures">${auth.server.feature}</property>
<property name="disabledFeatures">${auth.server.feature.disable}</property>
</configuration> </configuration>
</container> </container>
@ -647,7 +648,8 @@
org.keycloak.testsuite.arquillian.containers.KeycloakQuarkusEmbeddedDeployableContainer org.keycloak.testsuite.arquillian.containers.KeycloakQuarkusEmbeddedDeployableContainer
</property> </property>
<property name="bindHttpPortOffset">${auth.server.port.offset}</property> <property name="bindHttpPortOffset">${auth.server.port.offset}</property>
<property name="defaultFeatures">${auth.server.feature}</property> <property name="enabledFeatures">${auth.server.feature}</property>
<property name="disabledFeatures">${auth.server.feature.disable}</property>
</configuration> </configuration>
</container> </container>

View file

@ -96,6 +96,7 @@
<auth.server.profile/> <auth.server.profile/>
<auth.server.feature/> <auth.server.feature/>
<auth.server.feature.disable/>
<auth.server.host2>${auth.server.host}</auth.server.host2> <!-- for broker and JS adapter tests; defaults to auth.server.host --> <auth.server.host2>${auth.server.host}</auth.server.host2> <!-- for broker and JS adapter tests; defaults to auth.server.host -->
<app.server.host>localhost</app.server.host> <app.server.host>localhost</app.server.host>
@ -454,6 +455,7 @@
<auth.server.profile>${auth.server.profile}</auth.server.profile> <auth.server.profile>${auth.server.profile}</auth.server.profile>
<auth.server.feature>${auth.server.feature}</auth.server.feature> <auth.server.feature>${auth.server.feature}</auth.server.feature>
<auth.server.feature.disable>${auth.server.feature.disable}</auth.server.feature.disable>
<auth.server.host2>${auth.server.host2}</auth.server.host2> <!-- for broker tests --> <auth.server.host2>${auth.server.host2}</auth.server.host2> <!-- for broker tests -->

View file

@ -224,32 +224,12 @@
</profile> </profile>
<profile> <profile>
<id>jpa+infinispan+persistentsessions</id> <id>jpa+infinispan+volatilesessions</id>
<properties> <properties>
<keycloak.model.parameters>Infinispan,Jpa,PersistentUserSessions</keycloak.model.parameters> <keycloak.model.parameters>Infinispan,Jpa,VolatileUserSessions</keycloak.model.parameters>
</properties> </properties>
</profile> </profile>
<profile>
<id>jpa+cross-dc-infinispan+persistentsessions</id>
<properties>
<keycloak.model.parameters>CrossDCInfinispan,Jpa,PersistentUserSessions</keycloak.model.parameters>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<keycloak.profile.feature.multi_site>enabled</keycloak.profile.feature.multi_site>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile> <profile>
<id>jpa+infinispan+client-storage</id> <id>jpa+infinispan+client-storage</id>
<properties> <properties>

View file

@ -23,9 +23,9 @@ import org.keycloak.testsuite.model.KeycloakModelParameters;
import java.util.Collections; import java.util.Collections;
public class PersistentUserSessions extends KeycloakModelParameters { public class VolatileUserSessions extends KeycloakModelParameters {
public PersistentUserSessions() { public VolatileUserSessions() {
super(Collections.emptySet(), Collections.emptySet()); super(Collections.emptySet(), Collections.emptySet());
} }
@ -35,6 +35,6 @@ public class PersistentUserSessions extends KeycloakModelParameters {
} }
public static void updateConfigForJpa(Config cf) { public static void updateConfigForJpa(Config cf) {
System.getProperties().put(PropertiesProfileConfigResolver.getPropertyKey(Profile.Feature.PERSISTENT_USER_SESSIONS), "enabled"); System.getProperties().put(PropertiesProfileConfigResolver.getPropertyKey(Profile.Feature.PERSISTENT_USER_SESSIONS), "disabled");
} }
} }