diff options
Diffstat (limited to 'node-admin')
3 files changed, 23 insertions, 7 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/cgroup/Cgroup.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/cgroup/Cgroup.java index 2fcbcf3c738..e40e3c6c003 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/cgroup/Cgroup.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/cgroup/Cgroup.java @@ -16,7 +16,7 @@ import java.util.function.Consumer; import java.util.logging.Logger; /** - * Represents a cgroup directory in the control group v2 hierarchy, see + * Represents a cgroup in the control group v2 hierarchy, see * <a href="https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html">Control Group v2</a>. * * @author hakonhall @@ -87,7 +87,7 @@ public class Cgroup { /** Returns the absolute path to this cgroup. */ public Path path() { return root.resolve(relativePath); } - /** Returns the absolute UnixPath to this cgroup. */ + /** Returns the UnixPath of {@link #path()}. */ public UnixPath unixPath() { return new UnixPath(path()); } public String read(String filename) { @@ -129,10 +129,10 @@ public class Cgroup { /** Returns an instance representing core interface files (cgroup.* files). */ public CgroupCore core() { return new CgroupCore(this); } - /** Returns the CPU controller of this Cgroup (cpu.* files). */ + /** Returns the CPU controller of this cgroup (cpu.* files). */ public CpuController cpu() { return new CpuController(this); } - /** Returns the memory controller of this Cgroup (memory.* files). */ + /** Returns the memory controller of this cgroup (memory.* files). */ public MemoryController memory() { return new MemoryController(this); } /** diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/file/UnixPath.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/file/UnixPath.java index f3d0e5d0000..56d517d0b80 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/file/UnixPath.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/file/UnixPath.java @@ -100,7 +100,7 @@ public class UnixPath { } } - public List<String> readAllLines() { + public List<String> readLines() { return uncheck(() -> Files.readAllLines(path)); } diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/file/UnixPathTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/file/UnixPathTest.java index ad8c6ea3a35..d5af2b0c4b7 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/file/UnixPathTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/file/UnixPathTest.java @@ -10,8 +10,14 @@ import java.nio.charset.StandardCharsets; import java.nio.file.FileSystem; import java.nio.file.Files; import java.nio.file.Path; +import java.util.List; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author hakonhall @@ -38,6 +44,15 @@ public class UnixPathTest { path.writeUtf8File(original); String fromFile = path.readUtf8File(); assertEquals(original, fromFile); + assertEquals(List.of("foo", "bar"), path.readLines()); + } + + @Test + void touch() { + UnixPath path = new UnixPath(fs.getPath("example.txt")); + assertTrue(path.touch()); + assertEquals("", path.readUtf8File()); + assertFalse(path.touch()); } @Test @@ -74,9 +89,10 @@ public class UnixPathTest { Path path = fs.getPath("dir"); UnixPath unixPath = new UnixPath(path); String permissions = "rwxr-xr--"; - unixPath.createDirectory(permissions); + assertTrue(unixPath.createDirectory(permissions)); assertTrue(unixPath.isDirectory()); assertEquals(permissions, unixPath.getPermissions()); + assertFalse(unixPath.createDirectory(permissions)); } @Test |