8000 [Testsuite PoC] Adding config to provide option to select supplier types by wojnarfilip · Pull Request #31295 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

[Testsuite PoC] Adding config to provide option to select supplier types - #31295

Closed
wojnarfilip wants to merge 1 commit into
keycloak:mainfrom
wojnarfilip:PoC-config
Closed

wojnarfilip wants to merge 1 commit into
keycloak:mainfrom
wojnarfilip:PoC-config

Conversation

@wojnarfilip
@wojnarfilip wojnarfilip commented Jul 15, 2024 •
Copy link
Copy Markdown
Contributor

Default Config Sources and their ordinal can be found there https://smallrye.io/smallrye-config/Main/config/getting-started/.

Closes #30608

Comment on lines 17 to 22
@wojnarfilip wojnarfilip Jul 15, 2024 •
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure if there is more elegant way to check that file based config was provided with -Dkc.test.config

Comment on lines 12 to 30
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

After seeing this PR https://github.com/keycloak/keycloak/pull/31292/files. I guess it would be better to do something like this and have static getters right ? @stianst @miquelsi

    private static final SmallRyeConfig config;

    static {
        List<ConfigSource> configSources = new ArrayList<>();

        String kcTestConfigPath = System.getProperty("kc.test.config");
        if (kcTestConfigPath != null) {
            configSources.add(new FileConfigSource());
        }

        config = new SmallRyeConfigBuilder()
                .addDefaultSources()
                .addDefaultInterceptors()
                .withSources(configSources)
                .build();
    }

So the config is more global and there isn't need to initialize it.

@wojnarfilip
wojnarfilip marked this pull request as ready for review July 15, 2024 17:06
@wojnarfilip
wojnarfilip requested a review from a team as a code owner July 15, 2024 17:06
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@wojnarfilip please, rebase to latest change and focus on smallrye support of .env files (out of the box), I would propose to remove this class then: test-poc/framework/src/main/java/org/keycloak/test/framework/config/Config.java

@wojnarfilip
wojnarfilip force-pushed the PoC-config branch 2 times, most recently from 9c45403 to dc7e4c2 Compare July 16, 2024 10:38
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this needed? Looking at https://smallrye.io/smallrye-config/Main/config/getting-started/ it should already support .env file from the current working directory by default

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This class is for loading of config values from file provided with -Dkc.test.config= as was mentioned in #30608.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same with this is it needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

At this point probably not. Will remove this.

My thought behind this was that we might implement more ConfigSources specific for Keycloak over time and might want our own interface to be more flexible.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would just call this Config or TestConfig, KeycloakSmallryeConfig is longer than it needs to be ;)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Renamed

@stianst
stianst commented Jul 16, 2024
Copy link
Copy Markdown
Contributor

This may be better done as a follow-up, but wonder how we will support passing CLI options when running tests.

The following won't work as kc.test.browser won't be passed to the tests by Surefire:

mvn test -Dkc.test.browser=firefox

Having to wire-up all options in the pom.xml to pass to Surefire is also not very elegant.

Perhaps just using environment variables is better:

KC_TEST_BROWSER=firefox mvn test

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't you want to create private static final String testConfig = "kc.test.config" variable in here for better readability?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@wojnarfilip outer parentheses not required, probably a typo

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed

Signed-off-by: wojnarfilip <fwojnar@redhat.com>
@lhanusov lhanusov left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks for your fixes, good job @wojnarfilip, LGTM

@stianst
stianst commented Jul 19, 2024
Copy link
Copy Markdown
Contributor

There's a PropertiesConfigSource in Smallrye that we can use instead of creating our own FileConfigSource. I'm also not a huge fan of big static initialization blocks, so would be better to extract the init into a static method.

I did a quick cleanup proposal here:
stianst@92b2c57

@jonkoops
Copy link
Copy Markdown
Contributor

+1 for the proposed commit by @stianst

@wojnarfilip
Copy link
Copy Markdown
Contributor Author

Lets go with @stianst commit then, should I close this ?

@jonkoops
Copy link
Copy Markdown
Contributor

I think you can just cherry-pick the proposed changes on top of this PR.

@stianst
stianst commented Jul 19, 2024 •
Copy link
Copy Markdown
Contributor

Created a PR #31434 - I can squash it on merge

@stianst
stianst commented Jul 19, 2024
Copy link
Copy Markdown
Contributor

Closing in favor of #31434

@stianst stianst closed this Jul 19, 2024
@wojnarfilip
wojnarfilip deleted the PoC-config branch October 31, 2024 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Testsuite PoC - Configuration when running tests

4 participants

0