Search in sources :

Example 26 with Result

use of io.fabric8.insight.metrics.model.Result in project fabric8 by jboss-fuse.

the class DummyBatchingProgressMonitor method getVersionIds.

@Override
public List<String> getVersionIds(GitContext context) {
    LockHandle readLock = aquireReadLock();
    try {
        assertValid();
        GitOperation<List<String>> gitop = new GitOperation<List<String>>() {

            public List<String> call(Git git, GitContext context) throws Exception {
                List<String> result = new ArrayList<>(versions);
                // we do not want to expose master branch as a version
                if (result.contains(GitHelpers.MASTER_BRANCH)) {
                    result.remove(GitHelpers.MASTER_BRANCH);
                }
                Collections.sort(result, VersionSequence.getComparator());
                return Collections.unmodifiableList(result);
            }
        };
        return executeInternal(context, null, gitop);
    } finally {
        readLock.unlock();
    }
}
Also used : LockHandle(io.fabric8.api.LockHandle) Git(org.eclipse.jgit.api.Git) GitContext(io.fabric8.api.GitContext)

Example 27 with Result

use of io.fabric8.insight.metrics.model.Result in project fabric8 by jboss-fuse.

the class PushPullPolicyIT method noUpdates.

@Test
public void noUpdates() {
    PullPushPolicy.PullPolicyResult result = policy.doPull(new GitContext(), CP, true);
    assertNull(result.getLastException());
    List<String> versions = new ArrayList<>(result.getVersions());
    // these are sorted (TreeSet)
    assertThat(versions.get(0), equalTo("1.0"));
    assertThat(versions.get(1), equalTo("1.0.1"));
    assertThat(versions.get(2), equalTo("1.1"));
    assertThat(versions.get(3), equalTo("1.2"));
    assertThat(versions.get(4), equalTo("master"));
    assertTrue(result.localUpdateVersions().isEmpty());
    assertFalse(result.remoteUpdateRequired());
}
Also used : GitContext(io.fabric8.api.GitContext) ArrayList(java.util.ArrayList) DefaultPullPushPolicy(io.fabric8.git.internal.DefaultPullPushPolicy) Test(org.junit.Test)

Example 28 with Result

use of io.fabric8.insight.metrics.model.Result in project fabric8 by jboss-fuse.

the class PushPullPolicyIT method remoteRemovalOfSingleBranchWhenLocalBranchIsAheadAndNotCheckedOut.

@Test
public void remoteRemovalOfSingleBranchWhenLocalBranchIsAheadAndNotCheckedOut() throws GitAPIException, IOException {
    servlet.branchDelete().setForce(true).setBranchNames("1.1").call();
    local.checkout().setName("1.1").setCreateBranch(false).call();
    editVersion("1.1", 4, false);
    local.checkout().setName("1.0").setCreateBranch(false).call();
    PullPushPolicy.PullPolicyResult result = policy.doPull(new GitContext(), CP, true);
    assertNull(result.getLastException());
    List<String> versions = new ArrayList<>(result.getVersions());
    // these are sorted (TreeSet)
    assertThat(versions.size(), equalTo(4));
    assertThat(versions.get(0), equalTo("1.0"));
    assertThat(versions.get(1), equalTo("1.0.1"));
    assertThat(versions.get(2), equalTo("1.2"));
    assertThat(versions.get(3), equalTo("master"));
    List<String> localUpdateVersions = new ArrayList<>(result.localUpdateVersions().keySet());
    assertThat(localUpdateVersions.size(), equalTo(1));
    assertThat(localUpdateVersions.get(0), equalTo("1.1"));
    assertFalse(result.remoteUpdateRequired());
    List<Ref> localBranches = local.branchList().call();
    assertThat(localBranches.size(), equalTo(4));
    assertNull(local.getRepository().getRef("1.1"));
}
Also used : Ref(org.eclipse.jgit.lib.Ref) GitContext(io.fabric8.api.GitContext) ArrayList(java.util.ArrayList) DefaultPullPushPolicy(io.fabric8.git.internal.DefaultPullPushPolicy) Test(org.junit.Test)

Example 29 with Result

use of io.fabric8.insight.metrics.model.Result in project fabric8 by jboss-fuse.

the class PushPullPolicyIT method remoteUpdateWhenLocalBranchIsCheckedOutAndNotClean.

