summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/varlink/run_varlink_tests.sh37
-rw-r--r--test/varlink/test_containers.py99
-rw-r--r--test/varlink/test_images.py71
-rw-r--r--test/varlink/test_system.py21
4 files changed, 228 insertions, 0 deletions
diff --git a/test/varlink/run_varlink_tests.sh b/test/varlink/run_varlink_tests.sh
new file mode 100644
index 000000000..9c247fec2
--- /dev/null
+++ b/test/varlink/run_varlink_tests.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+set -x
+if [ ! -n "${PYTHON+ }" ]; then
+ if hash python3 > /dev/null 2>&1 /dev/null; then
+ PYTHON=$(hash -t python3)
+ elif type python3 > /dev/null 2>&1; then
+ PYTHON=$(type python3 | awk '{print $3}')
+ elif hash python2 > /dev/null 2>&1; then
+ PYTHON=$(hash -t python2)
+ elif type python2 > /dev/null 2>&1; then
+ PYTHON=$(type python2 | awk '{print $3}')
+ else
+ PYTHON='/usr/bin/python'
+ fi
+fi
+
+# Create temporary directory for storage
+TMPSTORAGE=`mktemp -d`
+
+# Need a location to store the podman socket
+mkdir /run/podman
+
+# Run podman in background without systemd for test purposes
+bin/podman --storage-driver=vfs --root=${TMPSTORAGE}/crio --runroot=${TMPSTORAGE}/crio-run varlink unix:/run/podman/io.projectatomic.podman&
+
+# Record podman's pid to be killed later
+PODMAN_PID=`echo $!`
+
+# Run tests
+${PYTHON} -m unittest discover -s test/varlink/
+
+# Kill podman
+kill -9 ${PODMAN_PID}
+
+# Clean up
+rm -fr ${TMPSTORAGE}
diff --git a/test/varlink/test_containers.py b/test/varlink/test_containers.py
new file mode 100644
index 000000000..651461d55
--- /dev/null
+++ b/test/varlink/test_containers.py
@@ -0,0 +1,99 @@
+import unittest
+from varlink import (Client, VarlinkError)
+
+
+address = "unix:/run/podman/io.projectatomic.podman"
+client = Client(address=address)
+
+
+def runErrorTest(tfunc):
+ try:
+ tfunc()
+ except VarlinkError as e:
+ return e.error() == "org.varlink.service.MethodNotImplemented"
+ return False
+
+
+class ContainersAPI(unittest.TestCase):
+ def test_ListContainers(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.ListContainers))
+
+ def test_CreateContainer(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.CreateContainer))
+
+ def test_InspecContainer(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.InspectContainer))
+
+ def test_ListContainerProcesses(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.ListContainerProcesses))
+
+ def test_GetContainerLogs(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.GetContainerLogs))
+
+ def test_ListContainerChanges(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.ListContainerChanges))
+
+ def test_ExportContainer(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.ExportContainer))
+
+ def test_GetContainerStats(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.GetContainerStats))
+
+ def test_ResizeContainerTty(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.ResizeContainerTty))
+
+ def test_StartContainer(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.StartContainer))
+
+ def test_RestartContainer(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.RestartContainer))
+
+ def test_KillContainer(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.KillContainer))
+
+ def test_UpdateContainer(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.UpdateContainer))
+
+ def test_RenameContainer(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.RenameContainer))
+
+ def test_PauseContainer(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.PauseContainer))
+
+ def test_UnpauseContainer(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.UnpauseContainer))
+
+ def test_AttachToContainer(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.AttachToContainer))
+
+ def test_WaitContainer(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.WaitContainer))
+
+ def test_RemoveContainer(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.RemoveContainer))
+
+ def test_DeleteContainer(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.DeleteContainer))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/test/varlink/test_images.py b/test/varlink/test_images.py
new file mode 100644
index 000000000..ef1ab1088
--- /dev/null
+++ b/test/varlink/test_images.py
@@ -0,0 +1,71 @@
+import unittest
+from varlink import (Client, VarlinkError)
+
+
+address = "unix:/run/podman/io.projectatomic.podman"
+client = Client(address=address)
+
+
+def runErrorTest(tfunc):
+ try:
+ tfunc()
+ except VarlinkError as e:
+ return e.error() == "org.varlink.service.MethodNotImplemented"
+ return False
+
+
+class ImagesAPI(unittest.TestCase):
+ def test_ListImages(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.ListImages))
+
+ def test_BuildImage(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.BuildImage))
+
+ def test_CreateImage(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.CreateImage))
+
+ def test_InspectImage(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.InspectImage))
+
+ def test_HistoryImage(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.HistoryImage))
+
+ def test_PushImage(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.PushImage))
+
+ def test_TagImage(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.TagImage))
+
+ def test_RemoveImage(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.TagImage))
+
+ def test_SearchImage(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.SearchImage))
+
+ def test_DeleteUnusedImages(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.DeleteUnusedImages))
+
+ def test_CreateFromContainer(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.CreateFromContainer))
+
+ def test_ImportImage(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.ImportImage))
+
+ def test_ExportImage(self):
+ podman = client.open("io.projectatomic.podman")
+ self.assertTrue(runErrorTest(podman.ExportImage))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/test/varlink/test_system.py b/test/varlink/test_system.py
new file mode 100644
index 000000000..6180d2068
--- /dev/null
+++ b/test/varlink/test_system.py
@@ -0,0 +1,21 @@
+import unittest
+from varlink import (Client, VarlinkError)
+
+
+address = "unix:/run/podman/io.projectatomic.podman"
+client = Client(address=address)
+
+class SystemAPI(unittest.TestCase):
+ def test_ping(self):
+ podman = client.open("io.projectatomic.podman")
+ response = podman.Ping()
+ self.assertEqual("OK", response["ping"]["message"])
+
+ def test_GetVersion(self):
+ podman = client.open("io.projectatomic.podman")
+ response = podman.GetVersion()
+ for k in ["version", "go_version", "built", "os_arch"]:
+ self.assertTrue(k in response["version"].keys())
+
+if __name__ == '__main__':
+ unittest.main()