コード例 #1
0
 def test_aws_set_volume_id(self):
     name = "yoname"
     _type = "awsElasticBlockStore"
     volume_id = "vol-0a89c9040d544a371"
     vol = _utils.create_pv(name=name, type=_type)
     vol.volume_id = volume_id
     self.assertEqual(vol.volume_id, volume_id)
コード例 #2
0
    def test_api_create_gce_pd(self):
        pvname = "yopv"
        pvcname = "yopvc"
        volname = "yovolume"
        podname = "yopod"
        contname = "yocontainer"

        pvtype = "gcePersistentDisk"
        pv = _utils.create_pv(name=pvname, type=pvtype)
        pv.pd_name = "mnubo-disk1"
        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):
            try:
                pv.create()
                pvc.create()
                pod.create()
                self.assertIsInstance(pv, K8sPersistentVolume)
                self.assertIsInstance(pvc, K8sPersistentVolumeClaim)
            except Exception as err:
                self.assertIsInstance(err, TimedOutException)
コード例 #3
0
 def test_hostpath_set_path(self):
     name = "yoname"
     _type = "hostPath"
     host_path = "/path/on/host"
     vol = _utils.create_pv(name=name, type=_type)
     vol.path = host_path
     self.assertEqual(host_path, vol.path)
コード例 #4
0
 def test_nfs_set_server_invalid_type(self):
     name = "yoname"
     _type = "hostPath"
     server = "nfs.company.com"
     vol = _utils.create_pv(name=name, type=_type)
     with self.assertRaises(NotImplementedError):
         vol.nfs_server = server
コード例 #5
0
 def test_aws_set_fs_type(self):
     name = "yoname"
     _type = "awsElasticBlockStore"
     fs_type = "xfs"
     vol = _utils.create_pv(name=name, type=_type)
     vol.fs_type = fs_type
     self.assertEqual(vol.fs_type, fs_type)
コード例 #6
0
 def test_hostpath_set_path_invalid_type(self):
     name = "yoname"
     _type = "gcePersistentDisk"
     host_path = "/path/on/host"
     vol = _utils.create_pv(name=name, type=_type)
     with self.assertRaises(NotImplementedError):
         vol.path = host_path
コード例 #7
0
 def test_aws_set_volume_id_invalid_type(self):
     name = "yoname"
     _type = "hostPath"
     volume_id = "vol-0a89c9040d544a371"
     vol = _utils.create_pv(name=name, type=_type)
     with self.assertRaises(NotImplementedError):
         vol.volume_id = volume_id
コード例 #8
0
 def test_gce_set_fs_type(self):
     name = "yoname"
     _type = "gcePersistentDisk"
     fs_type = "xfs"
     vol = _utils.create_pv(name=name, type=_type)
     vol.fs_type = fs_type
     self.assertEqual(vol.fs_type, fs_type)
コード例 #9
0
 def test_nfs_set_server(self):
     name = "yoname"
     _type = "nfs"
     server = "nfs.company.com"
     vol = _utils.create_pv(name=name, type=_type)
     vol.nfs_server = server
     self.assertEqual(vol.nfs_server, server)
コード例 #10
0
 def test_gce_fs_type_invalid_obj(self):
     name = "yoname"
     _type = "gcePersistentDisk"
     fs_type = object()
     vol = _utils.create_pv(name=name, type=_type)
     with self.assertRaises(SyntaxError):
         vol.fs_type = fs_type
コード例 #11
0
 def test_fs_type_invalid_type(self):
     name = "yoname"
     _type = "hostPath"
     fs_type = object()
     vol = _utils.create_pv(name=name, type=_type)
     with self.assertRaises(NotImplementedError):
         vol.fs_type = fs_type
コード例 #12
0
 def test_gce_set_pd_name(self):
     name = "yoname"
     _type = "gcePersistentDisk"
     pd_name = "vol-0a89c9040d544a371"
     vol = _utils.create_pv(name=name, type=_type)
     vol.pd_name = pd_name
     self.assertEqual(vol.pd_name, pd_name)
コード例 #13
0
 def test_nfs_set_server_invalid(self):
     name = "yoname"
     _type = "nfs"
     server = object()
     vol = _utils.create_pv(name=name, type=_type)
     with self.assertRaises(SyntaxError):
         vol.nfs_server = server
