use of com.emc.storageos.db.client.model.VdcVersion in project coprhd-controller by CoprHD.
the class VdcUtilTest method shouldReturnDefaultVersionIfNoGeoVersion.
@Test
public void shouldReturnDefaultVersionIfNoGeoVersion() {
DbClient dbClientMock = EasyMock.createMock(DbClient.class);
EasyMock.expect(dbClientMock.queryByType(VdcVersion.class, true)).andReturn(new ArrayList<URI>());
EasyMock.expect(dbClientMock.queryObject(VdcVersion.class, new ArrayList<URI>())).andReturn(new ArrayList<VdcVersion>());
EasyMock.expect(dbClientMock.queryByType(VirtualDataCenter.class, true)).andReturn(new ArrayList<URI>());
EasyMock.replay(dbClientMock);
VdcUtil.setDbClient(dbClientMock);
String minialVdcVersion = VdcUtil.getMinimalVdcVersion();
String expectedVdcVersion = DbConfigConstants.DEFAULT_VDC_DB_VERSION;
Assert.assertEquals(expectedVdcVersion, minialVdcVersion);
}
use of com.emc.storageos.db.client.model.VdcVersion in project coprhd-controller by CoprHD.
the class VdcUtilTest method shouldReturnDefaultVersionIfMissVdcVersion.
@Test
public void shouldReturnDefaultVersionIfMissVdcVersion() {
List<VdcVersion> geoVersions = new ArrayList<VdcVersion>();
List<URI> vdcIds = new ArrayList<URI>();
geoVersions.add(VDC2_GEO_VERSION);
vdcIds.add(VDC1_ID);
vdcIds.add(VDC2_ID);
DbClient dbClientMock = EasyMock.createMock(DbClient.class);
EasyMock.expect(dbClientMock.queryByType(VdcVersion.class, true)).andReturn(new ArrayList<URI>());
EasyMock.expect(dbClientMock.queryObject(VdcVersion.class, new ArrayList<URI>())).andReturn(geoVersions);
EasyMock.expect(dbClientMock.queryByType(VirtualDataCenter.class, true)).andReturn(vdcIds);
EasyMock.replay(dbClientMock);
VdcUtil.setDbClient(dbClientMock);
String minialVdcVersion = VdcUtil.getMinimalVdcVersion();
String expectedVdcVersion = DbConfigConstants.DEFAULT_VDC_DB_VERSION;
Assert.assertEquals(expectedVdcVersion, minialVdcVersion);
}
use of com.emc.storageos.db.client.model.VdcVersion in project coprhd-controller by CoprHD.
the class VdcUtil method checkGeoCompatibleOfOtherVdcs.
/**
* Check if geo version of all other vdcs(excluding local vdc) are equal to or higher than target version
*
* @param targetVersion
* @return
*/
public static boolean checkGeoCompatibleOfOtherVdcs(String targetVersion) {
URI localVdcId = getLocalVdc().getId();
List<URI> geoVerIds = dbClient.queryByType(VdcVersion.class, true);
List<VdcVersion> geoVersions = dbClient.queryObject(VdcVersion.class, geoVerIds);
for (VdcVersion geoVersion : geoVersions) {
URI vdcId = geoVersion.getVdcId();
if (vdcId.equals(localVdcId)) {
// skip current vdc
continue;
}
if (VdcVersionComparator.compare(geoVersion.getVersion(), targetVersion) < 0) {
log.info("Vdc {} version is less than {}", new Object[] { vdcId, targetVersion });
return false;
}
}
return true;
}
use of com.emc.storageos.db.client.model.VdcVersion in project coprhd-controller by CoprHD.
the class VdcUtil method getMinimalVdcVersion.
public static String getMinimalVdcVersion() {
List<URI> vdcIds = getVdcIds();
List<URI> geoVerIds = dbClient.queryByType(VdcVersion.class, true);
List<VdcVersion> geoVersions = dbClient.queryObject(VdcVersion.class, geoVerIds);
if (!hasAnyGeoVersion(geoVersions)) {
log.info("GeoVersion doesn't exist, return default version");
return DbConfigConstants.DEFAULT_VDC_DB_VERSION;
}
if (missVersionFor(vdcIds, geoVersions)) {
log.info("GeoVersion not exist for vdcs, return default version");
return DbConfigConstants.DEFAULT_VDC_DB_VERSION;
}
String minimalVersion = null;
for (VdcVersion geoVersion : geoVersions) {
if ((minimalVersion == null) || (VdcVersionComparator.compare(minimalVersion, geoVersion.getVersion()) > 0)) {
minimalVersion = geoVersion.getVersion();
}
}
log.info("minimal Geo version {}", minimalVersion);
return minimalVersion;
}
use of com.emc.storageos.db.client.model.VdcVersion in project coprhd-controller by CoprHD.
the class VdcUtilTest method shouldReturnMinimalVersionInVdcVersions.
@Test
public void shouldReturnMinimalVersionInVdcVersions() {
List<VdcVersion> geoVersions = new ArrayList<VdcVersion>();
List<URI> vdcIds = new ArrayList<URI>();
geoVersions.add(VDC1_GEO_VERSION);
geoVersions.add(VDC2_GEO_VERSION);
geoVersions.add(VDC3_GEO_VERSION);
vdcIds.add(VDC1_ID);
vdcIds.add(VDC2_ID);
vdcIds.add(VDC3_ID);
DbClient dbClientMock = EasyMock.createMock(DbClient.class);
EasyMock.expect(dbClientMock.queryByType(VdcVersion.class, true)).andReturn(new ArrayList<URI>());
EasyMock.expect(dbClientMock.queryObject(VdcVersion.class, new ArrayList<URI>())).andReturn(geoVersions);
EasyMock.expect(dbClientMock.queryByType(VirtualDataCenter.class, true)).andReturn(vdcIds);
EasyMock.replay(dbClientMock);
VdcUtil.setDbClient(dbClientMock);
String minialVdcVersion = VdcUtil.getMinimalVdcVersion();
String expectedVdcVersion = DbConfigConstants.DEFAULT_VDC_DB_VERSION;
Assert.assertEquals(expectedVdcVersion, minialVdcVersion);
}
Aggregations