Skip to content

Commit

Permalink
JBIDE-25870 - Add CDK runtime download integration tests
Browse files Browse the repository at this point in the history
   - ITests for downloading container runtimes CDK 3.x, CDK 3.2+ and Minishift 1.14
   - Checking passing of credentials in download runtime wizard
   - Tests downloading into default folders

Signed-off-by: Ondrej Dockal <odockal@redhat.com>
  • Loading branch information
odockal committed May 18, 2018
1 parent d138b20 commit bfe1b3e
Show file tree
Hide file tree
Showing 34 changed files with 997 additions and 96 deletions.
6 changes: 3 additions & 3 deletions itests/org.jboss.tools.cdk.ui.bot.test/META-INF/MANIFEST.MF
Expand Up @@ -5,7 +5,7 @@ Bundle-SymbolicName: org.jboss.tools.cdk.ui.bot.test
Bundle-Version: 3.5.0.qualifier
Bundle-Vendor: Red Hat
Require-Bundle: org.junit,
org.eclipse.reddeer.go;bundle-version="[2.0.0,3.0.0)",
org.eclipse.reddeer.go;bundle-version="[2.1.0,3.0.0)",
org.eclipse.wst.server.core;bundle-version="1.5.0",
org.eclipse.wst.server.ui;bundle-version="1.5.200",
org.eclipse.jdt.launching;bundle-version="3.7.0",
Expand All @@ -16,7 +16,6 @@ Require-Bundle: org.junit,
org.eclipse.core.externaltools;bundle-version="1.0.300",
org.eclipse.equinox.security;bundle-version="1.2.100",
org.eclipse.debug.ui;bundle-version="3.11.0",
org.eclipse.linuxtools.docker.core;bundle-version="[4.0.0,5.0.0)",
org.eclipse.linuxtools.docker.reddeer,
org.eclipse.tm.terminal.view.core;bundle-version="4.0.0",
org.eclipse.tm.terminal.view.ui;bundle-version="4.0.0",
Expand All @@ -43,7 +42,8 @@ Require-Bundle: org.junit,
org.jboss.ide.eclipse.as.core;bundle-version="3.0.0",
org.jboss.ide.eclipse.as.wtp.core;bundle-version="3.1.1",
org.jboss.ide.eclipse.as.wtp.ui;bundle-version="3.1.1",
org.jboss.tools.common.reddeer
org.jboss.tools.common.reddeer,
org.jboss.tools.runtime.reddeer
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Eclipse-BundleShape: jar
Bundle-Localization: plugin
Expand Down
Expand Up @@ -16,6 +16,7 @@

import org.eclipse.reddeer.common.exception.RedDeerException;
import org.jboss.tools.cdk.reddeer.core.enums.CDKHypervisor;
import org.jboss.tools.cdk.reddeer.utils.CDKUtils;
import org.jboss.tools.cdk.ui.bot.test.utils.CDKTestUtils;
import org.jboss.tools.openshift.common.core.utils.StringUtils;

