Skip to content

Commit aca411a

Browse files
RajatGupta02Rajat Gupta
andauthored
Fix systemd seccomp test (opensearch-project#18196)
* Fix seccomp test Signed-off-by: Rajat Gupta <gptrajat@amazon.com> * Remove sudo su for seccomp test Signed-off-by: Rajat Gupta <gptrajat@amazon.com> --------- Signed-off-by: Rajat Gupta <gptrajat@amazon.com> Co-authored-by: Rajat Gupta <gptrajat@amazon.com>
1 parent 46955ff commit aca411a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

qa/systemd-test/src/test/java/org/opensearch/systemdinteg/SystemdIntegTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import static org.junit.Assert.assertTrue;
3838
import static org.junit.Assert.assertEquals;
3939
import static org.junit.Assert.assertFalse;
40+
import static org.junit.Assert.assertNotEquals;
4041

4142

4243
public class SystemdIntegTests extends LuceneTestCase {
@@ -137,8 +138,9 @@ public void testFileDescriptorLimit() throws IOException, InterruptedException {
137138

138139
public void testSeccompEnabled() throws IOException, InterruptedException {
139140
// Check if Seccomp is enabled
140-
String seccomp = executeCommand("sudo su -c 'grep Seccomp /proc/" + opensearchPid + "/status'", "Failed to read Seccomp status");
141-
assertFalse("Seccomp should be enabled", seccomp.contains("0"));
141+
String seccomp = executeCommand("grep \"^Seccomp:\" /proc/" + opensearchPid + "/status", "Failed to read Seccomp status");
142+
int seccompValue = Integer.parseInt(seccomp.split(":\\s*")[1].trim());
143+
assertNotEquals("Seccomp should be enabled", 0, seccompValue);
142144
}
143145

144146
public void testRebootSysCall() throws IOException, InterruptedException {

0 commit comments

Comments
 (0)