[meta-parsec,3/3] oeqa: add parsec runtime tests

Message ID 20220521185640.143194-3-akuster808@gmail.com
State Accepted
Delegated to: Armin Kuster
Headers show
Series [meta-parsec,1/3] meta-parsec: Add pkg grps | expand

Commit Message

akuster808 May 21, 2022, 6:56 p.m. UTC
Signed-off-by: Armin Kuster <akuster808@gmail.com>
---
 meta-parsec/lib/oeqa/runtime/cases/parsec.py | 32 ++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 meta-parsec/lib/oeqa/runtime/cases/parsec.py

Comments

Anton Antonov May 23, 2022, 8:51 a.m. UTC | #1
Hi Amir,

Thank you very much for adding Parsec runtime testing.

I have a few small comments:

1. You defined the security Parsec image without TPM (with packagegroup-security-parsec group) , but in the runtime tests you use TPM. Shouldn't you use an image with packagegroup-security-parsec-tpm2 group instead?
2. Could you add 'parsec-cli-tests.sh' script after "parsec start" in the "cmds" list. This script runs end-to-end tests against Parsec service. The script is a part of the parsec-tool package and it's already included into the image

Regards,
Anton

Patch

diff --git a/meta-parsec/lib/oeqa/runtime/cases/parsec.py b/meta-parsec/lib/oeqa/runtime/cases/parsec.py
new file mode 100644
index 0000000..d07028c
--- /dev/null
+++ b/meta-parsec/lib/oeqa/runtime/cases/parsec.py
@@ -0,0 +1,32 @@ 
+# Copyright (C) 2022 Armin Kuster <akuster808@gmail.com>
+#
+import re
+
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+
+class ParsecTest(OERuntimeTestCase):
+    @OEHasPackage(['parsec-service'])
+    @OETestDepends(['ssh.SSHTest.test_ssh'])
+    def test_parsec_service(self):
+        toml_file = '/etc/parsec/config.tom'
+        status, output = self.target.run('echo -n library_path = "/usr/lib/softhsm/libsofthsm2.so" >> %s' %(toml_file))
+        status, output = self.target.run('echo -n slot_number = 0 >> %s' %(toml_file))
+        status, output = self.target.run('echo -n user_pin = "123456" >> %s' %(toml_file))
+        cmds = [
+                '/etc/init.d/parsec stop',
+                'sleep 5',
+                'softhsm2-util --init-token --slot 0 --label "Parsec Service" --pin 123456 --so-pin 123456',
+                'for d in /var/lib/softhsm/tokens/*; do chown -R parsec $d; done', 
+                'mkdir /tmp/myvtpm',
+                'swtpm socket --tpmstate dir=/tmp/myvtpm --tpm2 --ctrl type=tcp,port=2322 --server type=tcp,port=2321 --flags not-need-init &',
+                'export TPM2TOOLS_TCTI="swtpm:port=2321"',
+                'tpm2_startup -c',
+                'sleep 2',
+                '/etc/init.d/parsec start',
+               ]
+
+        for cmd in cmds:
+            status, output = self.target.run(cmd)
+            self.assertEqual(status, 0, msg='\n'.join([cmd, output]))