use of org.jboss.fuse.patch.management.impl.GitPatchManagementServiceImpl in project fuse-karaf by jboss-fuse.
the class GitPatchManagementServiceForStandaloneChildContainersIT method rollbackInstalledNonRollupPatch.
@Test
public void rollbackInstalledNonRollupPatch() throws IOException, GitAPIException {
initializationPerformedBaselineDistributionFoundInPatches();
freshKarafStandaloneDistro();
PatchManagement management = (PatchManagement) pm;
GitPatchRepository repository = ((GitPatchManagementServiceImpl) pm).getGitPatchRepository();
preparePatchZip("src/test/resources/content/patch1", "target/karaf/patches/source/patch-1.zip", false);
List<PatchData> patches = management.fetchPatches(new File("target/karaf/patches/source/patch-1.zip").toURI().toURL());
Patch patch = management.trackPatch(patches.get(0));
Git fork = repository.cloneRepository(repository.findOrCreateMainGitRepository(), true);
ObjectId master1 = fork.getRepository().resolve(GitPatchRepository.INSTANCE_HISTORY_BRANCH + "-child");
String tx = management.beginInstallation(PatchKind.NON_ROLLUP);
management.install(tx, patch, null);
management.commitInstallation(tx);
fork = repository.cloneRepository(repository.findOrCreateMainGitRepository(), true);
assertTrue(repository.containsTag(fork, "patch-my-patch-1-child"));
repository.closeRepository(fork, true);
management.rollback(patch.getPatchData());
repository.closeRepository(fork, true);
fork = repository.cloneRepository(repository.findOrCreateMainGitRepository(), true);
ObjectId master2 = fork.getRepository().resolve(GitPatchRepository.INSTANCE_HISTORY_BRANCH + "-child");
assertThat(master1, not(equalTo(master2)));
assertThat(fork.tagList().call().size(), equalTo(3));
assertTrue(repository.containsTag(fork, "patch-management"));
assertTrue(repository.containsTag(fork, "baseline-7.0.0"));
assertTrue(repository.containsTag(fork, "baseline-child-4.2.0.redhat-700001"));
assertFalse(repository.containsTag(fork, "patch-my-patch-1-child"));
String binStart = FileUtils.readFileToString(new File(karafHome, "bin/start"), "UTF-8");
assertTrue("bin/start should be at previous version", binStart.contains("echo \"This is user's change\""));
}
use of org.jboss.fuse.patch.management.impl.GitPatchManagementServiceImpl in project fuse-karaf by jboss-fuse.
the class GitPatchManagementServiceForStandaloneChildContainersIT method installNonRollupPatch.
@Test
public void installNonRollupPatch() throws IOException, GitAPIException {
initializationPerformedBaselineDistributionFoundInPatches();
freshKarafStandaloneDistro();
PatchManagement management = (PatchManagement) pm;
GitPatchRepository repository = ((GitPatchManagementServiceImpl) pm).getGitPatchRepository();
Git fork = repository.cloneRepository(repository.findOrCreateMainGitRepository(), true);
// no changes, but commit
((GitPatchManagementServiceImpl) pm).applyUserChanges(fork);
repository.prepareCommit(fork, "artificial change, not treated as user change (could be a patch)").call();
repository.push(fork);
FileUtils.write(new File(karafBase, "bin/shutdown"), "#!/bin/bash\nexit 42", "UTF-8");
((GitPatchManagementServiceImpl) pm).applyUserChanges(fork);
repository.closeRepository(fork, true);
preparePatchZip("src/test/resources/content/patch1", "target/karaf/patches/source/patch-1.zip", false);
List<PatchData> patches = management.fetchPatches(new File("target/karaf/patches/source/patch-1.zip").toURI().toURL());
Patch patch = management.trackPatch(patches.get(0));
String tx = management.beginInstallation(PatchKind.NON_ROLLUP);
management.install(tx, patch, null);
@SuppressWarnings("unchecked") Map<String, Git> transactions = (Map<String, Git>) getField(management, "pendingTransactions");
assertThat(transactions.size(), equalTo(1));
fork = transactions.values().iterator().next();
ObjectId since = fork.getRepository().resolve("baseline-child-4.2.0.redhat-700001^{commit}");
ObjectId to = fork.getRepository().resolve(tx);
Iterable<RevCommit> commits = fork.log().addRange(since, to).call();
List<String> commitList = Arrays.asList("[PATCH] Installing patch my-patch-1", "[PATCH] Apply user changes", "artificial change, not treated as user change (could be a patch)", "[PATCH] Apply user changes");
int n = 0;
for (RevCommit c : commits) {
String msg = c.getShortMessage();
assertThat(msg, equalTo(commitList.get(n++)));
}
assertThat(n, equalTo(commitList.size()));
assertThat(fork.tagList().call().size(), equalTo(4));
assertTrue(repository.containsTag(fork, "patch-management"));
assertTrue(repository.containsTag(fork, "baseline-7.0.0"));
assertTrue(repository.containsTag(fork, "baseline-child-4.2.0.redhat-700001"));
assertFalse(repository.containsTag(fork, "patch-my-patch-1"));
assertTrue(repository.containsTag(fork, "patch-my-patch-1-child"));
assertThat("The conflict should be resolved in special way", FileUtils.readFileToString(new File(karafHome, "bin/setenv"), "UTF-8"), equalTo("JAVA_MIN_MEM=2G # Minimum memory for the JVM\n"));
}
use of org.jboss.fuse.patch.management.impl.GitPatchManagementServiceImpl in project fuse-karaf by jboss-fuse.
the class GitPatchManagementServiceForStandaloneChildContainersIT method init.
@Before
public void init() throws IOException, GitAPIException {
super.init(true, true);
bsl = mock(BundleStartLevel.class);
when(bundle.adapt(BundleStartLevel.class)).thenReturn(bsl);
when(systemContext.getDataFile("patches")).thenReturn(new File(karafHome, "data/cache/bundle0/data/patches"));
// root container's part - initialization of baselines
freshKarafStandaloneDistro();
FileUtils.copyFile(new File("src/test/resources/karaf2/system/org/apache/karaf/instance/org.apache.karaf.instance.core/4.2.0.redhat-700001/org.apache.karaf.instance.core-4.2.0.redhat-700001.jar"), new File(karafHome, "system/org/apache/karaf/instance/org.apache.karaf.instance.core/4.2.0.redhat-700001/org.apache.karaf.instance.core-4.2.0.redhat-700001.jar"));
preparePatchZip("src/test/resources/baselines/baseline3", "target/karaf/system/org/jboss/fuse/fuse-karaf/7.0.0/fuse-karaf-7.0.0-baseline.zip", true);
pm = new GitPatchManagementServiceImpl(bundleContext);
pm.start();
pm.ensurePatchManagementInitialized();
karafHome = new File("target/karaf");
karafBase = new File("target/karaf/instances/child");
super.init(false, false);
properties.setProperty("karaf.name", "child");
properties.setProperty("karaf.instances", properties.getProperty("karaf.home") + File.separatorChar + "instances");
}
use of org.jboss.fuse.patch.management.impl.GitPatchManagementServiceImpl in project fuse-karaf by jboss-fuse.
the class GitPatchManagementServiceForStandaloneChildContainersIT method rollbackInstalledRollupPatch.
@Test
public void rollbackInstalledRollupPatch() throws IOException, GitAPIException {
initializationPerformedBaselineDistributionFoundInPatches();
freshKarafStandaloneDistro();
PatchManagement management = (PatchManagement) pm;
GitPatchRepository repository = ((GitPatchManagementServiceImpl) pm).getGitPatchRepository();
preparePatchZip("src/test/resources/content/patch1", "target/karaf/patches/source/patch-1.zip", false);
preparePatchZip("src/test/resources/content/patch7", "target/karaf/patches/source/patch-7.zip", false);
List<PatchData> patches = management.fetchPatches(new File("target/karaf/patches/source/patch-1.zip").toURI().toURL());
Patch patch1 = management.trackPatch(patches.get(0));
patches = management.fetchPatches(new File("target/karaf/patches/source/patch-7.zip").toURI().toURL());
Patch patch7 = management.trackPatch(patches.get(0));
Git fork = repository.cloneRepository(repository.findOrCreateMainGitRepository(), true);
ObjectId master1 = fork.getRepository().resolve(GitPatchRepository.INSTANCE_HISTORY_BRANCH + "-child");
String tx = management.beginInstallation(PatchKind.ROLLUP);
management.install(tx, patch7, null);
management.commitInstallation(tx);
// install P patch to check if rolling back rollup patch will remove P patch's tag
tx = management.beginInstallation(PatchKind.NON_ROLLUP);
management.install(tx, patch1, null);
management.commitInstallation(tx);
fork = repository.cloneRepository(repository.findOrCreateMainGitRepository(), true);
assertFalse(repository.containsTag(fork, "patch-my-patch-1"));
assertTrue(repository.containsTag(fork, "patch-my-patch-1-child"));
assertTrue(repository.containsTag(fork, "baseline-child-4.2.0.redhat-700001"));
assertTrue(repository.containsTag(fork, "baseline-child-4.2.0.redhat-700002"));
management.rollback(patch7.getPatchData());
repository.closeRepository(fork, true);
fork = repository.cloneRepository(repository.findOrCreateMainGitRepository(), true);
ObjectId master2 = fork.getRepository().resolve(GitPatchRepository.INSTANCE_HISTORY_BRANCH + "-child");
assertThat(master1, not(equalTo(master2)));
assertThat(fork.tagList().call().size(), equalTo(4));
assertTrue(repository.containsTag(fork, "patch-management"));
assertFalse("P patch1 should be not visible as installed", repository.containsTag(fork, "patch-my-patch-1-child"));
assertTrue(repository.containsTag(fork, "baseline-7.0.0"));
assertTrue(repository.containsTag(fork, "baseline-child-4.2.0.redhat-700001"));
assertTrue(repository.containsTag(fork, "baseline-child-4.2.0.redhat-700002"));
assertFalse(repository.containsTag(fork, "baseline-child-4.2.0.redhat-700002-child"));
assertFalse("When rolling back rollup patch, newer P patches' tags should be removed", repository.containsTag(fork, "patch-my-patch-1"));
assertThat(repository.findCurrentBaseline(fork).getTagName(), equalTo("baseline-child-4.2.0.redhat-700001"));
}
use of org.jboss.fuse.patch.management.impl.GitPatchManagementServiceImpl in project fuse-karaf by jboss-fuse.
the class PatchManagementIT method init.
@Before
public void init() throws IOException, GitAPIException {
super.init(true, true);
pm = new GitPatchManagementServiceImpl(bundleContext);
((GitPatchManagementServiceImpl) pm).start();
// prepare some ZIP patches
preparePatchZip("src/test/resources/content/patch1", "target/karaf/patches/source/patch-1.zip", false);
preparePatchZip("src/test/resources/content/patch3", "target/karaf/patches/source/patch-3.zip", false);
}
Aggregations