コード例 #14
0
 def test_gce_set_pd_name_invalid_type(self):
     name = "yoname"
     _type = "hostPath"
     pd_name = "yopdname"
     vol = _utils.create_pv(name=name, type=_type)
     with self.assertRaises(NotImplementedError):
         vol.pd_name = pd_name
コード例 #15
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):
            try:
                pv.create()
                pvc.create()
                pod.create()
                self.assertIsInstance(pv, K8sPersistentVolume)
                self.assertIsInstance(pvc, K8sPersistentVolumeClaim)
            except Exception as err:
                self.assertIsInstance(err, TimedOutException)
コード例 #16
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):
            try:
                pv.create()
                pvc.create()
                pod.create()
                self.assertIsInstance(pv, K8sPersistentVolume)
                self.assertIsInstance(pvc, K8sPersistentVolumeClaim)
            except Exception as err:
                self.assertIsInstance(err, TimedOutException)
コード例 #17
0
 def test_aws_fs_type_invalid_obj(self):
     name = "yoname"
     _type = "awsElasticBlockStore"
     fs_type = object()
     vol = _utils.create_pv(name=name, type=_type)
     with self.assertRaises(SyntaxError):
         vol.fs_type = fs_type
コード例 #18
0
 def test_aws_init(self):
     name = "yoname"
     _type = "awsElasticBlockStore"
     vol = _utils.create_pv(name=name, type=_type)
     self.assertIsNotNone(vol)
     self.assertIsInstance(vol, K8sPersistentVolume)
     self.assertEqual(_type, vol.type)
     self.assertIsInstance(vol.source, AWSElasticBlockStoreVolumeSource)
コード例 #19
0
 def test_gce_init(self):
     name = "yoname"
     _type = "gcePersistentDisk"
     vol = _utils.create_pv(name=name, type=_type)
     self.assertIsNotNone(vol)
     self.assertIsInstance(vol, K8sPersistentVolume)
     self.assertEqual(_type, vol.type)
     self.assertIsInstance(vol.source, GCEPersistentDiskVolumeSource)
コード例 #20
0
 def test_init_host_path(self):
     name = "yoname"
     _type = 'hostPath'
     vol = _utils.create_pv(name=name, type=_type)
     self.assertIsNotNone(vol)
     self.assertIsInstance(vol, K8sPersistentVolume)
     self.assertEqual('hostPath', vol.type)
     self.assertIsInstance(vol.source, HostPathVolumeSource)
コード例 #21
0
 def test_nfs_init(self):
     name = "yoname"
     _type = "nfs"
     vol = _utils.create_pv(name=name, type=_type)
     self.assertIsNotNone(vol)
     self.assertIsInstance(vol, K8sPersistentVolume)
     self.assertEqual(_type, vol.type)
     self.assertIsInstance(vol.source, NFSVolumeSource)
コード例 #22
0
 def test_api_hostpath(self):
     name = "yoname"
     _type = "hostPath"
     host_path = "/path/on/host"
     vol = _utils.create_pv(name=name, type=_type)
     vol.path = host_path
     self.assertEqual(host_path, vol.path)
     if _utils.is_reachable(vol.config):
         vol.create()
         self.assertIsInstance(vol, K8sPersistentVolume)
         self.assertEqual(host_path, vol.path)
コード例 #23
0
    def test_api_hostpath(self):
        name = "yoname"
        _type = "hostPath"
        host_path = "/path/on/host"
        vol = _utils.create_pv(name=name, type=_type)
        vol.path = host_path
        self.assertEqual(host_path, vol.path)

        if _utils.is_reachable(vol.config):
            vol.create()
            self.assertIsInstance(vol, K8sPersistentVolume)
            self.assertEqual(host_path, vol.path)
コード例 #24
0
 def test_list(self):
     name = "yoname"
     _type = "gcePersistentDisk"
     pd_name = "mnubo-disk1"
     fs_type = 'xfs'
     vol = _utils.create_pv(name=name, type=_type)
     vol.pd_name = pd_name
     vol.fs_type = fs_type
     if _utils.is_reachable(vol.config):
         vol.create()
         _list = vol.list()
         for x in _list:
             self.assertIsInstance(x, K8sPersistentVolume)
コード例 #25
0
 def test_api_gce_pd(self):
     name = "yoname"
     _type = "gcePersistentDisk"
     pd_name = "mnubo-disk1"
     fs_type = 'xfs'
     vol = _utils.create_pv(name=name, type=_type)
     vol.pd_name = pd_name
     vol.fs_type = fs_type
     if _utils.is_reachable(vol.config):
         vol.create()
         self.assertIsInstance(vol, K8sPersistentVolume)
         self.assertEqual(vol.pd_name, pd_name)
         self.assertEqual(vol.fs_type, fs_type)
