use of io.fabric8.api.Version in project fabric8 by jboss-fuse.
the class FabricHTTPGateway method getGatewayVersion.
/**
* Returns the default profile version used to filter out the current versions of services
* if no version expression is used the URI template
*/
String getGatewayVersion() {
assertValid();
Container currentContainer = fabricService.get().getCurrentContainer();
if (currentContainer != null) {
Version version = currentContainer.getVersion();
if (version != null) {
return version.getId();
}
}
return null;
}
use of io.fabric8.api.Version in project fabric8 by jboss-fuse.
the class MappingConfigurationTest method addService.
protected void addService(String path, String service, String version) {
Map<String, String> params = new HashMap<String, String>();
params.put("version", version);
String container = path.contains("HelloWorld") ? "soapy" : "resty";
params.put("container", container);
ServiceDTO serviceDetails = new ServiceDTO();
serviceDetails.setContainer(container);
serviceDetails.setVersion(version);
config.updateMappingRules(false, path, Arrays.asList(service), params, serviceDetails);
}
use of io.fabric8.api.Version in project fabric8 by jboss-fuse.
the class GitPatchManagementServiceForStandaloneChildContainersIT method validateInitialGitRepository.
private void validateInitialGitRepository() throws IOException, GitAPIException {
pm = new GitPatchManagementServiceImpl(bundleContext);
pm.start();
pm.ensurePatchManagementInitialized();
GitPatchRepository repository = ((GitPatchManagementServiceImpl) pm).getGitPatchRepository();
verify(bsl, atLeastOnce()).setStartLevel(2);
Git fork = repository.cloneRepository(repository.findOrCreateMainGitRepository(), true);
List<Ref> tags = fork.tagList().call();
boolean found1 = false;
boolean found2 = false;
for (Ref tag : tags) {
if ("refs/tags/baseline-6.2.0".equals(tag.getName())) {
found1 = true;
}
if ("refs/tags/baseline-child-2.4.0.redhat-620133".equals(tag.getName())) {
found2 = true;
}
}
assertTrue("Repository should contain baseline tags for version 6.2.0 (both for root and admin:create based child containrs)", found1 && found2);
repository.closeRepository(fork, true);
}
use of io.fabric8.api.Version in project fabric8 by jboss-fuse.
the class GitPatchManagementServiceIT method installPPatchHotFixPPatchAndThenRPatch.
/**
* Installation of R patch <strong>may</strong> leave P patches installed when they provide <strong>only</strong>
* bundles and the bundles are at higher version
* @throws IOException
* @throws GitAPIException
*/
@Test
public void installPPatchHotFixPPatchAndThenRPatch() throws IOException, GitAPIException {
initializationPerformedBaselineDistributionFoundInSystem();
// prepare some ZIP patches
preparePatchZip("src/test/resources/content/patch1", "target/karaf/patches/source/patch-1.zip", false);
preparePatchZip("src/test/resources/content/patch2", "target/karaf/patches/source/patch-2.zip", false);
preparePatchZip("src/test/resources/content/patch4", "target/karaf/patches/source/patch-4.zip", false);
GitPatchRepository repository = ((GitPatchManagementServiceImpl) pm).getGitPatchRepository();
PatchManagement service = (PatchManagement) pm;
PatchData patchData1 = service.fetchPatches(new File("target/karaf/patches/source/patch-1.zip").toURI().toURL()).get(0);
Patch patch1 = service.trackPatch(patchData1);
PatchData patchData2 = service.fetchPatches(new File("target/karaf/patches/source/patch-2.zip").toURI().toURL()).get(0);
Patch patch2 = service.trackPatch(patchData2);
PatchData patchData4 = service.fetchPatches(new File("target/karaf/patches/source/patch-4.zip").toURI().toURL()).get(0);
Patch patch4 = service.trackPatch(patchData4);
String tx = service.beginInstallation(PatchKind.NON_ROLLUP);
service.install(tx, patch1, null);
service.commitInstallation(tx);
tx = service.beginInstallation(PatchKind.NON_ROLLUP);
service.install(tx, patch2, null);
service.commitInstallation(tx);
assertTrue("There should be etc/overrides.properties after installing non-rollup patches", new File(karafHome, "etc/overrides.properties").exists());
// overrides.properties as after installing P patches with new mechanism
String etcOverridesProperties = FileUtils.readFileToString(new File(karafHome, "etc/overrides.properties"));
assertThat(etcOverridesProperties, equalTo("mvn:io.fabric8/fabric-tranquility/1.2.5\n"));
Git fork = repository.cloneRepository(repository.findOrCreateMainGitRepository(), true);
assertTrue(repository.containsTag(fork, "patch-my-patch-1"));
assertTrue(repository.containsTag(fork, "patch-my-patch-2"));
assertFalse(repository.containsTag(fork, "baseline-6.2.0.redhat-002"));
repository.closeRepository(fork, true);
tx = service.beginInstallation(PatchKind.ROLLUP);
service.install(tx, patch4, null);
service.commitInstallation(tx);
fork = repository.cloneRepository(repository.findOrCreateMainGitRepository(), true);
assertFalse(repository.containsTag(fork, "patch-my-patch-1"));
assertFalse(repository.containsTag(fork, "patch-my-patch-2"));
assertTrue(repository.containsTag(fork, "baseline-6.2.0.redhat-002"));
assertTrue("There still should be etc/overrides.properties after installing rollup patch", new File(karafHome, "etc/overrides.properties").exists());
// overrides.properties as after installing R patch with new mechanism
etcOverridesProperties = FileUtils.readFileToString(new File(karafHome, "etc/overrides.properties"));
assertThat(etcOverridesProperties, equalTo("mvn:io.fabric8/fabric-tranquility/1.2.5\n"));
repository.closeRepository(fork, true);
}
use of io.fabric8.api.Version in project fabric8 by jboss-fuse.
the class GitPatchManagementServiceIT method addPatch1.
/**
* Patch 1 is non-rollup patch
* @throws IOException
* @throws GitAPIException
*/
@Test
public void addPatch1() throws IOException, GitAPIException {
initializationPerformedBaselineDistributionFoundInSystem();
// prepare some ZIP patches
preparePatchZip("src/test/resources/content/patch1", "target/karaf/patches/source/patch-1.zip", false);
PatchManagement service = (PatchManagement) pm;
PatchData patchData = service.fetchPatches(new File("target/karaf/patches/source/patch-1.zip").toURI().toURL()).get(0);
assertThat(patchData.getId(), equalTo("my-patch-1"));
Patch patch = service.trackPatch(patchData);
GitPatchRepository repository = ((GitPatchManagementServiceImpl) pm).getGitPatchRepository();
Git fork = repository.cloneRepository(repository.findOrCreateMainGitRepository(), true);
// we should see remote branch for the patch, but without checking it out, it won't be available in the clone's local branches
List<Ref> branches = fork.branchList().setListMode(ListBranchCommand.ListMode.REMOTE).call();
Ref patchBranch = null;
for (Ref remoteBranch : branches) {
if (String.format("refs/remotes/origin/patch-%s", patchData.getId()).equals(remoteBranch.getName())) {
patchBranch = remoteBranch;
break;
}
}
assertNotNull("Should find remote branch for the added patch", patchBranch);
assertThat(patch.getManagedPatch().getCommitId(), equalTo(patchBranch.getObjectId().getName()));
RevCommit patchCommit = new RevWalk(fork.getRepository()).parseCommit(patchBranch.getObjectId());
// patch commit should be child of baseline commit
RevCommit baselineCommit = new RevWalk(fork.getRepository()).parseCommit(patchCommit.getParent(0));
// this baseline commit should be tagged "baseline-VERSION"
Ref tag = fork.tagList().call().get(0);
assertThat(tag.getName(), equalTo("refs/tags/baseline-6.2.0"));
RevCommit baselineCommitFromTag = new RevWalk(fork.getRepository()).parseCommit(tag.getTarget().getObjectId());
assertThat(baselineCommit.getId(), equalTo(baselineCommitFromTag.getId()));
// let's see the patch applied to baseline-6.2.0
fork.checkout().setName("my-patch-1").setStartPoint("origin/patch-my-patch-1").setCreateBranch(true).call();
String myProperties = FileUtils.readFileToString(new File(fork.getRepository().getWorkTree(), "etc/my.properties"));
assertTrue(myProperties.contains("p1 = v1"));
repository.closeRepository(fork, true);
}
Aggregations