|
30 | 30 | import java.nio.file.Path; |
31 | 31 | import java.util.Arrays; |
32 | 32 | import java.util.List; |
| 33 | +import java.util.concurrent.atomic.AtomicReference; |
33 | 34 |
|
34 | 35 | import org.apache.cloudstack.backup.BackupAnswer; |
35 | 36 | import org.apache.cloudstack.backup.RestoreBackupCommand; |
@@ -663,20 +664,23 @@ public void testGetDeviceToAttachDiskPassesUnquotedAwkProgram() throws Exception |
663 | 664 | } |
664 | 665 |
|
665 | 666 | @Test |
666 | | - public void testGetDeviceToAttachDiskFiltersOutCdromEntries() throws Exception { |
| 667 | + public void testGetDeviceToAttachDiskRequestsDomblklistDetails() throws Exception { |
667 | 668 | try (MockedStatic<Script> scriptMock = mockStatic(Script.class)) { |
668 | 669 | scriptMock.when(() -> Script.getExecutableAbsolutePath(anyString())) |
669 | 670 | .thenAnswer(invocation -> invocation.getArgument(0)); |
670 | | - final List<String[]>[] captured = new List[1]; |
| 671 | + final AtomicReference<List<String[]>> captured = new AtomicReference<>(); |
671 | 672 | scriptMock.when(() -> Script.executePipedCommands(anyList(), anyLong())) |
672 | 673 | .thenAnswer(invocation -> { |
673 | | - captured[0] = invocation.getArgument(0); |
| 674 | + captured.set(invocation.getArgument(0)); |
674 | 675 | return new Pair<>(0, "vdb" + System.lineSeparator()); |
675 | 676 | }); |
676 | 677 |
|
677 | 678 | Assert.assertEquals("vdc", invokeGetDeviceToAttachDisk("test-vm")); |
678 | 679 |
|
679 | | - String[] domblkCmd = captured[0].get(0); |
| 680 | + // --details adds the Type column the awk program filters on (verified separately in |
| 681 | + // testGetDeviceToAttachDiskPassesUnquotedAwkProgram); without it cdrom rows can't be |
| 682 | + // told apart from real disks at all. |
| 683 | + String[] domblkCmd = captured.get().get(0); |
680 | 684 | Assert.assertTrue("domblklist must request --details so the Type column is available to filter on", |
681 | 685 | Arrays.asList(domblkCmd).contains("--details")); |
682 | 686 | } |
|
0 commit comments