@Test
public void remoteUpdateWhenLocalBranchIsCheckedOutAndNotClean() throws GitAPIException, IOException {
    editVersion("1.1", 2, true);
    local.checkout().setName("1.1").setCreateBranch(false).call();
    FileUtils.write(new File(dirLocal, "newFile.txt"), "~");
    FileUtils.write(new File(dirLocal, "fabric/profiles/default.profile/my.special.pid.properties"), "\n# new line", true);
    assertFalse(local.status().call().isClean());
    PullPushPolicy.PullPolicyResult result = policy.doPull(new GitContext(), CP, true);
    assertNull(result.getLastException());
    List<String> versions = new ArrayList<>(result.getVersions());
    // these are sorted (TreeSet)
    assertThat(versions.size(), equalTo(5));
    assertThat(versions.get(0), equalTo("1.0"));
    assertThat(versions.get(1), equalTo("1.0.1"));
    assertThat(versions.get(2), equalTo("1.1"));
    assertThat(versions.get(3), equalTo("1.2"));
    assertThat(versions.get(4), equalTo("master"));
    List<String> localUpdateVersions = new ArrayList<>(result.localUpdateVersions().keySet());
    assertThat(localUpdateVersions.size(), equalTo(1));
    assertThat(localUpdateVersions.get(0), equalTo("1.1"));
    assertFalse(result.remoteUpdateRequired());
    List<Ref> localBranches = local.branchList().call();
    assertThat(localBranches.size(), equalTo(5));
    assertNotNull(local.getRepository().getRef("1.1"));
}
Also used : Ref(org.eclipse.jgit.lib.Ref) GitContext(io.fabric8.api.GitContext) ArrayList(java.util.ArrayList) DefaultPullPushPolicy(io.fabric8.git.internal.DefaultPullPushPolicy) File(java.io.File) Test(org.junit.Test)

Example 30 with Result

use of io.fabric8.insight.metrics.model.Result in project fabric8 by jboss-fuse.

the class PushPullPolicyIT method remoteRemovalOfSingleBranchWhenLocalBranchIsAheadAndCheckedOut.

@Test
public void remoteRemovalOfSingleBranchWhenLocalBranchIsAheadAndCheckedOut() throws GitAPIException, IOException {
    servlet.branchDelete().setForce(true).setBranchNames("1.1").call();
    editVersion("1.1", 4, false);
    local.checkout().setName("1.1").setCreateBranch(false).call();
    PullPushPolicy.PullPolicyResult result = policy.doPull(new GitContext(), CP, true);
    assertNull(result.getLastException());
    List<String> versions = new ArrayList<>(result.getVersions());
    // these are sorted (TreeSet)
    assertThat(versions.size(), equalTo(4));
    assertThat(versions.get(0), equalTo("1.0"));
    assertThat(versions.get(1), equalTo("1.0.1"));
    assertThat(versions.get(2), equalTo("1.2"));
    assertThat(versions.get(3), equalTo("master"));
    List<String> localUpdateVersions = new ArrayList<>(result.localUpdateVersions().keySet());
    assertThat(localUpdateVersions.size(), equalTo(1));
    assertThat(localUpdateVersions.get(0), equalTo("1.1"));
    assertFalse(result.remoteUpdateRequired());
    List<Ref> localBranches = local.branchList().call();
    assertThat(localBranches.size(), equalTo(4));
    assertNull(local.getRepository().getRef("1.1"));
}
Also used : Ref(org.eclipse.jgit.lib.Ref) GitContext(io.fabric8.api.GitContext) ArrayList(java.util.ArrayList) DefaultPullPushPolicy(io.fabric8.git.internal.DefaultPullPushPolicy) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)104 Expectations (mockit.Expectations)49 HashMap (java.util.HashMap)32 Map (java.util.Map)24 ArrayList (java.util.ArrayList)23 File (java.io.File)21 GitContext (io.fabric8.api.GitContext)20 IOException (java.io.IOException)20 Exchange (org.apache.camel.Exchange)20 Processor (org.apache.camel.Processor)20 DefaultPullPushPolicy (io.fabric8.git.internal.DefaultPullPushPolicy)18 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)17 Probe (io.fabric8.kubernetes.api.model.Probe)16 PatchResult (io.fabric8.patch.management.PatchResult)13 Properties (java.util.Properties)13 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)11 Patch (io.fabric8.patch.management.Patch)11 PatchException (io.fabric8.patch.management.PatchException)11 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)10 TreeMap (java.util.TreeMap)10