-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add K8S infrastructure for selenium tests #10384
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
Changes from all commits
5a49391
255b974
423ef77
d984183
db96bc6
3c85ee5
c69ff0a
a178ec6
06d3e57
d74b7c5
f89b554
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /* | ||
| * Copyright (c) 2012-2018 Red Hat, Inc. | ||
| * All rights reserved. This program and the accompanying materials | ||
| * are made available under the terms of the Eclipse Public License v1.0 | ||
| * which accompanies this distribution, and is available at | ||
| * http://www.eclipse.org/legal/epl-v10.html | ||
| * | ||
| * Contributors: | ||
| * Red Hat, Inc. - initial API and implementation | ||
| */ | ||
| package org.eclipse.che.selenium.core.constant; | ||
|
|
||
| import com.google.inject.Singleton; | ||
|
|
||
| /** | ||
| * Reflects values of environment variable CHE_INFRASTRUCTURE | ||
| * | ||
| * @author Dmytro Nochevnov | ||
| */ | ||
| @Singleton | ||
| public enum Infrastructure { | ||
| DOCKER, | ||
| OPENSHIFT, | ||
| K8S, | ||
| OSIO | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ | |
| import org.eclipse.che.selenium.core.SeleniumWebDriver; | ||
| import org.eclipse.che.selenium.core.client.TestFactoryServiceClient; | ||
| import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient; | ||
| import org.eclipse.che.selenium.core.constant.Infrastructure; | ||
| import org.eclipse.che.selenium.core.entrance.Entrance; | ||
| import org.eclipse.che.selenium.core.provider.TestApiEndpointUrlProvider; | ||
| import org.eclipse.che.selenium.core.provider.TestDashboardUrlProvider; | ||
|
|
@@ -60,7 +61,7 @@ public class TestFactoryInitializer { | |
|
|
||
| @Inject | ||
| @Named("che.infrastructure") | ||
| private String infrastructure; | ||
| private Infrastructure infrastructure; | ||
|
|
||
| /** | ||
| * Initialize {@link TestFactory} base upon template. | ||
|
|
@@ -69,9 +70,7 @@ public class TestFactoryInitializer { | |
| */ | ||
| public TestFactoryBuilder fromTemplate(String template) throws Exception { | ||
| String name = NameGenerator.generate("factory", 6); | ||
| InputStream resource = | ||
| TestFactory.class.getResourceAsStream( | ||
| format("/templates/factory/%s/%s", infrastructure, template)); | ||
| InputStream resource = TestFactory.class.getResourceAsStream(getTemplateDirectory(template)); | ||
| if (resource == null) { | ||
| throw new IOException(format("Factory template '%s' not found", template)); | ||
| } | ||
|
|
@@ -85,6 +84,20 @@ public TestFactoryBuilder fromTemplate(String template) throws Exception { | |
| return new TestFactoryBuilder(factoryDto); | ||
| } | ||
|
|
||
| private String getTemplateDirectory(String template) { | ||
| String templateDirectoryName; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be simplified:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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 OSIO: | ||
| templateDirectoryName = Infrastructure.OPENSHIFT.toString().toLowerCase(); | ||
| break; | ||
|
|
||
| default: | ||
| templateDirectoryName = infrastructure.toString().toLowerCase(); | ||
| } | ||
|
|
||
| return String.format("/templates/factory/%s/%s", templateDirectoryName, template); | ||
| } | ||
|
|
||
| /** Initialize {@link TestFactory} base upon url. Can't be modified. */ | ||
| public TestFactory fromUrl(String url) throws Exception { | ||
| HttpJsonRequest httpJsonRequest = | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ | |
| import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClientFactory; | ||
| import org.eclipse.che.selenium.core.configuration.SeleniumTestConfiguration; | ||
| import org.eclipse.che.selenium.core.configuration.TestConfiguration; | ||
| import org.eclipse.che.selenium.core.constant.Infrastructure; | ||
| import org.eclipse.che.selenium.core.pageobject.PageObjectsInjector; | ||
| import org.eclipse.che.selenium.core.provider.CheTestApiEndpointUrlProvider; | ||
| import org.eclipse.che.selenium.core.provider.CheTestDashboardUrlProvider; | ||
|
|
@@ -76,8 +77,6 @@ | |
| public class CheSeleniumSuiteModule extends AbstractModule { | ||
|
|
||
| public static final String AUXILIARY = "auxiliary"; | ||
| public static final String DOCKER_INFRASTRUCTURE = "docker"; | ||
| public static final String OPENSHIFT_INFRASTRUCTURE = "openshift"; | ||
|
|
||
| private static final String CHE_MULTIUSER_VARIABLE = "CHE_MULTIUSER"; | ||
| private static final String CHE_INFRASTRUCTURE_VARIABLE = "CHE_INFRASTRUCTURE"; | ||
|
|
@@ -132,19 +131,22 @@ public void configure() { | |
| } | ||
|
|
||
| private void configureInfrastructureRelatedDependencies() { | ||
| String cheInfrastructure = System.getenv(CHE_INFRASTRUCTURE_VARIABLE); | ||
| if (cheInfrastructure == null || cheInfrastructure.isEmpty()) { | ||
| throw new RuntimeException( | ||
| format( | ||
| "Che infrastructure should be defined by environment variable '%s'.", | ||
| CHE_INFRASTRUCTURE_VARIABLE)); | ||
| } else if (cheInfrastructure.equalsIgnoreCase(DOCKER_INFRASTRUCTURE)) { | ||
| install(new CheSeleniumDockerModule()); | ||
| } else if (cheInfrastructure.equalsIgnoreCase(OPENSHIFT_INFRASTRUCTURE)) { | ||
| install(new CheSeleniumOpenshiftModule()); | ||
| } else { | ||
| throw new RuntimeException( | ||
| format("Infrastructure '%s' hasn't been supported by tests.", cheInfrastructure)); | ||
| final Infrastructure cheInfrastructure = | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, restore |
||
| Infrastructure.valueOf(System.getenv(CHE_INFRASTRUCTURE_VARIABLE).toUpperCase()); | ||
| switch (cheInfrastructure) { | ||
| case OPENSHIFT: | ||
| case K8S: | ||
| case OSIO: | ||
| install(new CheSeleniumOpenshiftModule()); | ||
| break; | ||
|
|
||
| case DOCKER: | ||
| install(new CheSeleniumDockerModule()); | ||
| break; | ||
|
|
||
| default: | ||
| throw new RuntimeException( | ||
| format("Infrastructure '%s' hasn't been supported by tests.", cheInfrastructure)); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| { | ||
| "v":"4.0", | ||
| "workspace":{ | ||
| "projects":[ | ||
| { | ||
| "name":"Spring", | ||
| "attributes":{ | ||
| "languageVersion":[ | ||
| "1.6" | ||
| ], | ||
| "language":[ | ||
| "java" | ||
| ] | ||
| }, | ||
| "type":"maven", | ||
| "source":{ | ||
| "location":"https://github.com/codenvy-templates/web-spring-java-simple.git", | ||
| "type":"git", | ||
| "parameters":{ | ||
| "keepVcs":"false", | ||
| "branch":"3.1.0" | ||
| } | ||
| }, | ||
| "modules":[ | ||
|
|
||
| ], | ||
| "path":"/Spring", | ||
| "mixins":[ | ||
| "git" | ||
| ], | ||
| "problems":[ | ||
|
|
||
| ] | ||
| } | ||
| ], | ||
| "defaultEnv":"wss", | ||
| "name":"wss", | ||
| "environments":{ | ||
| "wss":{ | ||
| "machines":{ | ||
| "dev-machine":{ | ||
| "installers":[ | ||
| "org.eclipse.che.terminal", | ||
| "org.eclipse.che.ws-agent" | ||
| ], | ||
| "servers":{ | ||
|
|
||
| }, | ||
| "attributes":{ | ||
| "memoryLimitBytes":"2147483648" | ||
| } | ||
| } | ||
| }, | ||
| "recipe":{ | ||
| "content":"eclipse/ubuntu_jdk8", | ||
| "type":"dockerimage" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
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.
javadoc