Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Comments

Added the shutdown delay and shutdown timeout for the testcases to default options #46414

Open
ruchikajha95 wants to merge 8 commits intokeycloak:mainfrom
ruchikajha95:feature-46337/testcase_0seconds_delay
Open

Added the shutdown delay and shutdown timeout for the testcases to default options #46414
ruchikajha95 wants to merge 8 commits intokeycloak:mainfrom
ruchikajha95:feature-46337/testcase_0seconds_delay

Conversation

@ruchikajha95
Copy link
Contributor

@ruchikajha95 ruchikajha95 commented Feb 17, 2026

Closes #46337

Approach 1:
Added --shutdown-delay=0s", "--shutdown-timeout=1s"

Tested eg: $ time mvn clean test -Dtest=UpdateCommandDistTest

Before changes output:
real 1m57.160s
user 12m21.342s
sys 0m34.469s

After changes output:
real 0m43.130s
user 3m2.158s
sys 0m5.901s

Approach 2:

Added the Added --shutdown-delay=0s", "--shutdown-timeout=1s" implicitly instead of the default options.

@ruchikajha95 ruchikajha95 requested a review from pruivo February 18, 2026 15:29
* If any option must be set when starting the server.
*/
String[] defaultOptions() default {};

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change should be reverted.


args.addAll(List.of(config.defaultOptions()));

if (isStartCommand(args)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All changes in this file can be replaced with one line

setEnvVar("KC_SHUTDOWN_DELAY", "0s");

this.tlsEnabled = tlsEnabled;

List<String> args = keycloakServerConfigBuilder.toArgs();
if (args.stream().noneMatch(arg -> arg.startsWith("--shutdown-delay"))) {
Copy link
Member

@pruivo pruivo Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, in the method startKeycloak(), you can add

pb.environment().put("KC_SHUTDOWN_DELAY", "0s");

@ruchikajha95 ruchikajha95 force-pushed the feature-46337/testcase_0seconds_delay branch from 5c748bc to 0b6d0ad Compare February 19, 2026 13:21
@ryanemerson ryanemerson self-requested a review February 19, 2026 17:07
commands.add("--health-enabled=true"); // expose something to management interface to turn it on

// reduce shutdown delay to speed up testsuite execution.
env.put("KC_SHUTDOWN_DELAY", "0s");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, we could've used the CLI option to be consistent with other options being set here. In this testsuite we don't expect the tests would be overriding this option, so no need for the env var (if that was the motivation to use it over the CLI option in other places.

That said, it's not blocking, it's good as is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggested using the environment variable approach to keep consistent with the other places.
You're right, it doesn't seem possible to overwrite the command list in this class.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you mean consistent across testsuite, we're inconsistent already how each of them configures KC. The Arquillian testsuite uses CLI options, that was my argument here.


OutputHandler outputHandler;
try {
pb.environment().put("KC_SHUTDOWN_DELAY", "0s");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might want to put this somewhere into default options in the testsuite? @shawkins Do you remember where?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I don't recall a place for that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I found it:

private static KeycloakServerConfigBuilder getKeycloakServerConfigBuilder(KeycloakIntegrationTest annotation) {
KeycloakServerConfig serverConfig = SupplierHelpers.getInstance(annotation.config());
KeycloakServerConfigBuilder command = KeycloakServerConfigBuilder.startDev()
.bootstrapAdminClient(Config.getAdminClientId(), Config.getAdminClientSecret())
.bootstrapAdminUser(Config.getAdminUsername(), Config.getAdminPassword());

@lhanusov @stianst Can you please confirm this would be the correct place to provide default config options to the new testsuite?

@vmuzikar vmuzikar requested a review from shawkins February 19, 2026 17:52
Copy link
Contributor

@shawkins shawkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this only needed for distribution tests? What about embedded? And in general should start-dev shut down immediately?

@pruivo
Copy link
Member

pruivo commented Feb 19, 2026

@shawkins, we discussed the embedded mode, and we decided to ignore it and focus on making the GH actions faster. Embedded mode is not used by GH actions as far as we know, and it may go away with the new testsutite (?).

We never thought about start-dev, unfortunately 😅. I don't oppose having no delay during shutdown (assuming nobody uses it in production).

@shawkins
Copy link
Contributor

@shawkins, we discussed the embedded mode, and we decided to ignore it and focus on making the GH actions faster. Embedded mode is not used by GH actions as far as we know, and it may go away with the new testsutite (?).

Embedded mode is supported with the new testsuite and does seem to be used, just not by GH - cc @stianst @lhanusov

One other thought - is this adding any measurable delay to the operator tests?

@vmuzikar
Copy link
Contributor

Embedded is used for local development where speed is also important. It's also important to be consistent across testsuite modes (remote/embedded). So +1 to @shawkins to add this to embedded too.

@vmuzikar vmuzikar disabled auto-merge February 20, 2026 07:44
@ruchikajha95
Copy link
Contributor Author

Thank you everyone for the insightful discussion.
I acknowledge the importance of ensuring that the shutdown delay configuration applies consistently to both remote and embedded server modes, as highlighted.

Could the team decide to centralize this configuration (e.g., within AbstractKeycloakServerSupplier as referenced), or if there are further changes required to ensure alignment across all test scenarios, I am happy to implement these improvements. Please let me know if you would prefer that I make these updates within this PR, or if it would be better to address them in a subsequent PR.

Thanks again for your thorough review and the collaborative discussion.

cc: @ahus1 , @pruivo , @ryanemerson , @shawkins , @vmuzikar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run tests with shutdown-delay of 0 seconds

5 participants