Fix ConcurrentlySnapshotCase
@@ -167,28 +167,22 @@ class ConcurrentlySnapshotCase extends SubCase {
uuid = vm.uuid
}
- List<String> afterDestroyUuids = Q.New(VolumeSnapshotVO.class).select(VolumeSnapshotVO_.uuid).eq(VolumeSnapshotVO_.volumeUuid, vm.getRootVolumeUuid()).listValues()
- assert afterDestroyUuids.size() == 100
- final CountDownLatch latch = new CountDownLatch(100)
+ assert Q.New(VolumeSnapshotVO.class).eq(VolumeSnapshotVO_.volumeUuid, vm.getRootVolumeUuid()).count() == (long) 100
+ def threads = []
for (String suuid : uuids) {
def targetUuid = suuid
- new Thread(new Runnable() {
- @Override
- void run() {
- try{
+ def thread = Thread.start {
deleteVolumeSnapshot {
uuid = targetUuid
}
- }finally {
- latch.countDown()
- }
}
- }).start()
+
+ threads.add(thread)
}
- latch.await(20, TimeUnit.SECONDS)
- afterDestroyUuids = Q.New(VolumeSnapshotVO.class).select(VolumeSnapshotVO_.uuid).eq(VolumeSnapshotVO_.volumeUuid, vm.getRootVolumeUuid()).listValues()
- assert afterDestroyUuids.size() == 0
+ threads.each { it.join() }
+
+ assert Q.New(VolumeSnapshotVO.class).eq(VolumeSnapshotVO_.volumeUuid, vm.getRootVolumeUuid()).count() == (long) 0
recoverVmInstance {
uuid = vm.uuid
@@ -219,28 +213,21 @@ class ConcurrentlySnapshotCase extends SubCase {
uuid = vm.uuid
}
- List<String> afterExpungeUuids = Q.New(VolumeSnapshotVO.class).select(VolumeSnapshotVO_.uuid).eq(VolumeSnapshotVO_.volumeUuid, vm.getRootVolumeUuid()).listValues()
- assert afterExpungeUuids.size() == 0
- final CountDownLatch latch = new CountDownLatch(100)
+ assert Q.New(VolumeSnapshotVO.class).eq(VolumeSnapshotVO_.volumeUuid, vm.getRootVolumeUuid()).count() == (long) 0
+ def threads = []
for (String suuid : uuids) {
def targetUuid = suuid
- new Thread(new Runnable() {
- @Override
- void run() {
- try{
+ def thread = Thread.start {
deleteVolumeSnapshot {
uuid = targetUuid
}
- }finally {
- latch.countDown()
}
+ threads.add(thread)
}
- }).start()
- }
- latch.await(20, TimeUnit.SECONDS)
- afterExpungeUuids = Q.New(VolumeSnapshotVO.class).select(VolumeSnapshotVO_.uuid).eq(VolumeSnapshotVO_.volumeUuid, vm.getRootVolumeUuid()).listValues()
- assert afterExpungeUuids.size() == 0
+ threads.each { it.join() }
+
+ assert Q.New(VolumeSnapshotVO.class).eq(VolumeSnapshotVO_.volumeUuid, vm.getRootVolumeUuid()).count() == (long) 0
}
void testDeleteSnapshotsAfterDestroyVmDirectly() {
