Search in sources :

Example 26 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class MavenProxySnapshotResolutionTest method snapshotIsAvailableInTwoRemoteRepositories.

@Test
public void snapshotIsAvailableInTwoRemoteRepositories() throws IOException, InvalidMavenArtifactRequest {
    File differentLocalRepository = initFileRepository("dlr");
    File remoteRepository1 = initFileRepository("rr1");
    File remoteRepository2 = initFileRepository("rr2");
    MavenResolver resolver = new ResolverBuilder().withRemoteRepositories(Arrays.asList(remoteRepository1, remoteRepository2)).build();
    MavenDownloadProxyServlet servlet = new MavenDownloadProxyServlet(resolver, runtime, null, 1, 0);
    servlet.start();
    mvnDeploy(differentLocalRepository, remoteRepository1, "io.fabric8.test", "universalis-api", "0.1.0-SNAPSHOT", at("10:00"), "a");
    mvnDeploy(differentLocalRepository, remoteRepository2, "io.fabric8.test", "universalis-api", "0.1.0-SNAPSHOT", at("10:00"), "b");
    mvnDeploy(differentLocalRepository, remoteRepository2, "io.fabric8.test", "universalis-api", "0.1.0-SNAPSHOT", at("11:00"), "c");
    File file = servlet.download("io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/maven-metadata.xml");
    Metadata metadata = readMetadata(file);
    assertThat("Metadata should aggregate versions from all remote repositories, without duplicates", metadata.getVersioning().getSnapshotVersions().size(), is(4));
    assertThat("Latest version should win", metadata.getVersioning().getLastUpdated(), is("20170101110000"));
    assertThat("Latest version should win", metadata.getVersioning().getSnapshot().getTimestamp(), is("20170101.110000"));
    assertThat("Latest version should win, assume versions are sorted in ascending order", metadata.getVersioning().getSnapshotVersions().get(3).getVersion(), is("0.1.0-20170101.110000-2"));
}
Also used : MavenResolver(io.fabric8.maven.MavenResolver) Metadata(org.apache.maven.artifact.repository.metadata.Metadata) File(java.io.File) Test(org.junit.Test)

Example 27 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class DummyBatchingProgressMonitor method getVersionFromCacheRW.

private Version getVersionFromCacheRW(String versionId, String profileId) {
    try {
        initialVersionsAvailable.await(15, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
        LOGGER.warn("Waiting for initial versions failed");
    }
    LockHandle writeLock = aquireWriteLock();
    try {
        assertValid();
        String branch = GitHelpers.getProfileBranch(versionId, profileId);
        if (GitHelpers.localBranchExists(getGit(), branch)) {
            return versionCache.get(versionId);
        } else {
            return null;
        }
    } catch (Exception e) {
        throw FabricException.launderThrowable(e);
    } finally {
        writeLock.unlock();
    }
}
Also used : LockHandle(io.fabric8.api.LockHandle) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) IOException(java.io.IOException) FabricException(io.fabric8.api.FabricException) KeeperException(org.apache.zookeeper.KeeperException) MalformedURLException(java.net.MalformedURLException)

Example 28 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class DummyBatchingProgressMonitor method createProfile.

@Override
public String createProfile(GitContext context, final Profile profile) {
    IllegalStateAssertion.assertNotNull(profile, "profile");
    LockHandle writeLock = aquireWriteLock();
    try {
        assertValid();
        GitOperation<String> gitop = new GitOperation<String>() {

            public String call(Git git, GitContext context) throws Exception {
                String versionId = profile.getVersion();
                String profileId = profile.getId();
                Version version = getRequiredVersion(versionId);
                IllegalStateAssertion.assertFalse(version.hasProfile(profileId), "Profile already exists: " + profileId);
                checkoutRequiredProfileBranch(git, context, versionId, profileId);
                return createOrUpdateProfile(context, null, profile, new HashSet<String>());
            }
        };
        return executeInternal(context, null, gitop);
    } finally {
        writeLock.unlock();
    }
}
Also used : LockHandle(io.fabric8.api.LockHandle) Git(org.eclipse.jgit.api.Git) GitContext(io.fabric8.api.GitContext) GitVersion(io.fabric8.api.commands.GitVersion) Version(io.fabric8.api.Version)

Example 29 with Version

use of io.fabric8.kubernetes.model.annotation.Version in project fabric8 by jboss-fuse.

the class DummyBatchingProgressMonitor method doPullInternal.

private PullPolicyResult doPullInternal(GitContext context, CredentialsProvider credentialsProvider, boolean allowVersionDelete, boolean allowPush, int forcedTimeoutInSeconds) {
    PullPolicyResult pullResult = pullPushPolicy.doPull(context, credentialsProvider, allowVersionDelete, allowPush, forcedTimeoutInSeconds);
    if (pullResult.getLastException() == null) {
        Map<String, PullPushPolicy.BranchChange> updatedVersions = pullResult.localUpdateVersions();
        if (!updatedVersions.isEmpty()) {
            if (updatedVersions.containsKey(GitHelpers.MASTER_BRANCH)) {
                versionCache.invalidateAll();
            } else {
                for (String version : updatedVersions.keySet()) {
                    versionCache.invalidate(version);
                }
            }
            notificationRequired = true;
        }
        Set<String> pullVersions = pullResult.getVersions();
        if (!pullVersions.isEmpty() && !pullVersions.equals(versions)) {
            versions.clear();
            for (String v : pullVersions) {
                if (!v.startsWith("patches-") && !v.startsWith("patch-") && !v.equals(HISTORY_BRANCH) && !v.equals(ADMIN_HISTORY_BRANCH)) {
                    versions.add(v);
                }
            }
        }
        if (pullResult.remoteUpdateRequired()) {
            doPushInternal(context, credentialsProvider);
        }
    }
    return pullResult;
}
Also used : PullPolicyResult(io.fabric8.git.PullPushPolicy.PullPolicyResult)

Example 30 with Version

use of io.fabric8.kubernetes.model.annotation.Version 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)

Aggregations

Map (java.util.Map)87 Version (io.fabric8.api.Version)74 Profile (io.fabric8.api.Profile)70 Test (org.junit.jupiter.api.Test)66 ArrayList (java.util.ArrayList)63 IOException (java.io.IOException)62 File (java.io.File)61 HashMap (java.util.HashMap)61 Vertx (io.vertx.core.Vertx)58 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)57 Test (org.junit.Test)55 Checkpoint (io.vertx.junit5.Checkpoint)54 VertxExtension (io.vertx.junit5.VertxExtension)54 VertxTestContext (io.vertx.junit5.VertxTestContext)54 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)54 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)52 Reconciliation (io.strimzi.operator.common.Reconciliation)50 BeforeAll (org.junit.jupiter.api.BeforeAll)48 Collections (java.util.Collections)46 CoreMatchers.is (org.hamcrest.CoreMatchers.is)46