Expand All @@ -27,19 +28,18 @@ public abstract class CDKAbstractTest {
public static final String SERVER_ADAPTER_32 = "Container Development Environment 3.2+";
public static final String SERVER_ADAPTER_MINISHIFT = "Minishift 1.7+";

// General parameters
public static final boolean IS_WINDOWS = System.getProperty("os.name").toLowerCase().contains("win");
public static final boolean IS_LINUX = System.getProperty("os.name").toLowerCase().contains("linux");
public static final String FOLDER = IS_LINUX ? "linux" : (IS_WINDOWS ? "win" : "mac");
// General parameters
public static final String FOLDER = CDKUtils.IS_LINUX ? "linux" : (CDKUtils.IS_WINDOWS ? "win" : "mac");
public static final String separator = System.getProperty("file.separator");
public static final String MINISHIFT_CONFIG_MINIMAL = " --disk-size 5GB --memory 2GB --cpus 1";
public static final String SKIP_REGISTRATION = "--skip-registration";
public static final String RUNTIMES_DIRECTORY= System.getProperty("user.dir") + separator + "runtimes";

// mock files
protected static final String MOCK_CDK320 = getProjectAbsolutePath("resources/cdk-files/" + FOLDER + "/cdk-3.2.0-mock" + (IS_WINDOWS ? ".bat" : ""));
protected static final String MOCK_CDK311 = getProjectAbsolutePath("resources/cdk-files/" + FOLDER + "/cdk-3.1.1-mock" + (IS_WINDOWS ? ".bat" : ""));
protected static final String MOCK_MINISHIFT131 = getProjectAbsolutePath("resources/cdk-files/" + FOLDER + "/minishift-1.3.1-mock" + (IS_WINDOWS ? ".bat" : ""));
protected static final String MOCK_MINISHIFT170 = getProjectAbsolutePath("resources/cdk-files/" + FOLDER + "/minishift-1.7.0-mock" + (IS_WINDOWS ? ".bat" : ""));
protected static final String MOCK_CDK320 = getProjectAbsolutePath("resources/cdk-files/" + FOLDER + "/cdk-3.2.0-mock" + (CDKUtils.IS_WINDOWS ? ".bat" : ""));
protected static final String MOCK_CDK311 = getProjectAbsolutePath("resources/cdk-files/" + FOLDER + "/cdk-3.1.1-mock" + (CDKUtils.IS_WINDOWS ? ".bat" : ""));
protected static final String MOCK_MINISHIFT131 = getProjectAbsolutePath("resources/cdk-files/" + FOLDER + "/minishift-1.3.1-mock" + (CDKUtils.IS_WINDOWS ? ".bat" : ""));
protected static final String MOCK_MINISHIFT170 = getProjectAbsolutePath("resources/cdk-files/" + FOLDER + "/minishift-1.7.0-mock" + (CDKUtils.IS_WINDOWS ? ".bat" : ""));

// CDK Test suite parameters
public static final String MINISHIFT_PROFILE = "minishift";
Expand All @@ -58,7 +58,7 @@ public abstract class CDKAbstractTest {
CDK_MINISHIFT = CDKTestUtils.getSystemProperty("cdk.minishift");
CDK32_MINISHIFT = CDKTestUtils.getSystemProperty("cdk32.minishift");
MINISHIFT_HYPERVISOR = CDKTestUtils.getSystemProperty("hypervisor");
DEFAULT_MINISHIFT_HOME = System.getProperty("user.home") + separator + ".minishift";
DEFAULT_MINISHIFT_HOME = System.getProperty("user.home") + separator + ".minishift";
}

public static String assignMinishiftHypervisor() {
Expand Down
Expand Up @@ -25,6 +25,11 @@
import org.jboss.tools.cdk.ui.bot.test.server.wizard.CDK32ServerWizardTest;
import org.jboss.tools.cdk.ui.bot.test.server.wizard.CDK3ServerWizardTest;
import org.jboss.tools.cdk.ui.bot.test.server.wizard.MinishiftServerWizardTest;
import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.CDK32DownloadRuntimeTest;
import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.CDK3DownloadRuntimeTest;
import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.DownloadContainerRuntimeDefaultSettingsTest;
import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.DownloadRuntimesWizardTest;
import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.MinishiftDownloadRuntimeTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;

Expand All @@ -38,6 +43,13 @@
CDK32ServerWizardTest.class,
MinishiftServerWizardTest.class,

// Downloading and installation of CDK/Minishift runtimes via new server wizard
CDK3DownloadRuntimeTest.class,
CDK32DownloadRuntimeTest.class,
MinishiftDownloadRuntimeTest.class,
DownloadContainerRuntimeDefaultSettingsTest.class,
DownloadRuntimesWizardTest.class,

// Server editor tests by server adapter type
CDK3ServerEditorTest.class,
CDK32ServerEditorTest.class,
Expand Down
Expand Up @@ -12,6 +12,7 @@

import org.eclipse.reddeer.junit.runner.RedDeerSuite;
import org.jboss.tools.cdk.ui.bot.test.server.adapter.CDK32IntegrationTest;
import org.jboss.tools.cdk.ui.bot.test.server.adapter.CDK32ServerAdapterProfilesTest;
import org.jboss.tools.cdk.ui.bot.test.server.adapter.openshift.CDKImageRegistryUrlDiscoveryTest;
import org.jboss.tools.cdk.ui.bot.test.server.editor.CDK32ServerEditorTest;
import org.jboss.tools.cdk.ui.bot.test.server.editor.CDK3ServerEditorTest;
Expand All @@ -20,6 +21,9 @@
import org.jboss.tools.cdk.ui.bot.test.server.wizard.CDK32ServerWizardTest;
import org.jboss.tools.cdk.ui.bot.test.server.wizard.CDK3ServerWizardTest;
import org.jboss.tools.cdk.ui.bot.test.server.wizard.MinishiftServerWizardTest;
import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.CDK32DownloadRuntimeTest;
import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.DownloadRuntimesWizardTest;
import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.MinishiftDownloadRuntimeTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;

Expand All @@ -28,12 +32,16 @@
CDK3ServerWizardTest.class,
CDK32ServerWizardTest.class,
MinishiftServerWizardTest.class,
CDK32DownloadRuntimeTest.class,
MinishiftDownloadRuntimeTest.class,
DownloadRuntimesWizardTest.class,
CDK3ServerEditorTest.class,
CDK32ServerEditorTest.class,
MinishiftServerEditorTest.class,
CDKLaunchConfigurationTest.class,
CDKImageRegistryUrlDiscoveryTest.class,
CDK32IntegrationTest.class
CDK32IntegrationTest.class,
CDK32ServerAdapterProfilesTest.class
})
/**
* @author ondrej dockal
Expand Down
@@ -0,0 +1,62 @@
/*******************************************************************************
* Copyright (c) 2018 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 org.eclipse.reddeer.junit.runner.RedDeerSuite;
import org.jboss.tools.cdk.ui.bot.test.server.adapter.CDKServerAdapterSetupCDKTest;
import org.jboss.tools.cdk.ui.bot.test.server.editor.CDK32ServerEditorTest;
import org.jboss.tools.cdk.ui.bot.test.server.editor.CDK3ServerEditorTest;
import org.jboss.tools.cdk.ui.bot.test.server.editor.MinishiftServerEditorTest;
import org.jboss.tools.cdk.ui.bot.test.server.editor.launch.CDKLaunchConfigurationTest;
import org.jboss.tools.cdk.ui.bot.test.server.wizard.CDK32ServerWizardTest;
import org.jboss.tools.cdk.ui.bot.test.server.wizard.CDK3ServerWizardTest;
import org.jboss.tools.cdk.ui.bot.test.server.wizard.MinishiftServerWizardTest;
import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.CDK32DownloadRuntimeTest;
import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.CDK3DownloadRuntimeTest;
import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.DownloadContainerRuntimeDefaultSettingsTest;
import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.DownloadRuntimesWizardTest;
import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.MinishiftDownloadRuntimeTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;

@RunWith(RedDeerSuite.class)
@Suite.SuiteClasses({

// UI integration tests

// Wizard tests by server adapter type
CDK3ServerWizardTest.class,
CDK32ServerWizardTest.class,
MinishiftServerWizardTest.class,

// Downloading and installation of CDK/Minishift runtimes via new server wizard
CDK3DownloadRuntimeTest.class,
CDK32DownloadRuntimeTest.class,
MinishiftDownloadRuntimeTest.class,
DownloadContainerRuntimeDefaultSettingsTest.class,
DownloadRuntimesWizardTest.class,

// Server editor tests by server adapter type
CDK3ServerEditorTest.class,
CDK32ServerEditorTest.class,
MinishiftServerEditorTest.class,
CDKLaunchConfigurationTest.class,

// Setup CDK context menu item tests
CDKServerAdapterSetupCDKTest.class,
})
/**
*
* @author odockal
*
*/
public class CDKUITestsSuite {
}
Expand Up @@ -15,6 +15,7 @@
import org.jboss.tools.cdk.ui.bot.test.server.adapter.MinishiftServerAdapterTest;
import org.jboss.tools.cdk.ui.bot.test.server.editor.MinishiftServerEditorTest;
import org.jboss.tools.cdk.ui.bot.test.server.wizard.MinishiftServerWizardTest;
import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.MinishiftDownloadRuntimeTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;

