Skip to content

Commit

Permalink
Merge branch '4.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
rohityadavcloud committed Sep 1, 2016
2 parents 1d9735c + 08edd0c commit da76553
Show file tree
Hide file tree
Showing 7 changed files with 669 additions and 83 deletions.
260 changes: 181 additions & 79 deletions engine/schema/src/com/cloud/upgrade/DatabaseUpgradeChecker.java

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions engine/schema/src/com/cloud/upgrade/dao/Upgrade490to491.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ public class Upgrade490to491 implements DbUpgrade {

@Override
public String[] getUpgradableVersionRange() {
return new String[] {"4.9.0", "4.9.1"};
return new String[] {"4.9.0", "4.9.1.0"};
}

@Override
public String getUpgradedVersion() {
return "4.9.1";
return "4.9.1.0";
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions engine/schema/src/com/cloud/upgrade/dao/Upgrade491to4100.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ public class Upgrade491to4100 implements DbUpgrade {

@Override
public String[] getUpgradableVersionRange() {
return new String[] {"4.9.1", "4.10.0"};
return new String[] {"4.9.1", "4.10.0.0"};
}

@Override
public String getUpgradedVersion() {
return "4.10.0";
return "4.10.0.0";
}

@Override
Expand Down
122 changes: 122 additions & 0 deletions engine/schema/test/com/cloud/upgrade/DatabaseUpgradeCheckerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.upgrade;

import com.cloud.upgrade.dao.DbUpgrade;
import com.cloud.upgrade.dao.Upgrade452to460;
import com.cloud.upgrade.dao.Upgrade460to461;
import com.cloud.upgrade.dao.Upgrade461to470;
import com.cloud.upgrade.dao.Upgrade470to471;
import com.cloud.upgrade.dao.Upgrade471to480;
import com.cloud.upgrade.dao.Upgrade480to481;
import com.cloud.upgrade.dao.Upgrade490to491;
import org.apache.cloudstack.utils.CloudStackVersion;
import org.junit.Test;

import java.util.Arrays;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class DatabaseUpgradeCheckerTest {

@Test
public void testCalculateUpgradePath480to481() {

final CloudStackVersion dbVersion = CloudStackVersion.parse("4.8.0");
assertNotNull(dbVersion);

final CloudStackVersion currentVersion = CloudStackVersion.parse("4.8.1");
assertNotNull(currentVersion);

final DatabaseUpgradeChecker checker = new DatabaseUpgradeChecker();
final DbUpgrade[] upgrades = checker.calculateUpgradePath(dbVersion, currentVersion);

assertNotNull(upgrades);
assertTrue(upgrades.length >= 1);
assertTrue(upgrades[0] instanceof Upgrade480to481);

}

@Test
public void testCalculateUpgradePath490to4910() {

final CloudStackVersion dbVersion = CloudStackVersion.parse("4.9.0");
assertNotNull(dbVersion);

final CloudStackVersion currentVersion = CloudStackVersion.parse("4.9.1.0");
assertNotNull(currentVersion);

final DatabaseUpgradeChecker checker = new DatabaseUpgradeChecker();
final DbUpgrade[] upgrades = checker.calculateUpgradePath(dbVersion, currentVersion);

assertNotNull(upgrades);
assertTrue(upgrades.length >= 1);
assertTrue(upgrades[0] instanceof Upgrade490to491);

assertTrue(Arrays.equals(new String[] { "4.9.0", currentVersion.toString()}, upgrades[0].getUpgradableVersionRange()));
assertEquals(currentVersion.toString(), upgrades[0].getUpgradedVersion());

}

@Test
public void testFindUpgradePath470to481() {

final CloudStackVersion dbVersion = CloudStackVersion.parse("4.7.0");
assertNotNull(dbVersion);

final CloudStackVersion currentVersion = CloudStackVersion.parse("4.8.1");
assertNotNull(currentVersion);

final DatabaseUpgradeChecker checker = new DatabaseUpgradeChecker();
final DbUpgrade[] upgrades = checker.calculateUpgradePath(dbVersion, currentVersion);

assertNotNull(upgrades);

assertTrue(upgrades[0] instanceof Upgrade470to471);
assertTrue(upgrades[1] instanceof Upgrade471to480);
assertTrue(upgrades[2] instanceof Upgrade480to481);

}

@Test
public void testFindUpgradePath452to490() {

final CloudStackVersion dbVersion = CloudStackVersion.parse("4.5.2");
assertNotNull(dbVersion);

final CloudStackVersion currentVersion = CloudStackVersion.parse("4.9.0");
assertNotNull(currentVersion);

final DatabaseUpgradeChecker checker = new DatabaseUpgradeChecker();
final DbUpgrade[] upgrades = checker.calculateUpgradePath(dbVersion, currentVersion);

assertNotNull(upgrades);

assertTrue(upgrades[0] instanceof Upgrade452to460);
assertTrue(upgrades[1] instanceof Upgrade460to461);
assertTrue(upgrades[2] instanceof Upgrade461to470);
assertTrue(upgrades[3] instanceof Upgrade470to471);
assertTrue(upgrades[4] instanceof Upgrade471to480);
assertTrue(upgrades[5] instanceof Upgrade480to481);

assertTrue(Arrays.equals(new String[] { "4.8.1", currentVersion.toString()}, upgrades[6].getUpgradableVersionRange()));
assertEquals(currentVersion.toString(), upgrades[6].getUpgradedVersion());

}
}
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<!-- do not forget to also upgrade hamcrest library with junit -->
<cs.junit.version>4.12</cs.junit.version>
<cs.hamcrest.version>1.3</cs.hamcrest.version>
<cs.junit.dataprovider.version>1.10.0</cs.junit.dataprovider.version>
<cs.bcprov.version>1.46</cs.bcprov.version>
<cs.jsch.version>0.1.53</cs.jsch.version>
<cs.jpa.version>2.1.1</cs.jpa.version>
Expand Down Expand Up @@ -514,6 +515,12 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.tngtech.java</groupId>
<artifactId>junit-dataprovider</artifactId>
<version>${cs.junit.dataprovider.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
Expand Down
Loading

0 comments on commit da76553

Please sign in to comment.