From 021157db86fe59e7c0132cfd55329f22d53133f5 Mon Sep 17 00:00:00 2001 From: Rajat Gupta Date: Mon, 5 May 2025 15:31:06 +0530 Subject: [PATCH 1/2] Fix seccomp test Signed-off-by: Rajat Gupta --- .../java/org/opensearch/systemdinteg/SystemdIntegTests.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qa/systemd-test/src/test/java/org/opensearch/systemdinteg/SystemdIntegTests.java b/qa/systemd-test/src/test/java/org/opensearch/systemdinteg/SystemdIntegTests.java index 6a923a3534379..1bc2191847dee 100644 --- a/qa/systemd-test/src/test/java/org/opensearch/systemdinteg/SystemdIntegTests.java +++ b/qa/systemd-test/src/test/java/org/opensearch/systemdinteg/SystemdIntegTests.java @@ -37,6 +37,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; public class SystemdIntegTests extends LuceneTestCase { @@ -137,8 +138,9 @@ public void testFileDescriptorLimit() throws IOException, InterruptedException { public void testSeccompEnabled() throws IOException, InterruptedException { // Check if Seccomp is enabled - String seccomp = executeCommand("sudo su -c 'grep Seccomp /proc/" + opensearchPid + "/status'", "Failed to read Seccomp status"); - assertFalse("Seccomp should be enabled", seccomp.contains("0")); + String seccomp = executeCommand("sudo su -c 'grep \"^Seccomp:\" /proc/" + opensearchPid + "/status'", "Failed to read Seccomp status"); + int seccompValue = Integer.parseInt(seccomp.split(":\\s*")[1].trim()); + assertNotEquals("Seccomp should be enabled", 0, seccompValue); } public void testRebootSysCall() throws IOException, InterruptedException { From 113ae6c3958aa87cccc5088eedab975a669277ef Mon Sep 17 00:00:00 2001 From: Rajat Gupta Date: Mon, 5 May 2025 22:18:16 +0530 Subject: [PATCH 2/2] Remove sudo su for seccomp test Signed-off-by: Rajat Gupta --- .../java/org/opensearch/systemdinteg/SystemdIntegTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qa/systemd-test/src/test/java/org/opensearch/systemdinteg/SystemdIntegTests.java b/qa/systemd-test/src/test/java/org/opensearch/systemdinteg/SystemdIntegTests.java index 1bc2191847dee..bc6c929bdf766 100644 --- a/qa/systemd-test/src/test/java/org/opensearch/systemdinteg/SystemdIntegTests.java +++ b/qa/systemd-test/src/test/java/org/opensearch/systemdinteg/SystemdIntegTests.java @@ -138,7 +138,7 @@ public void testFileDescriptorLimit() throws IOException, InterruptedException { public void testSeccompEnabled() throws IOException, InterruptedException { // Check if Seccomp is enabled - String seccomp = executeCommand("sudo su -c 'grep \"^Seccomp:\" /proc/" + opensearchPid + "/status'", "Failed to read Seccomp status"); + String seccomp = executeCommand("grep \"^Seccomp:\" /proc/" + opensearchPid + "/status", "Failed to read Seccomp status"); int seccompValue = Integer.parseInt(seccomp.split(":\\s*")[1].trim()); assertNotEquals("Seccomp should be enabled", 0, seccompValue); }