summaryrefslogtreecommitdiffhomepage
path: root/test/test_java_isolation_rootfs.py
diff options
context:
space:
mode:
authorTiago Natel de Moura <t.nateldemoura@f5.com>2020-05-28 14:59:52 +0100
committerTiago Natel de Moura <t.nateldemoura@f5.com>2020-05-28 14:59:52 +0100
commit08b765ae4289f399bb3642d327ccf402efca3537 (patch)
tree972afb5db99730305f22c71a05bd319a9ad526a7 /test/test_java_isolation_rootfs.py
parente2b53e16c60ba1e3bbbe59172c184e97f889326b (diff)
downloadunit-08b765ae4289f399bb3642d327ccf402efca3537.tar.gz
unit-08b765ae4289f399bb3642d327ccf402efca3537.tar.bz2
Tests: Added rootfs tests.
Diffstat (limited to 'test/test_java_isolation_rootfs.py')
-rw-r--r--test/test_java_isolation_rootfs.py85
1 files changed, 85 insertions, 0 deletions
diff --git a/test/test_java_isolation_rootfs.py b/test/test_java_isolation_rootfs.py
new file mode 100644
index 00000000..4d39bdc3
--- /dev/null
+++ b/test/test_java_isolation_rootfs.py
@@ -0,0 +1,85 @@
+import os
+import subprocess
+import unittest
+
+from unit.applications.lang.java import TestApplicationJava
+
+
+class TestJavaIsolationRootfs(TestApplicationJava):
+ prerequisites = {'modules': {'java': 'all'}}
+
+ def setUp(self):
+ if not self.is_su:
+ return
+
+ super().setUp()
+
+ os.makedirs(self.testdir + '/jars')
+ os.makedirs(self.testdir + '/tmp')
+ os.chmod(self.testdir + '/tmp', 0o777)
+
+ try:
+ process = subprocess.Popen(
+ [
+ "mount",
+ "--bind",
+ self.pardir + "/build",
+ self.testdir + "/jars",
+ ],
+ stderr=subprocess.STDOUT,
+ )
+
+ process.communicate()
+
+ except:
+ self.fail('Cann\'t run mount process.')
+
+ def tearDown(self):
+ if not self.is_su:
+ return
+
+ try:
+ process = subprocess.Popen(
+ ["umount", "--lazy", self.testdir + "/jars"],
+ stderr=subprocess.STDOUT,
+ )
+
+ process.communicate()
+
+ except:
+ self.fail('Cann\'t run mount process.')
+
+ # super teardown must happen after unmount to avoid deletion of /build
+ super().tearDown()
+
+ def test_java_isolation_rootfs_chroot_war(self):
+ if not self.is_su:
+ print('require root')
+ raise unittest.SkipTest()
+
+ isolation = {
+ 'rootfs': self.testdir,
+ }
+
+ self.load('empty_war', isolation=isolation)
+
+ self.assertIn(
+ 'success',
+ self.conf(
+ '"/"', '/config/applications/empty_war/working_directory',
+ ),
+ )
+
+ self.assertIn(
+ 'success', self.conf('"/jars"', 'applications/empty_war/unit_jars')
+ )
+ self.assertIn(
+ 'success',
+ self.conf('"/java/empty.war"', 'applications/empty_war/webapp'),
+ )
+
+ self.assertEqual(self.get()['status'], 200, 'war')
+
+
+if __name__ == '__main__':
+ TestJavaIsolationRootfs.main()