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"));
}
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();
}
}
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();
}
}
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;
}
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();
}
}
Aggregations