Search in sources :

Example 61 with Start

use of io.fabric8.arquillian.kubernetes.event.Start in project fabric8 by jboss-fuse.

the class GitPatchManagementServiceImpl method alignTo.

@Override
public boolean alignTo(Map<String, String> versions, List<String> urls, File localMavenRepository, Runnable callback) throws PatchException {
    if (aligning.getAndSet(true)) {
        return false;
    }
    try {
        if (!env.isFabric()) {
            try {
                // we probably survived fabric:create without refreshing patch-management bundle
                env = envService.determineEnvironmentType();
                File patchRepositoryLocation = new File(patchesDir, GitPatchRepositoryImpl.MAIN_GIT_REPO_LOCATION);
                getGitPatchRepository().close();
                GitPatchRepositoryImpl repository = new GitPatchRepositoryImpl(env, patchRepositoryLocation, karafHome, karafBase, karafData, patchesDir);
                setGitPatchRepository(repository);
                start();
                // let's tweak the configuration when entering fabric mode
                // this way we will track other kinds of baselines
                ensurePatchManagementInitialized();
                if (master) {
                    // let the caller know that we've configured patch management in "master" container
                    // this is mainly to push the changes from local to cluster git repository
                    // so child/ssh containers created in fabric can fetch correct baselines
                    callback.run();
                }
            } catch (Exception e) {
                throw new PatchException(e.getMessage(), e);
            }
        }
        if (env.isFabric()) {
            Git fork = null;
            try {
                ensuringLock.lock();
                String version = versions.get(env.getProductId());
                String tagName = String.format(env.getBaselineTagFormat(), version);
                // we have to be at that tag
                Git mainRepository = gitPatchRepository.findOrCreateMainGitRepository();
                fetchFabricPatchData(mainRepository);
                fork = gitPatchRepository.cloneRepository(mainRepository, true);
                gitPatchRepository.checkout(fork).setName(gitPatchRepository.getMainBranchName()).call();
                RevTag tag = gitPatchRepository.findCurrentBaseline(fork);
                if (tag != null && tagName.equals(tag.getTagName())) {
                    if (master) {
                        // and then to data/git/servlet
                        try {
                            gitPatchRepository.pushPatchBranches();
                            callback.run();
                        } catch (Exception e) {
                            Activator.log(LogService.LOG_WARNING, null, e.getMessage(), e, false);
                        } catch (Error e) {
                            // in case newer patch management calls agent which is still wired to old patch management
                            Activator.log(LogService.LOG_WARNING, null, e.getMessage(), e, false);
                        }
                    }
                    return false;
                }
                boolean baselineSwitched = handleNonCurrentBaseline(fork, version, tagName, false, true);
                if (localMavenRepository != null) {
                    try {
                        File systemRepo = getSystemRepository(karafHome, systemContext);
                        // let's copy artifacts referenced in etc/startup.properties from localMavenRepository to system
                        File etcStartupProperties = new File(karafBase, "etc/startup.properties");
                        try (FileInputStream fis = new FileInputStream(etcStartupProperties)) {
                            Properties props = new Properties();
                            props.load(fis);
                            for (String artifact : props.stringPropertyNames()) {
                                File target = new File(systemRepo, artifact);
                                File src = new File(localMavenRepository, artifact);
                                if (!target.exists() && src.isFile()) {
                                    FileUtils.copyFile(src, target);
                                }
                            }
                        }
                        // now the URLs from the passed lis
                        for (String url : urls) {
                            String path = Utils.mvnurlToPath(url);
                            if (path != null) {
                                File target = new File(systemRepo, path);
                                File src = new File(localMavenRepository, path);
                                if (!target.exists() && src.isFile()) {
                                    FileUtils.copyFile(src, target);
                                }
                            }
                        }
                    } catch (Exception e) {
                        Activator.log(LogService.LOG_ERROR, null, e.getMessage(), e, false);
                    }
                }
                return baselineSwitched;
            } catch (Exception e) {
                throw new PatchException(e.getMessage(), e);
            } finally {
                ensuringLock.unlock();
                if (fork != null) {
                    gitPatchRepository.closeRepository(fork, true);
                }
            }
        }
        return false;
    } finally {
        aligning.set(false);
    }
}
Also used : Git(org.eclipse.jgit.api.Git) RevTag(org.eclipse.jgit.revwalk.RevTag) PatchException(io.fabric8.patch.management.PatchException) Properties(java.util.Properties) ZipFile(org.apache.commons.compress.archivers.zip.ZipFile) File(java.io.File) PatchException(io.fabric8.patch.management.PatchException) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) FileInputStream(java.io.FileInputStream)

