@Test public void testHostPathVolume() { IHostPathVolumeProperties volume = new HostPathVolumeProperties("/tmp/dir"); pv.setPersistentVolumeProperties(volume); volume = (IHostPathVolumeProperties) pv.getPersistentVolumeProperties(); assertEquals("/tmp/dir", volume.getPath()); }
@Test(expected = ArithmeticException.class) public void testSetCapacityOverflow() { /* * 2^4 * 2 ^60 = 2^64, LONG_MAX is only 2^64-1 */ pv.setCapacity(16L, MemoryUnit.Ei); pv.getCapacity(); }
@Test public void testNFSVolume() { INfsVolumeProperties volume = new NfsVolumeProperties("10.10.10.10", "/tmp/dir", true); pv.setPersistentVolumeProperties(volume); volume = (INfsVolumeProperties) pv.getPersistentVolumeProperties(); assertEquals("/tmp/dir", volume.getPath()); assertEquals("10.10.10.10", volume.getServer()); assertEquals(true, volume.isReadOnly()); }
@Test public void testGetCapacityUnit() { pv.setCapacity(1L, MemoryUnit.Ki); MemoryUnit unit = pv.getCapacityUnit(); assertEquals(MemoryUnit.Ki, unit); pv.setCapacity(1L, MemoryUnit.Pi); unit = pv.getCapacityUnit(); assertEquals(MemoryUnit.Pi, unit); }
@Test public void testSetCapacity() { pv.setCapacity(1L, MemoryUnit.Ki); long capacity = pv.getCapacity(); assertEquals(1024L, capacity); pv.setCapacity(31L, MemoryUnit.Ti); capacity = pv.getCapacity(MemoryUnit.Ti); assertEquals(31L, capacity); }
@Test public void testGetCapacityString() { pv.setCapacity(13L, MemoryUnit.Pi); long capacity = pv.getCapacity("Ki"); assertEquals(14293651161088L, capacity); capacity = pv.getCapacity("Ti"); assertEquals(13312L, capacity); capacity = pv.getCapacity("Pi"); assertEquals(13L, capacity); }
@Test public void testAccessModes() { pv.setAccessModes("ReadWriteOnce"); Set<String> modes = pv.getAccessModes(); assertTrue(modes.contains("ReadWriteOnce")); pv.setAccessModes("ReadWriteOnce", "ReadOnlyMany", "ReadWriteMany"); modes = pv.getAccessModes(); Set<String> expected = new HashSet<>(); expected.addAll(Arrays.asList("ReadWriteOnce", "ReadOnlyMany", "ReadWriteMany")); assertTrue(modes.containsAll(expected)); }
@Test public void testGetCapacity() { pv.setCapacity(13L, MemoryUnit.Pi); long capacity = pv.getCapacity(); assertEquals(14636698788954112L, capacity); }
@Test public void testGetPersistentVolumeProperties() { pv.getPersistentVolumeProperties(); }
@Test public void testReclaimPolicy() { pv.setReclaimPolicy("Recycle"); String policy = pv.getReclaimPolicy(); assertEquals(policy, "Recycle"); }