-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add conditional workflow for test-poc #31406
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
Conversation
f43629e to
80e5949
Compare
lhanusov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here are few suggestions, otherwise it looks good to me 👍
|
|
||
| @Override | ||
| public WebDriver getWebDriver() { | ||
| return new ChromeDriver(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will help to find Selenium Web elements properly:
ChromeOptions options = new ChromeOptions();
options.setImplicitWaitTimeout(Duration.ofMillis(1000));
options.setPageLoadStrategy(PageLoadStrategy.NORMAL);
return new ChromeDriver(options);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added to AbstractWebDriverSupplier
| public String getAlias() { | ||
| return "firefox"; | ||
| public WebDriver getWebDriver() { | ||
| return new FirefoxDriver(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as for chrome:
FirefoxOptions options = new FirefoxOptions();
options.setImplicitWaitTimeout(Duration.ofMillis(1000));
options.setPageLoadStrategy(PageLoadStrategy.NORMAL);
return new `FirefoxDriver(options);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added to AbstractWebDriverSupplier
| public class ChromeWebDriverSupplier extends AbstractWebDriverSupplier { | ||
|
|
||
| @Override | ||
| public String getAlias() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be also defined as abstract in AbstractWebDriverSupplier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, alias is optional, the default name for a supplier will be class.getSimpleName
| @Override | ||
| public void close(WebDriver instance) { | ||
| instance.quit(); | ||
| public String getAlias() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be also defined as abstract in AbstractWebDriverSupplier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, alias is optional, the default name for a supplier will be class.getSimpleName
| } catch (InterruptedException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| Thread.sleep(1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once Chrome and Firefox options are in place this can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
| return getValue(registry, annotation); | ||
| void initValue(InstanceContext<T, S> instanceContext); | ||
|
|
||
| default LifeCycle lifeCycle(S annotation) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the difference between lifecycle and getDefaultLifecycle? In AbstractWebDriverSupplier is lifecycle and in AbstractKeycloakServerSupplier only getDefaultLifecycle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registry calls getLifeCycle(annotation) to get the life cycle a given instance should have, by default that will look for a method lifecycle on the annotation and use that value if present, otherwise it will call getDefaultLifeCycle. That basically means we can have a consistent approach to the lifecycle in annotations.
An alternative approach would just be to let the suppliers handle it all; and return the lifecycle from the annotation if present, or the default lifecycle. Then we'd only have getLifeCycle (without a default implementation) and remove getDefaultLifecycle.
80e5949 to
6d6de67
Compare
Signed-off-by: stianst <[email protected]>
6d6de67 to
abdc736
Compare
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - id: integration-test-setup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can omit the id if you are not referencing it anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, just copy/paste from elsewhere though. Having id/name makes the run a bit more readable though as the output with reusable actions is not very elegant without it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'd just add a human readable name to it and call it a day
| public class NoAdminUserKeycloakTestServerConfig implements KeycloakTestServerConfig { | ||
|
|
||
| @Override | ||
| public Optional<String> adminUserName() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a fan of my optionals? 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They have their place, but found it easier to not have it in this case, as it's both simpler to just return null, and found the checks when setting the values simpler without optional stuff ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it's a matter of personal preference I guess. However using optionals forces you to handle nullability, whereas nulls do not. Also:
serverConfig.adminUserName().ifPresentOrElse(
username -> System.setProperty("keycloakAdmin", username),
() -> System.getProperties().remove("keycloakAdmin")
);| return getValue(registry, annotation); | ||
| T getValue(InstanceContext<T, S> instanceContext); | ||
|
|
||
| default LifeCycle getLifeCycle(S annotation) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd do:
if (annotation == null) {
return getDefaultLifecycle();
}
// The restThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think it matters too much - down to personal preference I guess ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh for sure, you know how much I hate nesting, this is just a prime example of an early return pattern.
Signed-off-by: stianst <[email protected]>
Signed-off-by: stianst [email protected]