Example 62 with Start

use of io.fabric8.arquillian.kubernetes.event.Start in project fabric8 by jboss-fuse.

the class ServiceImpl method featureUpdatesInPatch.

/**
 * Returns a list of {@link FeatureUpdate} for single patch, taking into account already discovered updates
 * @param patch
 * @param updatesForFeatureKeys
 * @param kind
 * @return
 */
private List<FeatureUpdate> featureUpdatesInPatch(Patch patch, Map<String, FeatureUpdate> updatesForFeatureKeys, PatchKind kind) throws Exception {
    Set<String> addedRepositoryNames = new HashSet<>();
    HashMap<String, Repository> after = null;
    try {
        List<FeatureUpdate> updatesInThisPatch = new LinkedList<>();
        /*
             * Two pairs of features makes feature names not enough to be a key:
             * <feature name="openjpa" description="Apache OpenJPA 2.2.x persistent engine support" version="2.2.2" resolver="(obr)">
             * <feature name="openjpa" description="Apache OpenJPA 2.3.x persistence engine support" version="2.3.0" resolver="(obr)">
             * and
             * <feature name="activemq-camel" version="5.11.0.redhat-621039" resolver="(obr)" start-level="50">
             * <feature name="activemq-camel" version="1.2.0.redhat-621039" resolver="(obr)">
             */
        // install the new feature repos, tracking the set the were
        // installed before and after
        // (e.g, "karaf-enterprise-2.4.0.redhat-620133" -> Repository)
        Map<String, Repository> before = new HashMap<>(getAvailableFeatureRepositories());
        for (String url : patch.getPatchData().getFeatureFiles()) {
            featuresService.addRepository(new URI(url));
        }
        after = getAvailableFeatureRepositories();
        // track which old repos provide which features to find out if we have new repositories for those features
        // key is name|version (don't expect '|' to be part of name...)
        // assume that [feature-name, feature-version{major,minor,0,0}] is defined only in single repository
        Map<String, String> featuresInOldRepositories = new HashMap<>();
        // key is only name, without version - used when there's single feature in old and in new repositories
        MultiMap<String, String> singleFeaturesInOldRepositories = new MultiMap<>();
        Map<String, Version> actualOldFeatureVersions = new HashMap<>();
        for (Repository existingRepository : before.values()) {
            for (Feature feature : existingRepository.getFeatures()) {
                Version v = Utils.getOsgiVersion(feature.getVersion());
                Version lowestUpdateableVersion = new Version(v.getMajor(), v.getMinor(), 0);
                // assume that we can update feature XXX-2.2.3 to XXX-2.2.142, but not to XXX-2.3.0.alpha-1
                String key = String.format("%s|%s", feature.getName(), lowestUpdateableVersion.toString());
                featuresInOldRepositories.put(key, existingRepository.getURI().toString());
                singleFeaturesInOldRepositories.put(feature.getName(), existingRepository.getURI().toString());
                actualOldFeatureVersions.put(key, v);
            }
        }
        // Use the before and after set to figure out which repos were added.
        addedRepositoryNames = new HashSet<>(after.keySet());
        addedRepositoryNames.removeAll(before.keySet());
        // track the new repositories where we can find old features
        Map<String, String> featuresInNewRepositories = new HashMap<>();
        MultiMap<String, String> singleFeaturesInNewRepositories = new MultiMap<>();
        Map<String, String> actualNewFeatureVersions = new HashMap<>();
        MultiMap<String, String> singleActualNewFeatureVersions = new MultiMap<>();
        // Figure out which old repos were updated:  Do they have feature
        // with the same name as one contained in a repo being added?
        // and do they have update'able version? (just like with bundles)
        Set<String> oldRepositoryNames = new HashSet<String>();
        for (String addedRepositoryName : addedRepositoryNames) {
            Repository added = after.get(addedRepositoryName);
            for (Feature feature : added.getFeatures()) {
                Version v = Utils.getOsgiVersion(feature.getVersion());
                Version lowestUpdateableVersion = new Version(v.getMajor(), v.getMinor(), 0);
                String key = String.format("%s|%s", feature.getName(), lowestUpdateableVersion.toString());
                featuresInNewRepositories.put(key, addedRepositoryName);
                singleFeaturesInNewRepositories.put(feature.getName(), addedRepositoryName);
                actualNewFeatureVersions.put(key, v.toString());
                singleActualNewFeatureVersions.put(feature.getName(), v.toString());
                String oldRepositoryWithUpdateableFeature = featuresInOldRepositories.get(key);
                if (oldRepositoryWithUpdateableFeature == null && singleFeaturesInOldRepositories.get(feature.getName()) != null && singleFeaturesInOldRepositories.get(feature.getName()).size() == 1) {
                    oldRepositoryWithUpdateableFeature = singleFeaturesInOldRepositories.get(feature.getName()).get(0);
                }
                if (oldRepositoryWithUpdateableFeature != null) {
                    // track the old repository to be removed
                    oldRepositoryNames.add(oldRepositoryWithUpdateableFeature);
                }
            }
        }
        // We need to uninstall them. Before we uninstall, track which features were installed.
        for (String oldRepositoryName : oldRepositoryNames) {
            Repository repository = before.get(oldRepositoryName);
            for (Feature feature : repository.getFeatures()) {
                if (featuresService.isInstalled(feature)) {
                    Version v = Utils.getOsgiVersion(feature.getVersion());
                    Version lowestUpdateableVersion = new Version(v.getMajor(), v.getMinor(), 0);
                    String key = String.format("%s|%s", feature.getName(), lowestUpdateableVersion.toString());
                    String newRepositoryName = featuresInNewRepositories.get(key);
                    String newVersion = actualNewFeatureVersions.get(key);
                    if (newRepositoryName == null) {
                        // feature from 1.1.1 to 1.3.0
                        if (singleFeaturesInOldRepositories.get(feature.getName()) != null && singleFeaturesInOldRepositories.get(feature.getName()).size() == 1 && singleFeaturesInNewRepositories.get(feature.getName()) != null && singleFeaturesInNewRepositories.get(feature.getName()).size() == 1) {
                            newRepositoryName = singleFeaturesInNewRepositories.get(feature.getName()).get(0);
                        }
                    }
                    if (newVersion == null) {
                        if (singleActualNewFeatureVersions.get(feature.getName()) != null && singleActualNewFeatureVersions.get(feature.getName()).size() == 1) {
                            newVersion = singleActualNewFeatureVersions.get(feature.getName()).get(0);
                        }
                    }
                    FeatureUpdate featureUpdate = null;
                    if (newVersion != null && newRepositoryName != null) {
                        featureUpdate = new FeatureUpdate(feature.getName(), after.get(oldRepositoryName).getURI().toString(), feature.getVersion(), after.get(newRepositoryName).getURI().toString(), newVersion);
                    } else {
                        // we didn't find an update for installed features among feature repositories from patch
                        // which means we have to preserve both the feature and the repository - this may
                        // be user's feature
                        featureUpdate = new FeatureUpdate(feature.getName(), after.get(oldRepositoryName).getURI().toString(), feature.getVersion(), null, null);
                    }
                    updatesInThisPatch.add(featureUpdate);
                    // Merge result
                    FeatureUpdate oldUpdate = updatesForFeatureKeys.get(key);
                    if (oldUpdate != null) {
                        Version upv = null, newV = null;
                        if (oldUpdate.getNewVersion() != null) {
                            upv = VersionTable.getVersion(oldUpdate.getNewVersion());
                        }
                        if (newVersion != null) {
                            newV = VersionTable.getVersion(newVersion);
                        }
                        if (upv == null && newV == null) {
                        // weird...
                        } else {
                            if (upv == null || (newV != null && upv.compareTo(newV) < 0)) {
                                // other patch contains newer update for the feature
                                updatesForFeatureKeys.put(key, featureUpdate);
                            }
                        }
                    } else {
                        // this is the first update of the bundle
                        updatesForFeatureKeys.put(key, featureUpdate);
                    }
                }
            }
        }
        // now let's see if there are repositories that are NOT updated (either they're not available in patch
        // (like user feature repositories) or simply didn't change (like jclouds 1.8.1 between Fuse 6.2 and 6.2.1)
        Set<String> unchangedRepositoryNames = new HashSet<>(before.keySet());
        unchangedRepositoryNames.removeAll(oldRepositoryNames);
        for (String unchangedRepositoryName : unchangedRepositoryNames) {
            Repository repository = before.get(unchangedRepositoryName);
            boolean hasInstalledFeatures = false;
            for (Feature feature : repository.getFeatures()) {
                if (featuresService.isInstalled(feature)) {
                    FeatureUpdate featureUpdate = new FeatureUpdate(feature.getName(), after.get(unchangedRepositoryName).getURI().toString(), feature.getVersion(), null, null);
                    hasInstalledFeatures = true;
                    // preserve unchanged/user feature - install after restart
                    updatesInThisPatch.add(featureUpdate);
                    // the key doesn't matter
                    updatesForFeatureKeys.put(String.format("%s|%s", feature.getName(), feature.getVersion()), featureUpdate);
                }
            }
            if (!hasInstalledFeatures) {
                // we have to preserve unchanged/user feature repository - even if it had no installed features
                // this featureUpdate means - "restore feature repository only"
                FeatureUpdate featureUpdate = new FeatureUpdate(null, after.get(unchangedRepositoryName).getURI().toString(), null, null, null);
                updatesInThisPatch.add(featureUpdate);
                updatesForFeatureKeys.put(String.format("REPOSITORY_TO_ADD:%s", after.get(unchangedRepositoryName).getURI().toString()), featureUpdate);
            }
        }
        return updatesInThisPatch;
    } catch (Exception e) {
        throw new PatchException(e.getMessage(), e);
    } finally {
        // we'll add new feature repositories again later. here we've added them only to track the updates
        if (after != null) {
            for (String repo : addedRepositoryNames) {
                if (after.get(repo) != null) {
                    featuresService.removeRepository(after.get(repo).getURI(), false);
                }
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) URI(java.net.URI) Feature(org.apache.karaf.features.Feature) LinkedList(java.util.LinkedList) URISyntaxException(java.net.URISyntaxException) PatchException(io.fabric8.patch.management.PatchException) BundleException(org.osgi.framework.BundleException) IOException(java.io.IOException) Repository(org.apache.karaf.features.Repository) Version(org.osgi.framework.Version) PatchException(io.fabric8.patch.management.PatchException) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) FeatureUpdate(io.fabric8.patch.management.FeatureUpdate)

Example 63 with Start

use of io.fabric8.arquillian.kubernetes.event.Start in project fabric8 by jboss-fuse.

the class ServiceImpl method applyChanges.

private void applyChanges(Map<Bundle, String> toUpdate) throws BundleException, IOException {
    List<Bundle> toStop = new ArrayList<Bundle>();
    Map<Bundle, String> lessToUpdate = new HashMap<>();
    for (Bundle b : toUpdate.keySet()) {
        if (b.getState() != Bundle.UNINSTALLED) {
            toStop.add(b);
            lessToUpdate.put(b, toUpdate.get(b));
        }
    }
    while (!toStop.isEmpty()) {
        List<Bundle> bs = getBundlesToDestroy(toStop);
        for (Bundle bundle : bs) {
            String hostHeader = bundle.getHeaders().get(Constants.FRAGMENT_HOST);
            if (hostHeader == null && (bundle.getState() == Bundle.ACTIVE || bundle.getState() == Bundle.STARTING)) {
                if (!"org.ops4j.pax.url.mvn".equals(bundle.getSymbolicName())) {
                    bundle.stop();
                }
            }
            toStop.remove(bundle);
        }
    }
    // eagerly load some classes
    try {
        getClass().getClassLoader().loadClass(Parser.class.getName());
        getClass().getClassLoader().loadClass(Clause.class.getName());
        getClass().getClassLoader().loadClass(Attribute.class.getName());
        getClass().getClassLoader().loadClass(Directive.class.getName());
        getClass().getClassLoader().loadClass(RefreshListener.class.getName());
    } catch (Exception ignored) {
    }
    Set<Bundle> toRefresh = new HashSet<Bundle>();
    Set<Bundle> toStart = new HashSet<Bundle>();
    for (Map.Entry<Bundle, String> e : lessToUpdate.entrySet()) {
        Bundle bundle = e.getKey();
        if (!"org.ops4j.pax.url.mvn".equals(bundle.getSymbolicName())) {
            System.out.println("updating: " + bundle.getSymbolicName());
            try {
                BundleUtils.update(bundle, new URL(e.getValue()));
            } catch (BundleException ex) {
                System.err.println("Failed to update: " + bundle.getSymbolicName() + ", due to: " + e);
            }
            toStart.add(bundle);
            toRefresh.add(bundle);
        }
    }
    findBundlesWithOptionalPackagesToRefresh(toRefresh);
    findBundlesWithFragmentsToRefresh(toRefresh);
    if (!toRefresh.isEmpty()) {
        final CountDownLatch l = new CountDownLatch(1);
        FrameworkListener listener = new RefreshListener(l);
        FrameworkWiring wiring = bundleContext.getBundle(0).adapt(FrameworkWiring.class);
        wiring.refreshBundles(toRefresh, listener);
        try {
            l.await();
        } catch (InterruptedException e) {
            throw new PatchException("Bundle refresh interrupted", e);
        }
    }
    for (Bundle bundle : toStart) {
        String hostHeader = bundle.getHeaders().get(Constants.FRAGMENT_HOST);
        if (hostHeader == null) {
            try {
                bundle.start();
            } catch (BundleException e) {
                System.err.println("Failed to start: " + bundle.getSymbolicName() + ", due to: " + e);
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Attribute(org.apache.felix.utils.manifest.Attribute) Bundle(org.osgi.framework.Bundle) ArrayList(java.util.ArrayList) FrameworkWiring(org.osgi.framework.wiring.FrameworkWiring) CountDownLatch(java.util.concurrent.CountDownLatch) URISyntaxException(java.net.URISyntaxException) PatchException(io.fabric8.patch.management.PatchException) BundleException(org.osgi.framework.BundleException) IOException(java.io.IOException) URL(java.net.URL) Parser(org.apache.felix.utils.manifest.Parser) Clause(org.apache.felix.utils.manifest.Clause) BundleException(org.osgi.framework.BundleException) PatchException(io.fabric8.patch.management.PatchException) FrameworkListener(org.osgi.framework.FrameworkListener) Directive(org.apache.felix.utils.manifest.Directive) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 64 with Start

use of io.fabric8.arquillian.kubernetes.event.Start in project fabric8 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.ADMIN_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.ADMIN_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-6.2.0"));
    assertTrue(repository.containsTag(fork, "baseline-child-2.4.0.redhat-620133"));
    assertFalse(repository.containsTag(fork, "patch-my-patch-1-child"));
    String binStart = FileUtils.readFileToString(new File(karafHome, "bin/start"));
    assertTrue("bin/start should be at previous version", binStart.contains("echo \"This is user's change\""));
}
Also used : GitPatchManagementServiceImpl(io.fabric8.patch.management.impl.GitPatchManagementServiceImpl) Git(org.eclipse.jgit.api.Git) ObjectId(org.eclipse.jgit.lib.ObjectId) GitPatchRepository(io.fabric8.patch.management.impl.GitPatchRepository) File(java.io.File) Test(org.junit.Test)

Example 65 with Start

use of io.fabric8.arquillian.kubernetes.event.Start in project fabric8 by jboss-fuse.

the class GitPatchManagementServiceForStandaloneChildContainersIT method installRollupPatch.

@Test
public void installRollupPatch() throws IOException, GitAPIException {
    initializationPerformedBaselineDistributionFoundInPatches();
    freshKarafStandaloneDistro();
    PatchManagement management = (PatchManagement) pm;
    GitPatchRepository repository = ((GitPatchManagementServiceImpl) pm).getGitPatchRepository();
    Git fork = repository.cloneRepository(repository.findOrCreateMainGitRepository(), true);
    repository.prepareCommit(fork, "artificial change, not treated as user change (could be a patch)").call();
    repository.prepareCommit(fork, "artificial change, not treated as user change").call();
    // no changes, but commit
    ((GitPatchManagementServiceImpl) pm).applyUserChanges(fork);
    FileUtils.write(new File(karafBase, "bin/start"), "echo \"another user change\"\n", true);
    // conflicting change, but commit
    ((GitPatchManagementServiceImpl) pm).applyUserChanges(fork);
    FileUtils.write(new File(karafBase, "bin/test"), "echo \"another user change\"\n");
    // non-conflicting
    ((GitPatchManagementServiceImpl) pm).applyUserChanges(fork);
    repository.closeRepository(fork, true);
    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-7.zip").toURI().toURL());
    Patch patch = management.trackPatch(patches.get(0));
    String tx = management.beginInstallation(PatchKind.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-2.4.0.redhat-620133^{commit}");
    ObjectId to = fork.getRepository().resolve(tx);
    Iterable<RevCommit> commits = fork.log().addRange(since, to).call();
    // only one "user change", because we had two conflicts with new baseline - they were resolved
    // by picking what already comes from rollup patch ("ours"):
    /*
         * Problem with applying the change 657f11c4b65bb7893a2b82f888bb9731a6d5f7d0:
         *  - bin/start: BOTH_MODIFIED
         * Choosing "ours" change
         * Problem with applying the change d9272b97582582f4b056f7170130ec91fc21aeac:
         *  - bin/start: BOTH_MODIFIED
         * Choosing "ours" change
         */
    List<String> commitList = Arrays.asList("[PATCH] Apply user changes", "[PATCH] Apply user changes", "[PATCH] Apply user changes", "[PATCH] Rollup patch patch-7 - resetting etc/overrides.properties", "[PATCH/baseline] Installing baseline-child-2.4.0.redhat-621084");
    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-6.2.0"));
    assertFalse(repository.containsTag(fork, "baseline-6.2.0.redhat-002"));
    assertTrue(repository.containsTag(fork, "baseline-child-2.4.0.redhat-620133"));
    assertTrue(repository.containsTag(fork, "baseline-child-2.4.0.redhat-621084"));
}
Also used : ObjectId(org.eclipse.jgit.lib.ObjectId) GitPatchRepository(io.fabric8.patch.management.impl.GitPatchRepository) GitPatchManagementServiceImpl(io.fabric8.patch.management.impl.GitPatchManagementServiceImpl) Git(org.eclipse.jgit.api.Git) File(java.io.File) Map(java.util.Map) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)27 Test (org.junit.Test)25 File (java.io.File)18 HashMap (java.util.HashMap)16 Map (java.util.Map)10 Git (org.eclipse.jgit.api.Git)10 ArrayList (java.util.ArrayList)9 GitPatchRepository (io.fabric8.patch.management.impl.GitPatchRepository)8 Bundle (org.osgi.framework.Bundle)8 PatchException (io.fabric8.patch.management.PatchException)7 URISyntaxException (java.net.URISyntaxException)7 BundleException (org.osgi.framework.BundleException)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 CuratorFramework (org.apache.curator.framework.CuratorFramework)6 Container (io.fabric8.api.Container)5 CreateContainerMetadata (io.fabric8.api.CreateContainerMetadata)5 FabricService (io.fabric8.api.FabricService)5 GitPatchManagementServiceImpl (io.fabric8.patch.management.impl.GitPatchManagementServiceImpl)5 HashSet (java.util.HashSet)5 ObjectId (org.eclipse.jgit.lib.ObjectId)5