Skip to content
Snippets Groups Projects
Commit cba1b20a authored by buczekp's avatar buczekp
Browse files

[LMS-2142] tests for remote implementation of folder comparison

SVN: 20473
parent ef2afb12
No related branches found
No related tags found
No related merge requests found
...@@ -210,7 +210,7 @@ public final class RemoteDataSetFileOperationsExecutor implements IDataSetFileOp ...@@ -210,7 +210,7 @@ public final class RemoteDataSetFileOperationsExecutor implements IDataSetFileOp
for (String line : output) for (String line : output)
{ {
String split[] = line.split("\t"); String split[] = line.split("\t");
assert split.length == 2; assert split.length == 2; // silently ignore in production - it will fail later
destinationFileSizesByPaths.put(split[0], Long.parseLong(split[1])); destinationFileSizesByPaths.put(split[0], Long.parseLong(split[1]));
} }
} else } else
......
...@@ -58,6 +58,12 @@ public class DataSetFileOperationsManagerTest extends AbstractFileSystemTestCase ...@@ -58,6 +58,12 @@ public class DataSetFileOperationsManagerTest extends AbstractFileSystemTestCase
ExecutionResult.createExceptional(new Exception(DUMMY_ERROR_MESSAGE)), null, 0, ExecutionResult.createExceptional(new Exception(DUMMY_ERROR_MESSAGE)), null, 0,
(List<String>) null, null, null, null); (List<String>) null, null, null, null);
private static ProcessResult createOkResultWithOutput(List<String> output)
{
return new ProcessResult(Arrays.asList(""), 0, null, ExecutionResult.create(null), null, 0,
output, null, null, null);
}
private static final long SSH_TIMEOUT_MILLIS = DataSetFileOperationsManager.SSH_TIMEOUT_MILLIS; private static final long SSH_TIMEOUT_MILLIS = DataSetFileOperationsManager.SSH_TIMEOUT_MILLIS;
private static final String LOCATION_1 = "l1"; private static final String LOCATION_1 = "l1";
...@@ -666,7 +672,7 @@ public class DataSetFileOperationsManagerTest extends AbstractFileSystemTestCase ...@@ -666,7 +672,7 @@ public class DataSetFileOperationsManagerTest extends AbstractFileSystemTestCase
{ {
{ {
/* /*
* ds1: directory is present and content is OK * ds1: directory is present but content is WRONG
*/ */
one(sshExecutor).exists(ds1ArchivedLocationFile.getPath(), SSH_TIMEOUT_MILLIS); one(sshExecutor).exists(ds1ArchivedLocationFile.getPath(), SSH_TIMEOUT_MILLIS);
will(returnValue(BooleanStatus.createTrue())); will(returnValue(BooleanStatus.createTrue()));
...@@ -674,26 +680,35 @@ public class DataSetFileOperationsManagerTest extends AbstractFileSystemTestCase ...@@ -674,26 +680,35 @@ public class DataSetFileOperationsManagerTest extends AbstractFileSystemTestCase
one(sshExecutor).executeCommandRemotely( one(sshExecutor).executeCommandRemotely(
gfindExec.getPath() + " " + ds1ArchivedLocationFile.getPath() gfindExec.getPath() + " " + ds1ArchivedLocationFile.getPath()
+ " -type f -printf \"%p\\t%s\\n\"", SSH_TIMEOUT_MILLIS); + " -type f -printf \"%p\\t%s\\n\"", SSH_TIMEOUT_MILLIS);
will(returnValue(ERROR_RESULT)); will(returnValue(createOkResultWithOutput(Arrays.asList(
"original/data1_2.txt\t4", "original/fake.txt\t666"))));
// /* /*
// * ds2: directory is present and content is OK * ds2: directory is present and content is OK
// */ */
// one(sshExecutor).exists(ds2ArchivedLocationFile.getPath(), one(sshExecutor).exists(ds2ArchivedLocationFile.getPath(), SSH_TIMEOUT_MILLIS);
// SSH_TIMEOUT_MILLIS); will(returnValue(BooleanStatus.createTrue()));
// will(returnValue(BooleanStatus.createTrue())); one(sshExecutor).executeCommandRemotely(
gfindExec.getPath() + " " + ds2ArchivedLocationFile.getPath()
+ " -type f -printf \"%p\\t%s\\n\"", SSH_TIMEOUT_MILLIS);
will(returnValue(createOkResultWithOutput(Arrays
.asList("original/data2.txt\t12"))));
} }
}); });
BooleanStatus status1 = dataSetCopier.isPresentInDestination(ds1Location, ds1); BooleanStatus status1 = dataSetCopier.isPresentInDestination(ds1Location, ds1);
// BooleanStatus status2 = dataSetCopier.isPresentInDestination(ds2Location, ds2); assertFalse(status1, "Inconsistencies:\n"
assertError(status1, "listing files failed"); + "'original/data1_1.txt' - exists in store but is missing in destination\n"
// assertTrue(status2); + "'original/data1_2.txt' - different file sizes; store: 14, destination: 4\n"
+ "'original/fake.txt' - exists in destination but is missing in store\n");
BooleanStatus status2 = dataSetCopier.isPresentInDestination(ds2Location, ds2);
assertTrue(status2);
context.assertIsSatisfied(); context.assertIsSatisfied();
} }
@Test @Test
public void testRemoteViaSshIsPresentInDestinationWithError() public void testRemoteViaSshIsPresentInDestinationWithErrors()
{ {
Properties properties = createRemoteViaSshDestinationProperties(); Properties properties = createRemoteViaSshDestinationProperties();
prepareRemoteCreateAndCheckCopier(HOST, null, true); prepareRemoteCreateAndCheckCopier(HOST, null, true);
...@@ -702,12 +717,28 @@ public class DataSetFileOperationsManagerTest extends AbstractFileSystemTestCase ...@@ -702,12 +717,28 @@ public class DataSetFileOperationsManagerTest extends AbstractFileSystemTestCase
context.checking(new Expectations() context.checking(new Expectations()
{ {
{ {
/*
* ds1: checking existance fails
*/
one(sshExecutor).exists(ds1ArchivedLocationFile.getPath(), SSH_TIMEOUT_MILLIS); one(sshExecutor).exists(ds1ArchivedLocationFile.getPath(), SSH_TIMEOUT_MILLIS);
will(returnValue(BooleanStatus.createError(DUMMY_ERROR_MESSAGE))); will(returnValue(BooleanStatus.createError(DUMMY_ERROR_MESSAGE)));
/*
* ds2: listing fails
*/
one(sshExecutor).exists(ds2ArchivedLocationFile.getPath(), SSH_TIMEOUT_MILLIS);
will(returnValue(BooleanStatus.createTrue()));
one(sshExecutor).executeCommandRemotely(
gfindExec.getPath() + " " + ds2ArchivedLocationFile.getPath()
+ " -type f -printf \"%p\\t%s\\n\"", SSH_TIMEOUT_MILLIS);
will(returnValue(ERROR_RESULT));
} }
}); });
BooleanStatus status = dataSetCopier.isPresentInDestination(ds1Location, ds1); BooleanStatus status1 = dataSetCopier.isPresentInDestination(ds1Location, ds1);
assertError(status, DUMMY_ERROR_MESSAGE); assertError(status1, DUMMY_ERROR_MESSAGE);
BooleanStatus status2 = dataSetCopier.isPresentInDestination(ds2Location, ds2);
assertError(status2, "listing files failed");
context.assertIsSatisfied(); context.assertIsSatisfied();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment