Skip to content

Commit

Permalink
Tests extended to using CDKv3 server adapter (#1792)
Browse files Browse the repository at this point in the history
  • Loading branch information
odockal authored and rhopp committed Apr 21, 2017
1 parent d70044f commit f02d868
Show file tree
Hide file tree
Showing 7 changed files with 531 additions and 171 deletions.
Expand Up @@ -33,7 +33,7 @@
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -pluginCustomization ${project_loc:org.jboss.tools.cdk.ui.bot.test}/../pluginCustomization.ini"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.jboss.tools.cdk.ui.bot.test"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dusage_reporting_enabled=false -Ddevelopers.username=${string_prompt:Username} -Ddevelopers.password=${string_prompt:Password} -Dvagrantfile.path=${string_prompt:&quot;Vagrantfile path&quot;}"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dusage_reporting_enabled=false -Ddevelopers.username=${string_prompt:Username} -Ddevelopers.password=${string_prompt:Password} -Dvagrantfile.path=${string_prompt:&quot;Vagrantfile path&quot;} -Dminishift.path=${string_prompt:&quot;Minishift binary&quot;} -Dhypervisor=${string_prompt:Hypervisor}"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="com.jboss.devstudio.core.product"/>
<stringAttribute key="rd.launch.property.rd.captureScreenshot" value="true"/>
Expand Down
4 changes: 3 additions & 1 deletion tests/org.jboss.tools.cdk.ui.bot.test/pom.xml
Expand Up @@ -14,9 +14,11 @@
<packaging>eclipse-test-plugin</packaging>
<properties>
<maven.test.failure.ignore>true</maven.test.failure.ignore>
<systemProperties>${integrationTestsSystemProperties} -Dvagrantfile.path=${vagrantfile.path} -Ddevelopers.username=${developers.username} -Ddevelopers.password=${developers.password}</systemProperties>
<systemProperties>${integrationTestsSystemProperties} -Dvagrantfile.path=${vagrantfile.path} -Ddevelopers.username=${developers.username} -Ddevelopers.password=${developers.password} -Dminishift.path=${minishift.path} -Dminishift.hypervisor=${minishift.hypervisor}</systemProperties>
<developers.username></developers.username>
<vagrantfile.path></vagrantfile.path>
<minishift.path></minishift.path>
<minishift.hypervisor></minishift.hypervisor>
</properties>

<profiles>
Expand Down
@@ -0,0 +1,245 @@
/*******************************************************************************
* Copyright (c) 2017 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is 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.jboss.tools.cdk.ui.bot.test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.jboss.reddeer.common.exception.RedDeerException;
import org.jboss.reddeer.common.exception.WaitTimeoutExpiredException;
import org.jboss.reddeer.common.logging.Logger;
import org.jboss.reddeer.common.wait.TimePeriod;
import org.jboss.reddeer.common.wait.WaitUntil;
import org.jboss.reddeer.common.wait.WaitWhile;
import org.jboss.reddeer.core.condition.JobIsRunning;
import org.jboss.reddeer.core.condition.ShellWithTextIsAvailable;
import org.jboss.reddeer.eclipse.exception.EclipseLayerException;
import org.jboss.reddeer.eclipse.wst.server.ui.view.Server;
import org.jboss.reddeer.eclipse.wst.server.ui.view.ServersView;
import org.jboss.reddeer.eclipse.wst.server.ui.view.ServersViewEnums.ServerState;
import org.jboss.reddeer.eclipse.wst.server.ui.wizard.NewServerWizardDialog;
import org.jboss.reddeer.eclipse.wst.server.ui.wizard.NewServerWizardPage;
import org.jboss.reddeer.jface.exception.JFaceLayerException;
import org.jboss.reddeer.jface.viewer.handler.TreeViewerHandler;
import org.jboss.reddeer.junit.runner.RedDeerSuite;
import org.jboss.reddeer.swt.condition.WidgetIsEnabled;
import org.jboss.reddeer.swt.impl.button.FinishButton;
import org.jboss.tools.cdk.reddeer.requirements.DisableSecureStorageRequirement.DisableSecureStorage;
import org.jboss.tools.cdk.reddeer.ui.CDEServer;
import org.jboss.tools.cdk.reddeer.ui.wizard.NewCDK3ServerContainerWizardPage;
import org.jboss.tools.docker.reddeer.ui.DockerExplorerView;
import org.jboss.tools.docker.reddeer.ui.resources.DockerConnection;
import org.jboss.tools.openshift.reddeer.view.OpenShiftExplorerView;
import org.jboss.tools.openshift.reddeer.view.resources.OpenShift3Connection;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
* Testing CDK3 server adapter with minishift using vm driver passed via system property
* @author odockal
*
*/
@RunWith(RedDeerSuite.class)
@DisableSecureStorage
public class CDK3DevstudioIntegrationTest extends CDKDevstudioAbstractTest {

private static final String SERVER_NAME = "Red Hat Container Development Kit 3 (Tech Preview)"; //$NON-NLS-1$

private static final String SERVER_ADAPTER = "Container Development Environment 3"; //$NON-NLS-1$

private static final String SERVER_TYPE = "Red Hat JBoss Middleware"; //$NON-NLS-1$

private static final String SERVER_HOST = "localhost"; //$NON-NLS-1$

private static final String OPENSHIFT_USER_NAME = "developer"; //$NON-NLS-1$

private static final String OPENSHIFT_PROJECT_NAME = "My Project"; //$NON-NLS-1$

private static final String DOCKER_DAEMON_CONNECTION = SERVER_ADAPTER;

private static final String MINISHIFT_HYPERVISOR;

private static final String MINISHIFT_PATH;

private static Logger log = Logger.getLogger(CDK3DevstudioIntegrationTest.class);

private TreeViewerHandler treeViewerHandler = TreeViewerHandler.getInstance();

static {
MINISHIFT_PATH = getSystemProperty("minishift.path"); //$NON-NLS-1$
MINISHIFT_HYPERVISOR = getSystemProperty("hypervisor"); //$NON-NLS-1$
}

private static void checkMinishiftParams() {
if (MINISHIFT_PATH == null) {
throw new RedDeerException("Minishift binary path was not specified"); //$NON-NLS-1$
}
log.info("Minishift binary file is " + MINISHIFT_PATH); //$NON-NLS-1$
if (MINISHIFT_HYPERVISOR == null) {
log.info("Default hypervisor will be set"); //$NON-NLS-1$
} else {
log.info(MINISHIFT_HYPERVISOR + " is set as hypervisor"); //$NON-NLS-1$
}
}

@Override
protected Server getCDEServer() {
return this.server;
}

@Override
protected ServersView getServersView() {
return this.serversView;
}

@Override
protected void setServersView(ServersView view) {
this.serversView = view;
}

@Override
protected void setCDEServer(Server server) {
this.server = (CDEServer)server;

}

@Override
protected String getServerAdapter() {
return SERVER_ADAPTER;
}

@BeforeClass
public static void setup() {
checkMinishiftParams();
log.info("Adding new Container Development Environment server adapter"); //$NON-NLS-1$
addNewCDEServer();
}

private static void addNewCDEServer() {
// call new server dialog from servers view
ServersView view = new ServersView();
view.open();
NewServerWizardDialog dialog = view.newServer();
NewServerWizardPage page = new NewServerWizardPage();

new WaitWhile(new JobIsRunning(), TimePeriod.NORMAL, false);
// set first dialog page
page.selectType(SERVER_TYPE, SERVER_NAME);
page.setHostName(SERVER_HOST);
page.setName(SERVER_ADAPTER);
dialog.next();

// set second new server dialog page
NewCDK3ServerContainerWizardPage containerPage = new NewCDK3ServerContainerWizardPage();
log.info("Setting credentials"); //$NON-NLS-1$
containerPage.setCredentials(USERNAME, PASSWORD);
if (MINISHIFT_HYPERVISOR != null && !MINISHIFT_HYPERVISOR.isEmpty()) {
log.info("Setting hypervisor"); //$NON-NLS-1$
containerPage.setHypevisor(MINISHIFT_HYPERVISOR);
}
log.info("Setting minishift binary file folder"); //$NON-NLS-1$
containerPage.setMinishiftBinary(MINISHIFT_PATH);
new WaitUntil(new WidgetIsEnabled(new FinishButton()), TimePeriod.NORMAL);
log.info("Finishing Add new server dialog"); //$NON-NLS-1$
if (!(new FinishButton().isEnabled())) {
log.error("Finish button was not enabled"); //$NON-NLS-1$
}
dialog.finish();
}

@AfterClass
public static void tearDownEnvironment() {
log.info("Deleting Container Development Environment server adapter"); //$NON-NLS-1$
ServersView servers = new ServersView();
servers.open();
try {
servers.getServer(SERVER_ADAPTER).delete(true);
} catch (EclipseLayerException exc) {
log.error(exc.getMessage());
exc.printStackTrace();
}
removeAccessRedHatCredentials();
}

@Test
public void testCDEStop() {
startServerAdapter();
getCDEServer().stop();
assertEquals(ServerState.STOPPED, getCDEServer().getLabel().getState());
}

@Test
public void testCDERestart() {
startServerAdapter();
getCDEServer().restart();
assertEquals(ServerState.STARTED, getCDEServer().getLabel().getState());
}

@Test
public void testOpenShiftConnection() {
startServerAdapter();
OpenShiftExplorerView osExplorer = new OpenShiftExplorerView();
osExplorer.open();
try {
OpenShift3Connection connection = osExplorer.getOpenShift3Connection(null, OPENSHIFT_USER_NAME);
// usually, when server adapter is not started, openshift connection after refresh should cause
// problem occurs dialog
connection.refresh();
try {
new WaitUntil(new ShellWithTextIsAvailable("Problem occurred"), TimePeriod.getCustom(30)); //$NON-NLS-1$
fail("Problem dialog occured when refreshing OpenShift connection"); //$NON-NLS-1$
} catch (WaitTimeoutExpiredException ex) {
// no dialog appeared, which is ok
log.debug("Expected WaitTimeoutExpiredException occured"); //$NON-NLS-1$
ex.printStackTrace();
}
try {
this.treeViewerHandler.getTreeItem(connection.getTreeItem(), OPENSHIFT_PROJECT_NAME);
} catch (JFaceLayerException ex) {
ex.printStackTrace();
fail("Could not find deployed sample OpenShift project"); //$NON-NLS-1$
}
} catch (RedDeerException ex) {
ex.printStackTrace();
fail("Could not open OpenShift connection for " + OPENSHIFT_USER_NAME + //$NON-NLS-1$
" ended with exception: " + ex.getMessage()); //$NON-NLS-1$
}
}

@Test
public void testDockerDaemonConnection() {
startServerAdapter();
DockerExplorerView dockerExplorer = new DockerExplorerView();
dockerExplorer.open();
DockerConnection connection = dockerExplorer.getDockerConnectionByName(DOCKER_DAEMON_CONNECTION);
if (connection == null) {
fail("Could not find Docker connection " + DOCKER_DAEMON_CONNECTION); //$NON-NLS-1$
}
connection.select();
connection.enableConnection();
connection.refresh();
new WaitWhile(new JobIsRunning(), TimePeriod.getCustom(30));
try {
assertTrue("Docker connection does not contain any images", connection.getImagesNames().size() > 0); //$NON-NLS-1$
} catch (WaitTimeoutExpiredException ex) {
ex.printStackTrace();
fail("WaitTimeoutExpiredException occurs when expanding" //$NON-NLS-1$
+ " Docker connection " + DOCKER_DAEMON_CONNECTION); //$NON-NLS-1$
} catch (JFaceLayerException jFaceExc) {
jFaceExc.printStackTrace();
fail(jFaceExc.getMessage());
}
}

}
Expand Up @@ -16,7 +16,8 @@

@RunWith(RedDeerSuite.class)
@Suite.SuiteClasses({
CDKDevstudioBaseTest.class
CDKDevstudioIntegrationTest.class,
CDK3DevstudioIntegrationTest.class
})
/**
* @author ondrej dockal
Expand Down

0 comments on commit f02d868

Please sign in to comment.