Add K8S infrastructure for selenium tests #10384
Conversation
| } else { | ||
| throw new RuntimeException( | ||
| format("Infrastructure '%s' hasn't been supported by tests.", cheInfrastructure)); | ||
| final Infrastructure cheInfrastructure = |
There was a problem hiding this comment.
Please, restore configureInfrastructureRelatedDependencies() method and update its content according to your PR.
| } | ||
| } | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
empty line missed at the end of file
| } | ||
|
|
||
| private String getTemplateDirectory(String template) { | ||
| String templateDirectoryName; |
There was a problem hiding this comment.
Can be simplified:
private String getTemplateDirectory(String template) {
String templateDirectoryName = infrastructure.toString().toLowerCase();
if (infrastructure == k8s){
templateDirectoryName = k8s.toString().toLowerCase();
}
return format("/templates/factory/%s/%s", templateDirectoryName, template);
There was a problem hiding this comment.
Yes, it can, but case-statement is more preferable so as it's more obvious compare to if-statement, and it is more flexible
| switch (infrastructure) { | ||
| case openshift: | ||
| case k8s: | ||
| templateDirectoryName = Infrastructure.openshift.toString().toLowerCase(); |
There was a problem hiding this comment.
Is it OK that case is "k8s" but infrastructure which using is "openshift"?
There was a problem hiding this comment.
Also may be optimized like in the previous remark
There was a problem hiding this comment.
Is it OK that case "k8s" but infrastructure which using is "openshift"?
Yes - it was requirement to use openshift templates for k8s.
Also may be optimized like in the previous remark
Please take a look at the answer https://github.com/eclipse/che/pull/10384/files/a178ec69b067878bf86a824ead181e7232512185#r201723043
|
|
||
| @Singleton | ||
| public enum Infrastructure { | ||
| docker, |
There was a problem hiding this comment.
You are right that it is the constant and have to be in upper case.
But we are using Infrastructure enum to simplify injection from environment variable CHE_INFRASTRUCTURE like the follow:
@Inject
@Named("che.infrastructure")
private Infrastructure infrastructure;
Such injection is case sensitive, and CHE_INFRASTRUCTURE uses lower-case values like docker, openshift etc.
There was a problem hiding this comment.
I've asked about values of the enum, not about the name of enum itself.
There was a problem hiding this comment.
We can transform the value of CHE_INFRASTRUCTURE variable to upper case in time of configuring CheSeleniumSuiteModule to make it possible to inject upper case values: Infrastructure.DOCKER, Infrastructure.OPENSHIFT etc.
There was a problem hiding this comment.
Not sure what do you mean. But lowercase enum values looks weird.
| package org.eclipse.che.selenium.core.constant; | ||
|
|
||
| import com.google.inject.Singleton; | ||
|
|
| docker, | ||
| openshift, | ||
| k8s, | ||
| supershift |
There was a problem hiding this comment.
supershift is redundant here
There was a problem hiding this comment.
I like an idea of supporting supershift in Che 😄
| switch (infrastructure) { | ||
| case openshift: | ||
| case k8s: | ||
| templateDirectoryName = Infrastructure.k8s.toString().toLowerCase(); |
There was a problem hiding this comment.
Did you mean Infrastructure.openshift.toString().toLowerCase() here?
|
|
||
| case docker: | ||
| default: | ||
| templateDirectoryName = infrastructure.toString().toLowerCase(); |
There was a problem hiding this comment.
Did you mean Infrastructure.docker.toString().toLowerCase() here?
Signed-off-by: Dmytro Nochevnov <dnochevnov@codenvy.com>
|
ci-test |
|
ci-test build report: |
Signed-off-by: Dmytro Nochevnov <dnochevnov@codenvy.com>
What does this PR do?
What issues does this PR fix or reference?
#9768