@@ -44,27 +44,27 @@ class DirectorySyncerTest extends DevStackSpec {
44
44
! volumeExists(uniqueVolumeName) ?: dockerClient. rmVolume(uniqueVolumeName)
45
45
log. debug(" \t Will use sync to Docker volume:" + uniqueVolumeName)
46
46
47
- DirectorySyncer firstSyncer = DirectorySyncer . createSyncToVolume([srcDir1. canonicalPath, srcDir2. canonicalPath], uniqueVolumeName, " DirSyncer" , " -avh --delete" , dockerRemoteHost, dockerCertPath )
47
+ DirectorySyncer firstSyncer = DirectorySyncer . createSyncToVolume([srcDir1. canonicalPath, srcDir2. canonicalPath], uniqueVolumeName, " DirSyncer" , " -avh --delete" , dockerRemoteHost, dockerCertPath)
48
48
log. info(" \t Created first sync container: ${ firstSyncer.containerName} (${ firstSyncer.shortId} )" )
49
49
Integer containersAfterFirst = firstSyncer. dockerClient. ps(true ). content. size()
50
50
log. info(" \t\t Docker engine now has a total of ${ containersAfterFirst} contianers" )
51
51
52
52
when : " Creating second sync container"
53
- DirectorySyncer secondSyncer = DirectorySyncer . createSyncToVolume([srcDir1. canonicalPath, srcDir2. canonicalPath], uniqueVolumeName, " DirSyncer" ," -avh --delete" , dockerRemoteHost, dockerCertPath )
53
+ DirectorySyncer secondSyncer = DirectorySyncer . createSyncToVolume([srcDir1. canonicalPath, srcDir2. canonicalPath], uniqueVolumeName, " DirSyncer" , " -avh --delete" , dockerRemoteHost, dockerCertPath)
54
54
log. info(" \t Created second sync container: ${ secondSyncer.containerName} (${ secondSyncer.shortId} )" )
55
55
56
56
then : " They should have the same ID"
57
- assert firstSyncer. id == secondSyncer. id : " The second container doesnt have the same id"
58
- assert containersAfterFirst == secondSyncer. dockerClient. ps(true ). content. size() : " The number of containers changed after creating the second one"
57
+ assert firstSyncer. id == secondSyncer. id: " The second container doesnt have the same id"
58
+ assert containersAfterFirst == secondSyncer. dockerClient. ps(true ). content. size(): " The number of containers changed after creating the second one"
59
59
assert secondSyncer. running
60
60
log. info(" \t A duplicate container was not created, instead the first one was returned" )
61
61
62
62
when : " Stopping the sync container, and creating another duplicate"
63
63
firstSyncer. stopContainer()
64
64
assert ! firstSyncer. running
65
- secondSyncer = DirectorySyncer . createSyncToVolume([srcDir1. canonicalPath, srcDir2. canonicalPath], uniqueVolumeName, " DirSyncer" ," -avh --delete" , dockerRemoteHost, dockerCertPath )
65
+ secondSyncer = DirectorySyncer . createSyncToVolume([srcDir1. canonicalPath, srcDir2. canonicalPath], uniqueVolumeName, " DirSyncer" , " -avh --delete" , dockerRemoteHost, dockerCertPath)
66
66
67
- then :" The duplicate should have been automatically started"
67
+ then : " The duplicate should have been automatically started"
68
68
secondSyncer. running
69
69
70
70
@@ -75,7 +75,6 @@ class DirectorySyncerTest extends DevStackSpec {
75
75
dockerClient. rmVolume(uniqueVolumeName)
76
76
77
77
78
-
79
78
}
80
79
81
80
@@ -96,7 +95,7 @@ class DirectorySyncerTest extends DevStackSpec {
96
95
srcContainer. user = " 1001:1001"
97
96
srcContainer. createSleepyContainer()
98
97
srcContainer. startContainer()
99
- srcContainer. runBashCommandInContainer(ImageSummaryDS . getReplaceUserScriptBody(" ubuntu" , " 1000" , " ubuntu" , " 1000" , " ubuntusrc" , " 1001" , " ubuntusrc" , " 1001" ),10 , " root" )
98
+ srcContainer. runBashCommandInContainer(ImageSummaryDS . getReplaceUserScriptBody(" ubuntu" , " 1000" , " ubuntu" , " 1000" , " ubuntusrc" , " 1001" , " ubuntusrc" , " 1001" ), 10 , " root" )
100
99
srcContainer. runBashCommandInContainer(" chown 1001:1001 -R /mnt/volume" , 5 , " root" )
101
100
102
101
@@ -106,7 +105,7 @@ class DirectorySyncerTest extends DevStackSpec {
106
105
destContainer. user = " 1002:1002"
107
106
destContainer. createSleepyContainer()
108
107
destContainer. startContainer()
109
- destContainer. runBashCommandInContainer(ImageSummaryDS . getReplaceUserScriptBody(" ubuntu" , " 1000" , " ubuntu" , " 1000" , " ubuntudest" , " 1002" , " ubuntudest" , " 1002" ),10 , " root" )
108
+ destContainer. runBashCommandInContainer(ImageSummaryDS . getReplaceUserScriptBody(" ubuntu" , " 1000" , " ubuntu" , " 1000" , " ubuntudest" , " 1002" , " ubuntudest" , " 1002" ), 10 , " root" )
110
109
destContainer. runBashCommandInContainer(" chown 1002:1002 -R /mnt/volume" , 5 , " root" )
111
110
112
111
then : " When checking user id, they should be different"
@@ -151,7 +150,7 @@ class DirectorySyncerTest extends DevStackSpec {
151
150
when : " When creating syncer"
152
151
153
152
assert ! volumeExists(uniqueVolumeName): " Destination volume already exists"
154
- DirectorySyncer syncer = DirectorySyncer . createSyncToVolume([srcDir1. canonicalPath, srcDir2. canonicalPath], uniqueVolumeName, " DirSyncer" , " -avh --delete" , dockerRemoteHost, dockerCertPath )
153
+ DirectorySyncer syncer = DirectorySyncer . createSyncToVolume([srcDir1. canonicalPath, srcDir2. canonicalPath], uniqueVolumeName, " DirSyncer" , " -avh --delete" , dockerRemoteHost, dockerCertPath)
155
154
log. info(" \t Created sync container: ${ syncer.containerName} (${ syncer.shortId} )" )
156
155
ContainerInspectResponse containerInspect = syncer. inspectContainer()
157
156
@@ -185,14 +184,16 @@ class DirectorySyncerTest extends DevStackSpec {
185
184
log. debug(" \t Container successfully synced the files to destination dir" )
186
185
187
186
when : " Creating a recursive file"
188
- File recursiveFile = new File (srcDir1. canonicalPath + " /subDir/subFile.temp" ). createParentDirectories()
187
+ File recursiveFile = new File (srcDir1. canonicalPath + " /subDir/subDir2/subDir3/subDir4/subDir5/subFile.temp" )
188
+ recursiveFile. createParentDirectories()
189
+ sleep(2000 ) // Make sure that we dont trigger on the dir creation, but on the recursive file
189
190
recursiveFile. createNewFile()
190
191
recursiveFile. text = System . nanoTime()
191
192
log. info(" \t Create recursive file:" + recursiveFile. canonicalPath)
192
193
193
194
then : " The sync container should see the new source file, and sync it to a new recursive dir"
194
195
sleep(2000 )
195
- syncer. runBashCommandInContainer(" cat /mnt/dest/subDir/subFile.temp" ). toString(). contains(recursiveFile. text)
196
+ syncer. runBashCommandInContainer(" cat /mnt/dest/subDir/subDir2/subDir3/subDir4/subDir5/ subFile.temp" ). toString(). contains(recursiveFile. text)
196
197
log. info(" \t\t File was successfully synced" )
197
198
198
199
@@ -211,27 +212,27 @@ class DirectorySyncerTest extends DevStackSpec {
211
212
syncer. runBashCommandInContainer(" cat /mnt/dest/${ srcFile2.name} " ). toString(). containsIgnoreCase(srcFile2. text)
212
213
log. debug(" \t\t Container successfully synced the changes" )
213
214
214
- when :" Creating a new container and attaching it to the synced volume"
215
+ when : " Creating a new container and attaching it to the synced volume"
215
216
AlpineContainer secondContainer = new AlpineContainer (dockerRemoteHost, dockerCertPath)
216
- secondContainer. containerName = syncer. containerName + " -companion"
217
+ secondContainer. containerName = syncer. containerName + " -companion"
217
218
secondContainer. prepareVolumeMount(uniqueVolumeName, " /mnt/syncDir" , false )
218
219
secondContainer. createSleepyContainer()
219
220
220
221
221
- then :" The second container should see the still remaining synced files"
222
- assert secondContainer. startContainer() : " Error creating/staring second container"
222
+ then : " The second container should see the still remaining synced files"
223
+ assert secondContainer. startContainer(): " Error creating/staring second container"
223
224
log. info(" \t Created an started second container ${ secondContainer.shortId} " )
224
- assert secondContainer. mounts. any { it. type == MountPoint.Type.Volume && it. RW == true } : " Second container did not mount the shared volume"
225
+ assert secondContainer. mounts. any { it. type == MountPoint.Type.Volume && it. RW == true } : " Second container did not mount the shared volume"
225
226
log. info(" \t Second container was attached to volume:" + uniqueVolumeName)
226
- log. info(" \t Checking that second container can access synced file:" + " /mnt/syncDir/${ srcFile2.name} " )
227
- assert secondContainer. runBashCommandInContainer(" cat /mnt/syncDir/${ srcFile2.name} " ). toString(). containsIgnoreCase(srcFile2. text) : " Error reading synced file in second container:" + " /mnt/syncDir/${ srcFile2.name} "
227
+ log. info(" \t Checking that second container can access synced file:" + " /mnt/syncDir/${ srcFile2.name} " )
228
+ assert secondContainer. runBashCommandInContainer(" cat /mnt/syncDir/${ srcFile2.name} " ). toString(). containsIgnoreCase(srcFile2. text): " Error reading synced file in second container:" + " /mnt/syncDir/${ srcFile2.name} "
228
229
229
230
log. info(" \t Checking that second container can access recursive synced file" )
230
- assert secondContainer. runBashCommandInContainer(" cat /mnt/syncDir/subDir/subFile.temp" ). toString(). contains(recursiveFile. text)
231
+ assert secondContainer. runBashCommandInContainer(" cat /mnt/syncDir/subDir/subDir2/subDir3/subDir4/subDir5/ subFile.temp" ). toString(). contains(recursiveFile. text)
231
232
log. info(" \t\t Container can access that file" )
232
233
cleanup :
233
- assert syncer. stopAndRemoveContainer()
234
- assert secondContainer?. stopAndRemoveContainer()
234
+ syncer. stopAndRemoveContainer()
235
+ secondContainer?. stopAndRemoveContainer()
235
236
srcDir1. deleteDir()
236
237
srcDir2. deleteDir()
237
238
dockerClient. rmVolume(containerInspect. mounts. find { it. type == MountPoint.Type.Volume }. name)
0 commit comments