示例#1
0
    def _podman_connect(self, podman_uri: str):
        logging.debug("Connecting to Podman API")
        try:
            client = PodmanClient(base_url=podman_uri, timeout=60)
            client.info()  # info() will try to connect to the API
        except APIError as e:
            raise PoolManagerError(f"Could not connect to Podman API: {e}")

        self._podman_client = client
示例#2
0
class SystemIntegrationTest(base.IntegrationTest):
    """system call integration test"""
    def setUp(self):
        super().setUp()
        self.client = PodmanClient(base_url=self.socket_uri)
        self.addCleanup(self.client.close)

    def test_info(self):
        """integration: system info call"""
        output = self.client.info()
        self.assertTrue('host' in output)

    def test_version(self):
        """integration: system version call"""
        output = self.client.version()
        self.assertTrue('Platform' in output)
        self.assertTrue('Version' in output)
        self.assertTrue('ApiVersion' in output)

    def test_show_disk_usage(self):
        """integration: system disk usage call"""
        output = self.client.df()
        self.assertTrue('Images' in output)
        self.assertTrue('Containers' in output)
        self.assertTrue('Volumes' in output)
示例#3
0
class SystemTestCase(unittest.TestCase):
    def setUp(self) -> None:
        super().setUp()

        self.client = PodmanClient(base_url=tests.BASE_SOCK)

    def tearDown(self) -> None:
        super().tearDown()

        self.client.close()

    @requests_mock.Mocker()
    def test_df(self, mock):
        body = {
            "Containers": [
                {"ContainerID": "f1fb3564c202"},
                {"ContainerID": "779afab684c7"},
            ],
            "Images": [
                {"ImageID": "118cc2c68ef5"},
                {"ImageID": "a6b4a8255f9e"},
            ],
            "Volumes": [
                {"VolumeName": "27df59163be8"},
                {"VolumeName": "77a83a10f86e"},
            ],
        }

        mock.get(
            tests.BASE_URL + "/libpod/system/df",
            json=body,
        )

        actual = self.client.df()
        self.assertDictEqual(actual, body)

    @requests_mock.Mocker()
    def test_info(self, mock):
        body = {
            "host": {
                "arch": "amd65",
                "os": "linux",
            }
        }
        mock.get(tests.BASE_URL + "/libpod/info", json=body)

        actual = self.client.info()
        self.assertDictEqual(actual, body)

    @requests_mock.Mocker()
    def test_ping(self, mock):
        mock.head(tests.BASE_URL + "/libpod/_ping")
        self.assertTrue(self.client.ping())

    @requests_mock.Mocker()
    def test_version(self, mock):
        body = {
            "APIVersion": "3.0.0",
            "MinAPIVersion": "3.0.0",
            "Arch": "amd64",
            "Os": "linux",
        }
        mock.get(tests.BASE_URL + "/libpod/version", json=body)
        self.assertDictEqual(self.client.version(), body)