|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | +""" Test for storage.overprovisioning.factor update |
| 18 | +""" |
| 19 | +#Import Local Modules |
| 20 | +from marvin.cloudstackTestCase import * |
| 21 | +from marvin.cloudstackAPI import * |
| 22 | +from marvin.integration.lib.utils import * |
| 23 | +from marvin.integration.lib.base import * |
| 24 | +from marvin.integration.lib.common import * |
| 25 | +from nose.plugins.attrib import attr |
| 26 | +#Import System modules |
| 27 | + |
| 28 | +class TestUpdateOverProvision(cloudstackTestCase): |
| 29 | + """ |
| 30 | + Test to update a storage.overprovisioning.factor |
| 31 | + """ |
| 32 | + def setUp(self): |
| 33 | + self.apiClient = self.testClient.getApiClient() |
| 34 | + |
| 35 | + @attr(tags=["simulator", "devcloud", "basic", "advanced"]) |
| 36 | + def test_UpdateStorageOverProvisioningFactor(self): |
| 37 | + """ |
| 38 | + test update configuration setting at storage scope |
| 39 | + @return: |
| 40 | + """ |
| 41 | + |
| 42 | + """ 1. list storagepools for id """ |
| 43 | + """ 2. list overprovisioning factor for storage pool """ |
| 44 | + """ 3. update setting for the pool""" |
| 45 | + """ 4. list overprovisioning factor for storage pool and assert""" |
| 46 | + |
| 47 | + """ list storagepools """ |
| 48 | + storage_pools = StoragePool.list( |
| 49 | + self.apiClient, |
| 50 | + listall=True |
| 51 | + ) |
| 52 | + self.assertEqual( |
| 53 | + isinstance(storage_pools, list), |
| 54 | + True, |
| 55 | + "List storage pools should not return empty response" |
| 56 | + ) |
| 57 | + |
| 58 | + if len(storage_pools) < 1: |
| 59 | + raise self.skipTest( |
| 60 | + "The environment don't have storage pools required for test") |
| 61 | + |
| 62 | + for pool in storage_pools: |
| 63 | + if pool.type == "NetworkFilesystem" or pool.type == "VMFS": |
| 64 | + break |
| 65 | + if pool.type != "NetworkFilesystem" and pool.type != "VMFS": |
| 66 | + raise self.skipTest("Storage overprovisioning currently not supported on " + pool.type + " pools") |
| 67 | + |
| 68 | + self.poolId = pool.id |
| 69 | + """ list overprovisioning factor for storage pool """ |
| 70 | + factorOld = float(pool.overprovisionfactor) |
| 71 | + factorNew = str(factorOld + 1.0) |
| 72 | + |
| 73 | + """ update setting for the pool""" |
| 74 | + updateConfigurationCmd = updateConfiguration.updateConfigurationCmd() |
| 75 | + updateConfigurationCmd.name = "storage.overprovisioning.factor" |
| 76 | + updateConfigurationCmd.value = factorNew |
| 77 | + updateConfigurationCmd.storageid = pool.id |
| 78 | + |
| 79 | + updateConfigurationResponse = self.apiClient.updateConfiguration(updateConfigurationCmd) |
| 80 | + |
| 81 | + self.debug("updated the parameter %s with value %s"%(updateConfigurationResponse.name, updateConfigurationResponse.value)) |
| 82 | + |
| 83 | + storage_pools = StoragePool.list( |
| 84 | + self.apiClient, |
| 85 | + id = self.poolId |
| 86 | + ) |
| 87 | + pool = storage_pools[0] |
| 88 | + factorNew = float(pool.overprovisionfactor) |
| 89 | + self.assertNotEqual(int(factorNew), int(factorOld)," Check if overprovision factor of storage pool has changed") |
| 90 | + self.assertEqual(int(factorNew), int(factorOld + 1.0)," Check if overprovision factor of storage pool has increased by 1") |
| 91 | + |
| 92 | + def tearDown(self): |
| 93 | + """Reset the storage.overprovisioning.factor back to its original value |
| 94 | + @return: |
| 95 | + """ |
| 96 | + storage_pools = StoragePool.list( |
| 97 | + self.apiClient, |
| 98 | + id = self.poolId |
| 99 | + ) |
| 100 | + pool = storage_pools[0] |
| 101 | + updateConfigurationCmd = updateConfiguration.updateConfigurationCmd() |
| 102 | + updateConfigurationCmd.name = "storage.overprovisioning.factor" |
| 103 | + factorOld = float(pool.overprovisionfactor) |
| 104 | + factorNew = str(factorOld - 1.0) |
| 105 | + updateConfigurationCmd.value = factorNew |
| 106 | + updateConfigurationCmd.storageid = pool.id |
| 107 | + updateConfigurationResponse = self.apiClient.updateConfiguration(updateConfigurationCmd) |
0 commit comments