Beispiel #1
0
    def test_api_create_nfs(self):
        pvname = "yopv"
        pvcname = "yopvc"
        volname = "yovolume"
        podname = "yopod"
        contname = "yocontainer"

        pvtype = "nfs"
        pv = utils.create_pv(name=pvname, type=pvtype)
        pv.nfs_server = "nfs.company.com"
        pv.nfs_path = "/fs1/test-nfs"

        pvc = utils.create_pvc(name=pvcname)

        vol = utils.create_volume(name=volname, type='persistentVolumeClaim')
        vol.claim_name = pvcname

        container = utils.create_container(name=contname, image="nginx:latest")
        volmount = utils.create_volume_mount(name=volname,
                                             mount_path='/test-persistent')
        container.add_volume_mount(volmount)

        pod = utils.create_pod(name=podname)
        pod.add_volume(vol)
        pod.add_container(container)

        if utils.is_reachable(pvc.config.api_host):
            try:
                pv.create()
                pvc.create()
                pod.create()
                self.assertIsInstance(pv, K8sPersistentVolume)
                self.assertIsInstance(pvc, K8sPersistentVolumeClaim)
            except Exception as err:
                self.assertIsInstance(err, TimedOutException)
Beispiel #2
0
    def test_api_create_aws_ebs(self):
        pvname = "yopv"
        pvcname = "yopvc"
        volname = "yovolume"
        podname = "yopod"
        contname = "yocontainer"

        pvtype = "awsElasticBlockStore"
        pv = utils.create_pv(name=pvname, type=pvtype)
        pv.volume_id = "vol-0e3056a2"
        pv.fs_type = "xfs"

        pvc = utils.create_pvc(name=pvcname)

        vol = utils.create_volume(name=volname, type='persistentVolumeClaim')
        vol.claim_name = pvcname

        container = utils.create_container(name=contname, image="nginx:latest")
        volmount = utils.create_volume_mount(name=volname,
                                             mount_path='/test-persistent')
        container.add_volume_mount(volmount)

        pod = utils.create_pod(name=podname)
        pod.add_volume(vol)
        pod.add_container(container)

        if utils.is_reachable(pvc.config.api_host):
            try:
                pv.create()
                pvc.create()
                pod.create()
                self.assertIsInstance(pv, K8sPersistentVolume)
                self.assertIsInstance(pvc, K8sPersistentVolumeClaim)
            except Exception as err:
                self.assertIsInstance(err, TimedOutException)