/** * Perform a upgrade using the test image corresponding to * testCaseName. * * @param testCaseName * @param expectedStorageId if null, then the upgrade generates a new * unique storage ID. * @throws IOException */ private static void runLayoutUpgradeTest(final String testCaseName, final String expectedStorageId) throws IOException { TestDFSUpgradeFromImage upgrade = new TestDFSUpgradeFromImage(); upgrade.unpackStorage(testCaseName + ".tgz", testCaseName + ".txt"); Configuration conf = new Configuration(TestDFSUpgradeFromImage.upgradeConf); initStorageDirs(conf, testCaseName); upgradeAndVerify(upgrade, conf, new ClusterVerifier() { @Override public void verifyClusterPostUpgrade(MiniDFSCluster cluster) throws IOException { // Verify that a GUID-based storage ID was generated. final String bpid = cluster.getNamesystem().getBlockPoolId(); StorageReport[] reports = cluster.getDataNodes().get(0).getFSDataset().getStorageReports(bpid); assertThat(reports.length, is(1)); final String storageID = reports[0].getStorage().getStorageID(); assertTrue(DatanodeStorage.isValidStorageId(storageID)); if (expectedStorageId != null) { assertThat(storageID, is(expectedStorageId)); } } }); }
private static void upgradeAndVerify(final TestDFSUpgradeFromImage upgrade, final Configuration conf, final ClusterVerifier verifier) throws IOException{ upgrade.upgradeAndVerify(new MiniDFSCluster.Builder(conf) .numDataNodes(1) .manageDataDfsDirs(false) .manageNameDfsDirs(false), verifier); }