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)
 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
 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)
Beispiel #4
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)
 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
 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)
 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
 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
Beispiel #9
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)
 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)
 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
 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)
 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
 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)
 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
 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
 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)
 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)
 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)
 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)
 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.api_host):
         vol.create()
         self.assertIsInstance(vol, K8sPersistentVolume)
         self.assertEqual(host_path, vol.path)
 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.api_host):
         vol.create()
         self.assertIsInstance(vol, K8sPersistentVolume)
         self.assertEqual(vol.pd_name, pd_name)
         self.assertEqual(vol.fs_type, fs_type)
 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.api_host):
         vol.create()
         _list = vol.list()
         for x in _list:
             self.assertIsInstance(x, K8sPersistentVolume)
 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.api_host):
         vol.create()
         self.assertIsInstance(vol, K8sPersistentVolume)
         self.assertEqual(vol.nfs_server, server)
         self.assertEqual(vol.nfs_path, path)
 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.api_host):
         vol.create()
         self.assertIsInstance(vol, K8sPersistentVolume)
         self.assertEqual(vol.volume_id, volume_id)
         self.assertEqual(vol.fs_type, fs_type)
 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
 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
 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
 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