コード例 #26
0
 def test_api_nfs(self):
     name = "yoname"
     _type = "nfs"
     server = "nfs.company.com"
     path = "/some/path"
     vol = _utils.create_pv(name=name, type=_type)
     vol.nfs_server = server
     vol.nfs_path = path
     if _utils.is_reachable(vol.config):
         vol.create()
         self.assertIsInstance(vol, K8sPersistentVolume)
         self.assertEqual(vol.nfs_server, server)
         self.assertEqual(vol.nfs_path, path)
コード例 #27
0
 def test_api_aws_ebs(self):
     name = "yoname"
     _type = "awsElasticBlockStore"
     volume_id = "vol-0e3056a2"
     fs_type = 'xfs'
     vol = _utils.create_pv(name=name, type=_type)
     vol.volume_id = volume_id
     vol.fs_type = fs_type
     if _utils.is_reachable(vol.config):
         vol.create()
         self.assertIsInstance(vol, K8sPersistentVolume)
         self.assertEqual(vol.volume_id, volume_id)
         self.assertEqual(vol.fs_type, fs_type)
コード例 #28
0
    def test_api_gce_pd(self):
        name = "yoname"
        _type = "gcePersistentDisk"
        pd_name = "mnubo-disk1"
        fs_type = 'xfs'
        vol = _utils.create_pv(name=name, type=_type)
        vol.pd_name = pd_name
        vol.fs_type = fs_type

        if _utils.is_reachable(vol.config):
            vol.create()
            self.assertIsInstance(vol, K8sPersistentVolume)
            self.assertEqual(vol.pd_name, pd_name)
            self.assertEqual(vol.fs_type, fs_type)
コード例 #29
0
    def test_api_aws_ebs(self):
        name = "yoname"
        _type = "awsElasticBlockStore"
        volume_id = "vol-0e3056a2"
        fs_type = 'xfs'
        vol = _utils.create_pv(name=name, type=_type)
        vol.volume_id = volume_id
        vol.fs_type = fs_type

        if _utils.is_reachable(vol.config):
            vol.create()
            self.assertIsInstance(vol, K8sPersistentVolume)
            self.assertEqual(vol.volume_id, volume_id)
            self.assertEqual(vol.fs_type, fs_type)
コード例 #30
0
    def test_list(self):
        name = "yoname"
        _type = "gcePersistentDisk"
        pd_name = "mnubo-disk1"
        fs_type = 'xfs'
        vol = _utils.create_pv(name=name, type=_type)
        vol.pd_name = pd_name
        vol.fs_type = fs_type

        if _utils.is_reachable(vol.config):
            vol.create()
            _list = vol.list()
            for x in _list:
                self.assertIsInstance(x, K8sPersistentVolume)
コード例 #31
0
    def test_api_nfs(self):
        name = "yoname"
        _type = "nfs"
        server = "nfs.company.com"
        path = "/some/path"
        vol = _utils.create_pv(name=name, type=_type)
        vol.nfs_server = server
        vol.nfs_path = path

        if _utils.is_reachable(vol.config):
            vol.create()
            self.assertIsInstance(vol, K8sPersistentVolume)
            self.assertEqual(vol.nfs_server, server)
            self.assertEqual(vol.nfs_path, path)
コード例 #32
0
 def test_aws_set_fs_type_none(self):
     name = "yoname"
     _type = "awsElasticBlockStore"
     vol = _utils.create_pv(name=name, type=_type)
     with self.assertRaises(SyntaxError):
         vol.fs_type = None
コード例 #33
0
 def test_gce_set_fs_type_none(self):
     name = "yoname"
     _type = "gcePersistentDisk"
     vol = _utils.create_pv(name=name, type=_type)
     with self.assertRaises(SyntaxError):
         vol.fs_type = None
コード例 #34
0
 def test_hostpath_set_path_none(self):
     name = "yoname"
     _type = "hostPath"
     vol = _utils.create_pv(name=name, type=_type)
     with self.assertRaises(SyntaxError):
         vol.path = None
コード例 #35
0
 def test_nfs_set_server_none(self):
     name = "yoname"
     _type = "nfs"
     vol = _utils.create_pv(name=name, type=_type)
     with self.assertRaises(SyntaxError):
         vol.nfs_server = None