Skip to content

Commit

Permalink
IssueId #404 Excluded TSM tests from the test phase
Browse files Browse the repository at this point in the history
1) Added new interface TSMTest which is used to mark unit tests which are TSM specific
2) Updated the worker’s pom so that the surefire plugin excludes TSM tests
3) Updated TivoliStorageMangerTest so that all the tests are now marked using the new interface.
  • Loading branch information
dspeed2 committed Feb 20, 2018
1 parent 699c3cc commit 3ea765a
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 121 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.datavaultplatform.test;

public interface TSMTest {
/* category marker */
}
2 changes: 2 additions & 0 deletions datavault-worker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@
<includes>
<include>**/*Test.java</include>
</includes>

<excludedGroups>org.datavaultplatform.test.TSMTest</excludedGroups>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

public class TivoliStorageManagerTest {

Expand Down Expand Up @@ -68,146 +69,151 @@ private void deleteArchive(String description, String optFilePath) throws Excep
}

@Test
@Category(org.datavaultplatform.test.TSMTest.class)
public void testStoreValidParams() {
// Progress progress = new Progress();
// File working = new File(tsmResources, "test.tar");
// String path = "/tmp";
// String retVal = null;
// try {
// // store the tar
// retVal = tsm.store(path, working, progress);
// assertNotNull("RetVal should not be null", retVal);
// // check it is now in TSM node 1
// BufferedReader reader = this.queryArchive(working, retVal, TivoliStorageManager.TSM_SERVER_NODE1_OPT);
// String line = null;
// while ( (line = reader.readLine()) != null) {
// assertFalse("Node1 attempt to store failed", line.contains("No files matching search criteria were found"));
// }
//
// reader = this.queryArchive(working, retVal, TivoliStorageManager.TSM_SERVER_NODE2_OPT);
// line = null;
// while ( (line = reader.readLine()) != null) {
// assertFalse("Node2 attempt to store failed", line.contains("No files matching search criteria were found"));
// }
//
// // delete from TSM node 1
// deleteArchive(retVal, TivoliStorageManager.TSM_SERVER_NODE1_OPT);
// deleteArchive(retVal, TivoliStorageManager.TSM_SERVER_NODE2_OPT);
// } catch (Exception e) {
// fail("Unexpected exception " + e.getMessage());
// }
Progress progress = new Progress();
File working = new File(tsmResources, "test.tar");
String path = "/tmp";
String retVal = null;
try {
// store the tar
retVal = tsm.store(path, working, progress);
assertNotNull("RetVal should not be null", retVal);
// check it is now in TSM node 1
BufferedReader reader = this.queryArchive(working, retVal, TivoliStorageManager.TSM_SERVER_NODE1_OPT);
String line = null;
while ( (line = reader.readLine()) != null) {
assertFalse("Node1 attempt to store failed", line.contains("No files matching search criteria were found"));
}

reader = this.queryArchive(working, retVal, TivoliStorageManager.TSM_SERVER_NODE2_OPT);
line = null;
while ( (line = reader.readLine()) != null) {
assertFalse("Node2 attempt to store failed", line.contains("No files matching search criteria were found"));
}

// delete from TSM node 1
deleteArchive(retVal, TivoliStorageManager.TSM_SERVER_NODE1_OPT);
deleteArchive(retVal, TivoliStorageManager.TSM_SERVER_NODE2_OPT);
} catch (Exception e) {
fail("Unexpected exception " + e.getMessage());
}
}

@Test
@Category(org.datavaultplatform.test.TSMTest.class)
public void testStoreNonExistantFile() {
// Progress progress = new Progress();
// File working = new File(tsmResources, "testx.tar");
// String path = "/tmp";
// try {
// // store the tar
// tsm.store(path, working, progress);
// // exception should be thrown by store so we should never get here
// fail("Exception should have been thrown");
// } catch (Exception e) {
// assertNotNull("Exception should not be null", e);
// assertEquals("Message not as expected", "Deposit of testx.tar using /opt/tivoli/tsm/client/ba/bin/dsm1.opt failed. ", e.getMessage());
// }
Progress progress = new Progress();
File working = new File(tsmResources, "testx.tar");
String path = "/tmp";
try {
// store the tar
tsm.store(path, working, progress);
// exception should be thrown by store so we should never get here
fail("Exception should have been thrown");
} catch (Exception e) {
assertNotNull("Exception should not be null", e);
assertEquals("Message not as expected", "Deposit of testx.tar using /opt/tivoli/tsm/client/ba/bin/dsm1.opt failed. ", e.getMessage());
}
}

@Test
@Category(org.datavaultplatform.test.TSMTest.class)
public void testRetrieveValidParams() {
// Progress progress = new Progress();
// File working = new File(tsmResources, "test.tar");
// File temp = new File(tsmResources, "test.tar.tmp");
// String path = "/tmp";
// String retVal = null;
// try {
// // store the tar
// System.out.println("Store the tar");
// retVal = tsm.store(path, working, progress);
// //File retrieved = new File("/tmp/" + retVal);
// assertNotNull("RetVal should not be null", retVal);
// // check it is now in TSM node 1
// System.out.println("check it has been archived");
// BufferedReader reader = this.queryArchive(working, retVal, TivoliStorageManager.TSM_SERVER_NODE1_OPT);
// String line = null;
// while ( (line = reader.readLine()) != null) {
// assertFalse("Node 1 attempt to store failed", line.contains("No files matching search criteria were found"));
// }
//
// reader = this.queryArchive(working, retVal, TivoliStorageManager.TSM_SERVER_NODE2_OPT);
// line = null;
// while ( (line = reader.readLine()) != null) {
// assertFalse("Node 2 attempt to store failed", line.contains("No files matching search criteria were found"));
// }
//
// // temp move the file (so we can retrieve without overwriting)
// FileUtils.moveFile(working, temp);
// assertFalse("The working file shouldn't exist", working.exists());
//
// // retrieve from TSM node 1
// System.out.println("Retrieve the tar");
// //dsmc retrieve /tmp/datavault/temp/2848@ubuntu-xenial/513c2b11-30df-4947-846b-a64309c61eb8.tar
// tsm.retrieve(path, working, progress, TivoliStorageManager.TSM_SERVER_NODE1_OPT);
//
// // check that the /tmp/"retval" dir now exists
// System.out.println("Check the retrieve archive exits");
// assertTrue("The retrieved archive doesn't exist", working.exists());
//
// // delete from TSM node 1
// System.out.println("Delete from TSM");
// deleteArchive(retVal, TivoliStorageManager.TSM_SERVER_NODE1_OPT);
//
// // delete from TSM node2
// deleteArchive(retVal, TivoliStorageManager.TSM_SERVER_NODE2_OPT);
//
// // delete the retrieved tar
// System.out.println("Delete the retrieved archive");
// Boolean deleted = working.delete();
// assertTrue("Retrieved archive not cleaned up", deleted);
//
// // move the source file back
// FileUtils.moveFile(temp, working);
// assertTrue("The working file should exist", working.exists());
// } catch (Exception e) {
// fail("Unexpected exception " + e.getMessage());
// }
Progress progress = new Progress();
File working = new File(tsmResources, "test.tar");
File temp = new File(tsmResources, "test.tar.tmp");
String path = "/tmp";
String retVal = null;
try {
// store the tar
System.out.println("Store the tar");
retVal = tsm.store(path, working, progress);
//File retrieved = new File("/tmp/" + retVal);
assertNotNull("RetVal should not be null", retVal);
// check it is now in TSM node 1
System.out.println("check it has been archived");
BufferedReader reader = this.queryArchive(working, retVal, TivoliStorageManager.TSM_SERVER_NODE1_OPT);
String line = null;
while ( (line = reader.readLine()) != null) {
assertFalse("Node 1 attempt to store failed", line.contains("No files matching search criteria were found"));
}

reader = this.queryArchive(working, retVal, TivoliStorageManager.TSM_SERVER_NODE2_OPT);
line = null;
while ( (line = reader.readLine()) != null) {
assertFalse("Node 2 attempt to store failed", line.contains("No files matching search criteria were found"));
}

// temp move the file (so we can retrieve without overwriting)
FileUtils.moveFile(working, temp);
assertFalse("The working file shouldn't exist", working.exists());

// retrieve from TSM node 1
System.out.println("Retrieve the tar");
//dsmc retrieve /tmp/datavault/temp/2848@ubuntu-xenial/513c2b11-30df-4947-846b-a64309c61eb8.tar
tsm.retrieve(path, working, progress, TivoliStorageManager.TSM_SERVER_NODE1_OPT);

// check that the /tmp/"retval" dir now exists
System.out.println("Check the retrieve archive exits");
assertTrue("The retrieved archive doesn't exist", working.exists());

// delete from TSM node 1
System.out.println("Delete from TSM");
deleteArchive(retVal, TivoliStorageManager.TSM_SERVER_NODE1_OPT);

// delete from TSM node2
deleteArchive(retVal, TivoliStorageManager.TSM_SERVER_NODE2_OPT);

// delete the retrieved tar
System.out.println("Delete the retrieved archive");
Boolean deleted = working.delete();
assertTrue("Retrieved archive not cleaned up", deleted);

// move the source file back
FileUtils.moveFile(temp, working);
assertTrue("The working file should exist", working.exists());
} catch (Exception e) {
fail("Unexpected exception " + e.getMessage());
}
}

@Test
@Category(org.datavaultplatform.test.TSMTest.class)
public void testRetrieveNonExistantFileFromNodeOne() {
// retrieve from TSM
// Progress progress = new Progress();
// File working = new File("/tmp/test.tar");
// String path = "/tmp";
//
// try {
// System.out.println("Retrieve the tar");
// //dsmc retrieve /tmp/datavault/temp/2848@ubuntu-xenial/513c2b11-30df-4947-846b-a64309c61eb8.tar
// tsm.retrieve(path, working, progress, TivoliStorageManager.TSM_SERVER_NODE1_OPT);
// fail("Exception should have been thrown");
// } catch (Exception e) {
// assertNotNull("Exception should not be null", e);
// assertEquals("Message not as expected", "Retrieval of test.tar failed. ", e.getMessage());
// }
Progress progress = new Progress();
File working = new File("/tmp/test.tar");
String path = "/tmp";

try {
System.out.println("Retrieve the tar");
//dsmc retrieve /tmp/datavault/temp/2848@ubuntu-xenial/513c2b11-30df-4947-846b-a64309c61eb8.tar
tsm.retrieve(path, working, progress, TivoliStorageManager.TSM_SERVER_NODE1_OPT);
fail("Exception should have been thrown");
} catch (Exception e) {
assertNotNull("Exception should not be null", e);
assertEquals("Message not as expected", "Retrieval of test.tar failed. ", e.getMessage());
}
}

@Test
@Category(org.datavaultplatform.test.TSMTest.class)
public void testRetrieveNonExistantFileFromNodeTwo() {
// retrieve from TSM
// Progress progress = new Progress();
// File working = new File("/tmp/test.tar");
// String path = "/tmp";
//
// try {
// System.out.println("Retrieve the tar");
// //dsmc retrieve /tmp/datavault/temp/2848@ubuntu-xenial/513c2b11-30df-4947-846b-a64309c61eb8.tar
// tsm.retrieve(path, working, progress, TivoliStorageManager.TSM_SERVER_NODE2_OPT);
// fail("Exception should have been thrown");
// } catch (Exception e) {
// assertNotNull("Exception should not be null", e);
// assertEquals("Message not as expected", "Retrieval of test.tar failed. ", e.getMessage());
// }
Progress progress = new Progress();
File working = new File("/tmp/test.tar");
String path = "/tmp";

try {
System.out.println("Retrieve the tar");
//dsmc retrieve /tmp/datavault/temp/2848@ubuntu-xenial/513c2b11-30df-4947-846b-a64309c61eb8.tar
tsm.retrieve(path, working, progress, TivoliStorageManager.TSM_SERVER_NODE2_OPT);
fail("Exception should have been thrown");
} catch (Exception e) {
assertNotNull("Exception should not be null", e);
assertEquals("Message not as expected", "Retrieval of test.tar failed. ", e.getMessage());
}
}

@After
Expand Down

0 comments on commit 3ea765a

Please sign in to comment.