Expand All @@ -23,6 +24,7 @@
MinishiftServerWizardTest.class,
MinishiftServerEditorTest.class,
MinishiftServerAdapterTest.class,
MinishiftDownloadRuntimeTest.class,
MinishiftServerAdapterProfilesTest.class
})
public class MinishiftAllTestsSuite {
Expand Down
Expand Up @@ -87,14 +87,14 @@ public void setupSecondAdapter() {
@Test
public void testCDK32ServerAdapterWithMultipleProfiles() {
// fisrt adapter start verification
startServerAdapter(() -> { skipRegistration(getCDKServer());}, false);
startServerAdapter(() -> { skipRegistrationViaFlag(getCDKServer(), true);}, false);
int conCount = view.getOpenShift3Connections().size();
int docCount = getDockerConnectionCreatedByCDK(dockerView, DOCKER_DAEMON_CONNECTION).size();
assertEquals("Expected only one OS connection, got " + conCount, 1, conCount);
assertEquals("Expected only one Docker connection, got " + docCount, 1, docCount);
// second adapter start verification
startServerAdapter(getSecondCDKServer(),
() -> { skipRegistration(getSecondCDKServer());
() -> { skipRegistrationViaFlag(getSecondCDKServer(), true);
}, false);
// check counts of connections
conCount = view.getOpenShift3Connections().size();
Expand Down
Expand Up @@ -43,7 +43,7 @@ public static void setup() {
@Test
public void testCDK3ServerAdapter() {
// cdk start verification
startServerAdapter(() -> skipRegistration(getCDKServer()), true);
startServerAdapter(() -> skipRegistrationViaFlag(getCDKServer(), true), true);
// OS3 and docker connection created verification
testOpenshiftConnection(null, OPENSHIFT_USERNAME);
testDockerConnection(DOCKER_DAEMON_CONNECTION);
Expand Down
Expand Up @@ -53,6 +53,7 @@
import org.jboss.tools.cdk.reddeer.server.exception.CDKServerException;
import org.jboss.tools.cdk.reddeer.server.ui.CDKServer;
import org.jboss.tools.cdk.reddeer.server.ui.CDKServersView;
import org.jboss.tools.cdk.reddeer.server.ui.editor.CDK32ServerEditor;
import org.jboss.tools.cdk.reddeer.server.ui.editor.CDK3ServerEditor;
import org.jboss.tools.cdk.reddeer.server.ui.editor.MinishiftServerEditor;
import org.jboss.tools.cdk.reddeer.server.ui.editor.launch.configuration.CDKLaunchConfigurationDialog;
Expand Down Expand Up @@ -181,6 +182,16 @@ protected void addParamsToCDKLaunchConfig(Server server, String paramsToAdd) {
launchConfig.ok();
}

protected void skipRegistrationViaFlag(Server server, boolean checked) {
server.open();
CDK32ServerEditor editor = new CDK32ServerEditor(server.getLabel().getName());
editor.getAddSkipRegistrationOnStartCheckBox().toggle(checked);
new WaitUntil(new SystemJobIsRunning(new JobMatcher(CDKLabel.Job.MINISHIFT_VALIDATION_JOB)), TimePeriod.SHORT, false);
new WaitWhile(new SystemJobIsRunning(new JobMatcher(CDKLabel.Job.MINISHIFT_VALIDATION_JOB)), TimePeriod.DEFAULT, false);
CDKTestUtils.performSave(editor.getEditorPart());
editor.close();
}

protected void skipRegistration(Server server) {
addParamsToCDKLaunchConfig(server, SKIP_REGISTRATION);
}
Expand Down
Expand Up @@ -87,15 +87,14 @@ public void setupSecondAdapter() {
@Test
public void testMinishiftServerAdapterWithMultipleProfiles() {
// fisrt adapter start verification
startServerAdapter(() -> { skipRegistration(getCDKServer());}, false);
startServerAdapter(() -> {}, false);
int conCount = view.getOpenShift3Connections().size();
int docCount = getDockerConnectionCreatedByCDK(dockerView, DOCKER_DAEMON_CONNECTION).size();
assertEquals("Expected only one OS connection, got " + conCount, 1, conCount);
assertEquals("Expected only one Docker connection, got " + docCount, 1, docCount);
// second adapter start verification
startServerAdapter(getSecondCDKServer(),
() -> { skipRegistration(getCDKServer());
}, false);
() -> {}, false);
// check counts of connections
conCount = view.getOpenShift3Connections().size();
docCount = getDockerConnectionCreatedByCDK(dockerView, DOCKER_DAEMON_CONNECTION).size();
Expand Down
Expand Up @@ -69,7 +69,7 @@ public static void tearDownCDKImageResgitryUrlAbstract() {
@Before
public void setupAdapter() {
startServerAdapterIfNotRunning(() -> {
skipRegistration(getCDKServer());
skipRegistrationViaFlag(getCDKServer(), true);
}, false);
wizard = getOpenshiftConnectionWizard(findOpenShiftConnection(null, OPENSHIFT_USERNAME));
assertTrue(wizard.getAuthSection().getMethod().equals(AuthenticationMethod.BASIC));
Expand Down
Expand Up @@ -69,7 +69,7 @@ public void testImageRegistryUrlIsUpdated() {
stopServerAdapter();
// start server adapter -> should bring up the value of registry url in existing
// connection
startServerAdapter(() -> skipRegistration(getCDKServer()), false);
startServerAdapter(() -> skipRegistrationViaFlag(getCDKServer(), true), false);
wizard = getOpenshiftConnectionWizard(findOpenShiftConnection(null, OPENSHIFT_USERNAME));
switchOffPasswordSaving(wizard);
checkImageRegistryUrl(wizard, OPENSHIFT_REGISTRY);
Expand Down Expand Up @@ -101,7 +101,7 @@ public void testAllConnectionsImageRegistryUrlUpdated() {
newWizard = null;
// stop and start server adapter
stopServerAdapter();
startServerAdapter(() -> skipRegistration(getCDKServer()), false);
startServerAdapter(() -> skipRegistrationViaFlag(getCDKServer(), true), false);
// check that both connections have filled image registry url
try {
wizard = getOpenshiftConnectionWizard(findOpenShiftConnection(null, OPENSHIFT_USERNAME));
Expand Down
Expand Up @@ -13,6 +13,7 @@
import static org.junit.Assert.assertTrue;

import org.eclipse.reddeer.junit.runner.RedDeerSuite;
import org.jboss.tools.cdk.reddeer.utils.CDKUtils;
import org.jboss.tools.cdk.ui.bot.test.utils.CDKTestUtils;
import org.junit.After;
import org.junit.Test;
Expand Down Expand Up @@ -48,7 +49,7 @@ public void testSettingOCToWorkspace() {
setupOCForWorkspace();
wizard = getOpenshiftConnectionWizard(findOpenShiftConnection(null, OPENSHIFT_USERNAME));
assertStringContains(wizard.getConnectionMessage(), "OpenShift server");
assertTrue(wizard.getOCLocationLabel().getText().endsWith(IS_WINDOWS ? "oc.exe" : "oc"));
assertTrue(wizard.getOCLocationLabel().getText().endsWith(CDKUtils.IS_WINDOWS ? "oc.exe" : "oc"));
}

/**
Expand Down
Expand Up @@ -11,6 +11,8 @@
package org.jboss.tools.cdk.ui.bot.test.server.wizard;

import static org.junit.Assert.assertTrue;
import static org.jboss.tools.cdk.ui.bot.test.utils.CDKTestUtils.assertDiffMessage;
import static org.jboss.tools.cdk.ui.bot.test.utils.CDKTestUtils.assertSameMessage;

import org.eclipse.reddeer.common.wait.TimePeriod;
import org.eclipse.reddeer.common.wait.WaitUntil;
Expand Down Expand Up @@ -45,7 +47,7 @@ protected String getServerAdapter() {
}

@Test
public void testCDK3ServerType() {
public void testCDK32ServerType() {
assertServerType(CDKLabel.Server.CDK32_SERVER_NAME);
}

Expand All @@ -69,28 +71,29 @@ public void testNewCDK32ServerWizard() {
containerPage.setMinishiftBinary(EXISTING_PATH);

// first the credentials are checked
assertSameMessage(dialog, NO_USER);
assertSameMessage(dialog, CDKLabel.Messages.NO_USER);
containerPage.setCredentials(USERNAME, PASSWORD);
assertDiffMessage(dialog, NO_USER);
assertDiffMessage(dialog, CDKLabel.Messages.NO_USER);

// checking of minishift binary validation
// test that existing folder cannot be run
containerPage.setMinishiftBinary(EXISTING_PATH);
assertSameMessage(dialog, CANNOT_RUN_PROGRAM);
assertSameMessage(dialog, CDKLabel.Messages.CANNOT_RUN_PROGRAM);
containerPage.setMinishiftBinary(NON_EXECUTABLE_FILE);
assertSameMessage(dialog, NOT_EXECUTABLE);
assertSameMessage(dialog, CDKLabel.Messages.NOT_EXECUTABLE);
containerPage.setMinishiftBinary(NON_EXISTING_PATH);
assertSameMessage(dialog, DOES_NOT_EXIST);
assertSameMessage(dialog, CDKLabel.Messages.DOES_NOT_EXIST);
containerPage.setMinishiftBinary(EXECUTABLE_FILE);
assertSameMessage(dialog, CHECK_MINISHIFT_VERSION);
assertSameMessage(dialog, CDKLabel.Messages.CHECK_MINISHIFT_VERSION);

// check compatibility of cdk version with server adapter
containerPage.setMinishiftBinary(MOCK_CDK311);
assertSameMessage(dialog, NOT_COMPATIBLE);
assertSameMessage(dialog, CDKLabel.Messages.NOT_COMPATIBLE);

// Positive test of proper minishift binary
containerPage.setMinishiftBinary(CDK32_MINISHIFT);
assertDiffMessage(dialog, CHECK_MINISHIFT_VERSION);
assertDiffMessage(dialog, CDKLabel.Messages.CHECK_MINISHIFT_VERSION);
assertSameMessage(dialog, CDKLabel.Messages.SERVER_ADAPTER_REPRESENTING);
new WaitUntil(new ControlIsEnabled(new FinishButton()), TimePeriod.MEDIUM, false);
assertTrue("Expected Finish button is not enabled", dialog.isFinishEnabled());
dialog.cancel();
Expand Down

0 comments on commit bfe1b3e

Please sign in to comment.