Unverified Commit da70bee9 authored by Daniel Bluhm's avatar Daniel Bluhm Committed by GitHub

Merge pull request #467 from dbluhm/move-test-util

Rename org.eclipse.ice.tests to org.eclipse.ice.tests.util
parents ebdc5521 3bb6d6de
......@@ -16,6 +16,7 @@
</properties>
<modules>
<module>../org.eclipse.ice.tests.util</module>
<module>../org.eclipse.ice.data</module>
<module>../org.eclipse.ice.dev</module>
<module>../org.eclipse.ice.archetypes</module>
......
......@@ -21,7 +21,7 @@ $ mvn clean verify
In both cases one can skip the tests by including `-DskipTests` in your build.
### Dependencies
All dependencies are noted in the `pom` file, and all but one are within maven central. The only non-centralized dependency is the ICE package `org.eclipse.ice.tests.data`. To install it, perform the following commands (after cloning the ICE repositiory) so that the Commands package can build successfully:
All dependencies are noted in the `pom` file, and all but one are within maven central. The only non-centralized dependency is the ICE package `org.eclipse.ice.tests.util.data`. To install it, perform the following commands (after cloning the ICE repositiory) so that the Commands package can build successfully:
```shell
$ cd org.eclipse.ice.data
......
......@@ -22,14 +22,14 @@
</dependency>
<dependency>
<groupId>org.eclipse.ice</groupId>
<artifactId>org.eclipse.ice.tests.data</artifactId>
<artifactId>org.eclipse.ice.tests.util.data</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependency>
<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId>
......@@ -51,4 +51,4 @@
<version>4.5.10</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
</project>
......@@ -4,7 +4,7 @@ This README serves as additional information for setting up the more complicated
### Dependencies
All dependencies are noted in the `pom` file, and all but one are within maven central. The only non-centralized dependency is the ICE package `org.eclipse.ice.tests.data`. To install it, perform the following commands (after cloning the ICE repositiory) so that the Commands package can build successfully:
All dependencies are noted in the `pom` file, and all but one are within maven central. The only non-centralized dependency is the ICE package `org.eclipse.ice.tests.util.data`. To install it, perform the following commands (after cloning the ICE repositiory) so that the Commands package can build successfully:
```shell
$ cd org.eclipse.ice.tests
......@@ -20,7 +20,7 @@ password
hostname
```
See the README in `org.eclipse.ice.tests/org.eclipse.ice.tests.data` for information regarding the `$TEST_DATA_PATH` environment variable; [this link](https://github.com/dbluhm/ice/blob/next/org.eclipse.ice.tests/org.eclipse.ice.tests.data/README.md) takes you to the README on the `next` branch.
See the README in `org.eclipse.ice.tests/org.eclipse.ice.tests.util.data` for information regarding the `$TEST_DATA_PATH` environment variable; [this link](https://github.com/dbluhm/ice/blob/next/org.eclipse.ice.tests/org.eclipse.ice.tests.util.data/README.md) takes you to the README on the `next` branch.
The automated tests will then grab the necessary credentials from this file to run. Any valid ssh connection will work. If you still find that the tests fail, ensure that the ssh connection you are using has been logged into before from your host computer such that there is a key fingerprint associated to that host in your `~/.ssh/known_hosts` file. The Commands package requires that this key exists in order for authentication to proceed, no matter what form of authentication you use. In the event that tests fail on a host that already exists in `known_hosts` (e.g. with the error message `server key did not validate`, try deleting your `known_hosts` file (or the entries in your `known_hosts` that correspond to the host you are trying to run the tests on), logging in again to re-establish a fingerprint, and running the tests again.
......
......@@ -38,7 +38,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.ice</groupId>
<artifactId>org.eclipse.ice.tests.data</artifactId>
<artifactId>org.eclipse.ice.tests.util.data</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
......
......@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Initial API and implementation and/or initial documentation -
* Initial API and implementation and/or initial documentation -
* Jay Jay Billings, Joe Osborn
*******************************************************************************/
package org.eclipse.ice.tests.commands;
......@@ -36,7 +36,7 @@ import org.eclipse.ice.commands.LocalFileHandler;
import org.eclipse.ice.commands.RemoteCommand;
import org.eclipse.ice.commands.RemoteFileHandler;
import org.eclipse.ice.commands.TxtFileConnectionAuthorizationHandler;
import org.eclipse.ice.tests.data.TestDataPath;
import org.eclipse.ice.tests.util.data.TestDataPath;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
......@@ -45,7 +45,7 @@ import org.junit.Test;
/**
* This class tests {@link org.eclipse.ice.commands.CommandFactory}.
*
*
* @author Jay Jay Billings, Joe Osborn
*
*/
......@@ -76,7 +76,7 @@ public class CommandFactoryTest {
* A TDP for collecting configuration files to run tests
*/
private TestDataPath dataPath = new TestDataPath();
/**
* Default constructor
*/
......@@ -85,7 +85,7 @@ public class CommandFactoryTest {
/**
* Close the connections after we are finished with them in an individual test
*
*
* @throws Exception
*/
@After
......@@ -96,7 +96,7 @@ public class CommandFactoryTest {
/**
* Set no strict host key checking just for tests
*
*
* @throws Exception
*/
@BeforeClass
......@@ -107,7 +107,7 @@ public class CommandFactoryTest {
* Run after the tests have finished processing. This function just removes the
* dummy text files that are created with log/error information from running
* various commands tests.
*
*
* @throws IOException
* @throws InterruptedException
*/
......@@ -153,7 +153,7 @@ public class CommandFactoryTest {
/**
* This function tests a multi-hop remote command, where the command logs into a
* remote host and then executes on a different remote host.
* remote host and then executes on a different remote host.
*/
@Test
@Ignore // ignore until second host is setup
......@@ -179,7 +179,7 @@ public class CommandFactoryTest {
// This is the connection where the job will be executed
// Get a factory which determines the type of authorization
ConnectionAuthorizationHandlerFactory authFactory = new ConnectionAuthorizationHandlerFactory();
// Request a ConnectionAuthorization of type text file which contains the
// credentials
String keyPath = dataPath.resolve("commands/somekey").toString();
......@@ -188,7 +188,7 @@ public class CommandFactoryTest {
keyPath);
auth.setHostname("hostname");
auth.setUsername("password");
// Set it
ConnectionConfiguration firstConn = new ConnectionConfiguration();
firstConn.setAuthorization(auth);
......@@ -199,9 +199,9 @@ public class CommandFactoryTest {
firstConn.deleteWorkingDirectory(false);
ConnectionConfiguration secondConn = new ConnectionConfiguration();
String credFile = dataPath.resolve("commands/ice-remote-creds.txt").toString();
String credFile = dataPath.resolve("commands/ice-remote-creds.txt").toString();
ConnectionAuthorizationHandler intermAuth = authFactory.getConnectionAuthorizationHandler("text",credFile);
secondConn.setAuthorization(intermAuth);
secondConn.setName("executeConnection");
......@@ -667,7 +667,7 @@ public class CommandFactoryTest {
/**
* This function sets up and returns a default case of a command configuration
* for use throughout the tests.
*
*
* @return
*/
private CommandConfiguration setupDefaultCommandConfig() {
......@@ -683,7 +683,7 @@ public class CommandFactoryTest {
/**
* A helper function to return the dummy connection configuration for remote
* testing
*
*
* @return - dummy connection configuration
*/
private ConnectionConfiguration setupDummyConnectionConfiguration() {
......@@ -691,7 +691,7 @@ public class CommandFactoryTest {
ConnectionConfiguration cfg = new ConnectionConfiguration();
// Make the connection configuration
// Get a factory which determines the type of authorization
ConnectionAuthorizationHandlerFactory authFactory = new ConnectionAuthorizationHandlerFactory();
// Request a ConnectionAuthorization of type text file which contains the
// credentials
......@@ -712,7 +712,7 @@ public class CommandFactoryTest {
/**
* This function just returns the local hostname of your local computer. It is
* useful for testing a variety of local commands.
*
*
* @return - String - local hostname
*/
protected static String getLocalHostname() {
......
......@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Initial API and implementation and/or initial documentation -
* Initial API and implementation and/or initial documentation -
* Jay Jay Billings, Joe Osborn
*******************************************************************************/
package org.eclipse.ice.tests.commands;
......@@ -25,14 +25,14 @@ import org.eclipse.ice.commands.EmailUpdateHandler;
import org.eclipse.ice.commands.HTTPCommandUpdateHandler;
import org.eclipse.ice.commands.ICommandUpdateHandler;
import org.eclipse.ice.commands.TxtFileConnectionAuthorizationHandler;
import org.eclipse.ice.tests.data.TestDataPath;
import org.eclipse.ice.tests.util.data.TestDataPath;
import org.junit.Test;
/**
* This class tests local commands in conjunction with a given
* ICommandUpdaterHandler class. The class is not intended to test the Command
* logic, but rather the updater logic associated with the Command.
*
*
* @author Joe Osborn
*
*/
......@@ -42,7 +42,7 @@ public class CommandFactoryUpdaterTest {
* A TDP for collecting config files
*/
private TestDataPath dataPath = new TestDataPath();
/**
* This function tests a command with an HTTPUpdater
*/
......@@ -107,7 +107,7 @@ public class CommandFactoryUpdaterTest {
/**
* Helper function to create and return a local connection configuration
*
*
* @return
*/
private ConnectionConfiguration setupConnectionConfiguration() {
......@@ -122,7 +122,7 @@ public class CommandFactoryUpdaterTest {
/**
* Helper function to setup and create a local command configuration
*
*
* @return
*/
private CommandConfiguration setupCommandConfiguration() {
......@@ -148,12 +148,12 @@ public class CommandFactoryUpdaterTest {
/**
* Sets up the dummy email address via a text file credential for CI
*
*
* @return
*/
private EmailUpdateHandler setupEmailUpdateHandler() {
// Get a text file with credentials
String credFile = dataPath.resolve("commands/ice-email-creds.txt").toString();
TxtFileConnectionAuthorizationHandler auth = new TxtFileConnectionAuthorizationHandler();
......
......@@ -30,14 +30,14 @@ import org.eclipse.ice.commands.ConnectionManagerFactory;
import org.eclipse.ice.commands.LocalCommand;
import org.eclipse.ice.commands.RemoteCommand;
import org.eclipse.ice.commands.TxtFileConnectionAuthorizationHandler;
import org.eclipse.ice.tests.data.TestDataPath;
import org.eclipse.ice.tests.util.data.TestDataPath;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* Test for class {@link org.eclipse.ice.commands.Command}.
*
*
* @author Joe Osborn
*
*/
......@@ -50,13 +50,13 @@ public class CommandTest {
private String pwd = System.getProperty("user.dir") + "/src/test/java/org/eclipse/ice/tests/commands/";
/**
* A TDP for collecting config files
*/
* A TDP for collecting config files
*/
private TestDataPath dataPath = new TestDataPath();
/**
* Remove output files after tests finish running
*
*
* @throws IOException
* @throws InterruptedException
*/
......@@ -97,7 +97,7 @@ public class CommandTest {
/**
* Set no strict host key checking just for tests
*
*
* @throws Exception
*/
@BeforeClass
......@@ -124,24 +124,24 @@ public class CommandTest {
commandConfig.setAppendInput(true); // append the input file name to the script executable command
commandConfig.setNumProcs("1"); // number of processes is 1
commandConfig.setOS(System.getProperty("os.name"));
// Set the remote working directory, where the command will be processed
commandConfig.setRemoteWorkingDirectory("/tmp/remoteCommandTestDirectory");
// Set the connection configuration to a dummy remote connection
// Make the ConnectionConfiguration and set it up
ConnectionConfiguration connectConfig = new ConnectionConfiguration();
// Make the connection configuration
// Get a factory which determines the type of authorization
ConnectionAuthorizationHandlerFactory authFactory = new ConnectionAuthorizationHandlerFactory();
// Request a ConnectionAuthorization of type text file which contains the
// credentials
String credFile = dataPath.resolve("commands/ice-remote-creds.txt").toString();
ConnectionAuthorizationHandler auth = authFactory.getConnectionAuthorizationHandler("text", credFile);
// Set it
connectConfig.setAuthorization(auth);
connectConfig.setName("dummyConnection");
......@@ -169,21 +169,21 @@ public class CommandTest {
public void testLocalCommand() {
System.out.println("\n\n\n\nTest a local command!");
String os = System.getProperty("os.name");
// Set the CommandConfiguration class
// See {@link org.eclipse.ice.commands.CommandConfiguration} for detailed info
// on each
CommandConfiguration commandConfig = new CommandConfiguration();
commandConfig.setCommandId(1);
commandConfig.setExecutable("./test_code_execution.sh");
// If the os is windows, set the executable appropriately
if (os.toLowerCase().contains("win")) {
// two slashes so that java doesn't read it as a tab
commandConfig.setExecutable(".\\test_code_execution.ps1");
commandConfig.setInterpreter("powershell.exe");
}
commandConfig.addInputFile("someInputFile", "someInputFile.txt");
commandConfig.setErrFileName("someLocalErrFile.txt");
commandConfig.setOutFileName("someLocalOutFile.txt");
......@@ -238,11 +238,11 @@ public class CommandTest {
// Make the ConnectionConfiguration and set it up
ConnectionConfiguration connectConfig = new ConnectionConfiguration();
// Make the connection configuration
// Get a factory which determines the type of authorization
ConnectionAuthorizationHandlerFactory authFactory = new ConnectionAuthorizationHandlerFactory();
// Request a ConnectionAuthorization of type text file which contains the
// credentials
String credFile = dataPath.resolve("commands/ice-remote-creds.txt").toString();
......@@ -305,11 +305,11 @@ public class CommandTest {
public void testArgumentCommand() {
// Make the ConnectionConfiguration and set it up
ConnectionConfiguration connectConfig = new ConnectionConfiguration();
// Make the connection configuration
// Get a factory which determines the type of authorization
ConnectionAuthorizationHandlerFactory authFactory = new ConnectionAuthorizationHandlerFactory();
// Request a ConnectionAuthorization of type text file which contains the
// credentials
String credFile = dataPath.resolve("commands/ice-remote-creds.txt").toString();
......
......@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Initial API and implementation and/or initial documentation -
* Initial API and implementation and/or initial documentation -
* Jay Jay Billings, Joe Osborn
*******************************************************************************/
package org.eclipse.ice.tests.commands;
......@@ -25,13 +25,13 @@ import org.eclipse.ice.commands.ConnectionAuthorizationHandler;
import org.eclipse.ice.commands.ConnectionAuthorizationHandlerFactory;
import org.eclipse.ice.commands.ConnectionConfiguration;
import org.eclipse.ice.commands.ConnectionManagerFactory;
import org.eclipse.ice.tests.data.TestDataPath;
import org.eclipse.ice.tests.util.data.TestDataPath;
import org.junit.Test;
/**
* This class tests
* {@link org.eclipse.ice.commands.ConnectionAuthorizationHandlerFactory}
*
*
* @author Joe Osborn
*
*/
......@@ -46,7 +46,7 @@ public class ConnectionAuthorizationHandlerFactoryTest {
* A TDP for collecting config files
*/
private TestDataPath dataPath = new TestDataPath();
/**
* Tests local authorization of
* {@link org.eclipse.ice.commands.ConnectionAuthorizationHandlerFactory#getConnectionAuthorizationHandler(String)}
......@@ -71,12 +71,12 @@ public class ConnectionAuthorizationHandlerFactoryTest {
/**
* Tests text file authorization of
* {@link org.eclipse.ice.commands.ConnectionAuthorizationHandlerFactory#getConnectionAuthorizationHandler(String)}
*
*
* @throws JSchException
*/
@Test
public void testTextAuthorization() throws IOException {
String credFile = dataPath.resolve("commands/ice-remote-creds.txt").toString();
// Get a text file authorization handler
......@@ -90,15 +90,15 @@ public class ConnectionAuthorizationHandlerFactoryTest {
// delete the password since we don't need it here
Arrays.fill(pwd, Character.MIN_VALUE);
String hostname = scanner.next();
assertEquals(username, text.getUsername());
assertEquals(hostname, text.getHostname());
// Create a connection configuration to actually try and open the connection
ConnectionConfiguration config = new ConnectionConfiguration();
config.setName("Text");
config.setAuthorization(text);
// Try to open the connection
ConnectionManagerFactory.getConnectionManager().openConnection(config);
// Assert that it was correctly opened
......@@ -111,14 +111,14 @@ public class ConnectionAuthorizationHandlerFactoryTest {
/**
* Tests key path authorization of
* {@link org.eclipse.ice.commands.ConnectionAuthorizationHandlerFactory#getConnectionAuthorizationHandler(String)}
*
*
* @throws JSchException
*/
@Test
public void testKeyPathAuthorization() throws IOException {
// Filepath to the dummy host key
String keyPath = System.getProperty("user.home") + "/.ssh/dummyhostkey";
// Create a text file credential path to get the same username/hostname
// as the key, in the event someone is using a host that is not the dummy
// server
......@@ -126,7 +126,7 @@ public class ConnectionAuthorizationHandlerFactoryTest {
// Get a text file authorization handler
ConnectionAuthorizationHandler text = factory.getConnectionAuthorizationHandler("text", credFile);
// Create a connection authorization handler for a keypath
ConnectionAuthorizationHandler auth = factory.getConnectionAuthorizationHandler("keypath", keyPath);
auth.setHostname(text.getHostname());
......
......@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Initial API and implementation and/or initial documentation -
* Initial API and implementation and/or initial documentation -
* Jay Jay Billings, Joe Osborn
*******************************************************************************/
package org.eclipse.ice.tests.commands;
......@@ -27,7 +27,7 @@ import org.eclipse.ice.commands.ConnectionConfiguration;
import org.eclipse.ice.commands.ConnectionManager;
import org.eclipse.ice.commands.ConnectionManagerFactory;
import org.eclipse.ice.commands.KeyPathConnectionAuthorizationHandler;
import org.eclipse.ice.tests.data.TestDataPath;
import org.eclipse.ice.tests.util.data.TestDataPath;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
......@@ -39,7 +39,7 @@ import org.junit.Test;
* as currently implemented, the ssh connection is a dummy account set up within
* gitlab that will be used in CI for testing. The test class reads from a txt
* file the username, password, and hostname of the dummy account.
*
*
* @author Joe Osborn
*
*/
......@@ -64,10 +64,10 @@ public class ConnectionManagerTest {
* A TDP for collecting config files
*/
static TestDataPath dataPath = new TestDataPath();
/**
* This function makes a test connection with which to play with
*
*
* @throws java.lang.Exception
*/
@BeforeClass
......@@ -76,7 +76,7 @@ public class ConnectionManagerTest {
// Set up the configuration with the necessary credentials
// Get a factory which determines the type of authorization
ConnectionAuthorizationHandlerFactory authFactory = new ConnectionAuthorizationHandlerFactory();
// Request a ConnectionAuthorization of type text file which contains the
// credentials
ConnectionAuthorizationHandler auth = null;
......@@ -93,7 +93,7 @@ public class ConnectionManagerTest {
/**
* Clear out the connections formed after each test so that each test starts
* fresh with a clean slated connection manager
*
*
* @throws Exception
*/
@After
......@@ -110,7 +110,7 @@ public class ConnectionManagerTest {
/**
* This function deletes all of the connections in the connection manager once
* the tests have run and completed.
*
*
* @throws Exception
*/
@AfterClass
......@@ -129,7 +129,7 @@ public class ConnectionManagerTest {
/**
* This function tests opening a connection with an already generated key path
*
*
* @throws JSchException
*/
@Test
......@@ -298,7 +298,7 @@ public class ConnectionManagerTest {
/**
* This tests failure if the known host does not exist in the known_hosts ssh
* file
*
*
* @throws JSchException
*/
@Test(expected = IOException.class)
......@@ -316,12 +316,12 @@ public class ConnectionManagerTest {
/**