Example #1
0
 def setUpClass(cls):
     super(TestVolume,cls).setUpClass()
     cls.host = FixtureFactory(cls.api).create_host_with_depends(Config.get_instance().hosts[0].create()).host
     result = FixtureFactory(cls.api).create_host_with_depends(Config.get_instance().hosts[1].create())
     cls.host2 = result.host
     cls.cluster = result.cluster
     cls.datacenter = result.datacenter
Example #2
0
 def tearDownClass(cls):
     FixtureFactory(cls.api).deactivate_host_and_wait_for_maintanence(cls.host)
     HostRepository(cls.api).destroy(cls.host)
     FixtureFactory(cls.api).deactivate_host_and_wait_for_maintanence(cls.host2)
     HostRepository(cls.api).destroy(cls.host2)
     ClusterRepository(cls.api).destroy(cls.cluster)
     DatacenterRepository(cls.api).destroy(cls.datacenter)
     super(TestVolume,cls).tearDownClass()
Example #3
0
 def test_create_distributed_volume(self):
     bricks = ParamFactory().create_bricks()
     for _ in range(4):
        bricks.add_brick(ParamFactory().create_brick(TestVolume.host.id))
     for _ in range(4):
        bricks.add_brick(ParamFactory().create_brick(TestVolume.host2.id))
     volparams = ParamFactory().create_volume(bricks,'myvol2')
     vol = FixtureFactory(self.api).create_volume(TestVolume.cluster, volparams)
     vol.delete()
Example #4
0
 def test_create_replicated_volume(self):
     bricks = ParamFactory().create_bricks()
     for _ in range(4):
         bricks.add_brick(ParamFactory().create_brick(TestVolume.host.id))
     for _ in range(4):
         bricks.add_brick(ParamFactory().create_brick(TestVolume.host2.id))
     volparams = ParamFactory().create_volume(bricks,'rep-vol',"REPLICATE")
     volparams.set_replica_count(8)
     vol = FixtureFactory(self.api).create_volume(TestVolume.cluster, volparams)
     vol.delete()
Example #5
0
 def tearDown(self):
     FixtureFactory(self.api).deactivate_host_and_wait_for_maintanence(
         self.host)
     HostRepository(self.api).destroy(self.host)
     FixtureFactory(self.api).deactivate_host_and_wait_for_maintanence(
         self.host2)
     HostRepository(self.api).destroy(self.host2)
     ClusterRepository(self.api).destroy(self.cluster)
     DatacenterRepository(self.api).destroy(self.datacenter)
     self.vol.delete()
Example #6
0
 def setUp(self):
     self.api = TestBase.api
     self.host = FixtureFactory(self.api).create_host_with_depends(
         Config.get_instance().hosts[0].create()).host
     result = FixtureFactory(api).create_host_with_depends(
         Config.get_instance().hosts[1].create())
     self.host2 = result.host
     self.cluster = result.cluster
     self.datacenter = result.datacenter
     self.vol = create_distributed_volume()
     VolumePopulator().fileForEachBrick(volume)
 def test_add_brick(self):
     volparams = VolumeFactory().create_distributed_volume("myvol", TestVolume.hosts, 8)
     vol = FixtureFactory(self.api).create_volume(TestVolume.cluster, volparams)
     try:
         bricks = ParamFactory().create_bricks()
         new_brick = BrickFactory().create(TestVolume.host2.id)
         bricks.add_brick(new_brick)
         vol.bricks.add(bricks)
     except Exception as e:
         raise
     finally:
         vol.delete()
    def test_negative_create_distributed_volume_with_bricks_from_another(self):
        vol = None
        existing_volum = None
        try:
            existing_volume_params = VolumeFactory().create_distributed_volume("existing-volume", TestVolume.hosts, 8)
            existing_volum = FixtureFactory(self.api).create_volume(TestVolume.cluster, existing_volume_params)
            existing_brick = existing_volum.bricks.list()[0]

            bricks = VolumeFactory().create_bricks(TestVolume.hosts, 7)
            bricks.add_brick(BrickFactory().create(existing_brick.get_server_id(), existing_brick.get_brick_dir()))
            new_volume_params = VolumeFactory().create_distributed_volume("new-volume", TestVolume.hosts, 8)
            new_volume_params.set_bricks(bricks)
            self.assertRaisesRegexp(
                RequestError,
                ".*already used.*",
                lambda: FixtureFactory(self.api).create_volume(TestVolume.cluster, new_volume_params),
            )
        finally:
            existing_volum and existing_volum.delete()
            vol and vol.delete()
Example #9
0
    def test_negative_create_distributed_volume_with_bricks_from_another(self):
        vol = None
        existing_volum = None
        try:
            existing_volum = self._create_distributed_volume('existing-volume')
            existing_brick = existing_volum.bricks.list()[0]

            bricks = self._create_param_bricks(TestVolume.host.id, 7)
            bricks.append(ParamFactory().create_brick(existing_brick.get_server_id(),existing_brick.get_brick_dir()))
            self.assertRaisesRegexp(RequestError,'.*already used.*',
                    lambda: FixtureFactory(self.api).create_volume(TestVolume.cluster, ParamFactory().create_volume(ParamFactory().create_bricks(*bricks),'existing-brick-negative-volume')))
        finally:
            existing_volum and existing_volum.delete()
            vol and vol.delete()
 def test_create_replicated_volume(self):
     volparams = VolumeFactory().create_distributed_replicate_volume("myvol", TestVolume.hosts, 8, 2)
     vol = FixtureFactory(self.api).create_volume(TestVolume.cluster, volparams)
     vol.delete()
Example #11
0
 def _create_distributed_volume(self, name):
     return FixtureFactory(self.api).create_volume(TestVolume.cluster, self._create_distributed_volume_params(name))
Example #12
0
 def create_distributed_volume(self):
     params = VolumeFactory().distributedVolume('my_dist_vol')
     return FixtureFactory(self.api).create_volume(TestVolume.cluster,
                                                   params)