Tal Nisan has uploaded a new change for review.

Change subject: core: Disallow domains of mixed subtype (file/block) in <3.4 
storage pool
......................................................................

core: Disallow domains of mixed subtype (file/block) in <3.4 storage pool

Disallow adding domains of a different subtype (file/block)  that the
domains alread contained in the pool with a compatibility version lower
than 3.4 which contains domai

Change-Id: I8226c29e6c34ab6434d0a5ec07aa7fa1d4d00306
Bug-Url: https://bugzilla.redhat.com/1083560
Signed-off-by: Tal Nisan <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBase.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBaseTest.java
2 files changed, 36 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/66/26366/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBase.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBase.java
index 1da70ee..8589f12 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBase.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBase.java
@@ -227,7 +227,7 @@
     // to mix NFS domains with block domains on 3.0 pools since block domains 
on 3.0 pools can be in V2 format while NFS
     // domains on 3.0 can only be in V1 format
     protected boolean isMixedTypesAllowedInDC() {
-        return 
getStoragePool().getcompatibility_version().compareTo(Version.v3_0) > 0;
+        return 
getStoragePool().getcompatibility_version().compareTo(Version.v3_3) > 0;
     }
 
     public boolean isMixedTypeDC(StorageDomain storageDomain) {
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBaseTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBaseTest.java
index 52e5271..efa8d05 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBaseTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBaseTest.java
@@ -61,7 +61,9 @@
     public static MockConfigRule mcr = new MockConfigRule(
             // Indicates a supported storage format of V2 & V3 in version 3.4
             mockConfig(ConfigValues.SupportedStorageFormats, 
Version.v3_0.toString(), "0,1"),
+            mockConfig(ConfigValues.SupportedStorageFormats, 
Version.v3_1.toString(), "3"),
             mockConfig(ConfigValues.SupportedStorageFormats, 
Version.v3_2.toString(), "3"),
+            mockConfig(ConfigValues.SupportedStorageFormats, 
Version.v3_3.toString(), "3"),
             mockConfig(ConfigValues.SupportedStorageFormats, 
Version.v3_4.toString(), "3"),
             mockConfig(ConfigValues.GlusterFsStorageEnabled, 
Version.v3_0.toString(), false),
             mockConfig(ConfigValues.GlusterFsStorageEnabled, 
Version.v3_4.toString(), true),
@@ -132,28 +134,52 @@
         assertTrue("Attaching a valid domain to attach was failed", 
cmd.checkDomainCanBeAttached(storageDomain));
     }
 
+
     /**
-     * Mixed types are not allowed on V3.0, test that attempting to attach a 
domain of different type than what already
-     * exists in the data center will fail
+     * Mixed types are not allowed on version lower than V3.4, test that 
attempting to attach a domain of different type
+     * than what already exists in the data center will fail for versions 3.0 
to 3.3 inclusive
      */
     @Test
-    public void testMixedTypesUnsupported() {
-        storagePool.setcompatibility_version(Version.v3_0);
+    public void testMixedTypesOnAllUnsupportedVersions() {
+        for (Version version : Version.ALL) {
+            if (version.compareTo(Version.v3_0) >= 0 && 
version.compareTo(Version.v3_4) < 0) { // No reason to test unsupported versions
+                testAddingMixedTypes(version, false);
+            }
+        }
+    }
+
+    @Test
+    public void testMixedTypesOnAllSupportedVersions() {
+        for (Version version : Version.ALL) {
+            if (version.compareTo(Version.v3_4) >= 0) { // No reason to test 
unsupported versions
+                testAddingMixedTypes(version, true);
+            }
+        }
+    }
+
+    private void testAddingMixedTypes(Version version, boolean 
addingMixedTypesShouldSucceed) {
+        storagePool.setcompatibility_version(version);
 
         StorageDomain existingStorageDomain = createValidStorageDomain();
         existingStorageDomain.setStorageType(StorageType.NFS);
         addDomainToPool(existingStorageDomain);
 
         StorageDomain domainToAttach = createValidStorageDomain();
-        domainToAttach.setStorageFormat(StorageFormatType.V1);
+        
domainToAttach.setStorageFormat(cmd.getSupportedStorageFormatSet(version).iterator().next());
         existingStorageDomain.setStorageType(StorageType.NFS);
-        assertTrue("Attaching an NFS domain to a pool with NFS domain with no 
mixed type allowed failed", cmd.checkDomainCanBeAttached(domainToAttach));
+        initCommand();
+        assertTrue("Attaching an NFS domain to a pool with NFS domain with no 
mixed type allowed failed, version: " + version, 
cmd.checkDomainCanBeAttached(domainToAttach));
 
         domainToAttach.setStorageType(StorageType.ISCSI);
         initCommand();
-        assertFalse("Attaching an ISCSI domain to a pool with NFS domain with 
no mixed type allowed succeeded", cmd.checkDomainCanBeAttached(domainToAttach));
-        CanDoActionTestUtils.assertCanDoActionMessages("Attaching an ISCSI 
domain to a pool with NFS domain with no mixed type failed with the wrong 
message", cmd,
-                
VdcBllMessages.ACTION_TYPE_FAILED_MIXED_STORAGE_TYPES_NOT_ALLOWED);
+        if (addingMixedTypesShouldSucceed) {
+            assertTrue("Attaching an ISCSI domain to a pool with NFS domain 
with with mixed type allowed failed, version: " + version, 
cmd.checkDomainCanBeAttached(domainToAttach));
+        }
+        else {
+            assertFalse("Attaching an ISCSI domain to a pool with NFS domain 
with no mixed type allowed succeeded, version: " + version, 
cmd.checkDomainCanBeAttached(domainToAttach));
+            CanDoActionTestUtils.assertCanDoActionMessages("Attaching an ISCSI 
domain to a pool with NFS domain with no mixed type failed with the wrong 
message", cmd,
+                    
VdcBllMessages.ACTION_TYPE_FAILED_MIXED_STORAGE_TYPES_NOT_ALLOWED);
+        }
 
     }
 


-- 
To view, visit http://gerrit.ovirt.org/26366
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8226c29e6c34ab6434d0a5ec07aa7fa1d4d00306
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Tal Nisan <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to