use of io.fabric8.kubernetes.api.model.extensions.Deployment in project carbon-apimgt by wso2.
the class KubernetesGatewayImplTestCase method testCreateIngressResourceForKubernetesException.
@Test
public void testCreateIngressResourceForKubernetesException() throws Exception {
OpenShiftClient openShiftClient = Mockito.mock(OpenShiftClient.class, Mockito.RETURNS_DEEP_STUBS);
KubernetesGatewayImpl kubernetesGateway = getKubernetesGatewayImpl(openShiftClient);
Mockito.when(openShiftClient.load(Mockito.any()).get()).thenReturn(getServiceResources(), getDeploymentResources(), getIngressResources());
NonNamespaceOperation nonNamespaceOperation = Mockito.mock(NonNamespaceOperation.class);
ScalableResource scalableResource = Mockito.mock(ScalableResource.class);
Mockito.when(scalableResource.get()).thenReturn(null);
Service service = createService(openShiftClient, nonNamespaceOperation);
Deployment deployment = createDeployment(openShiftClient, nonNamespaceOperation, scalableResource);
Mockito.when(nonNamespaceOperation.create(Mockito.any())).thenReturn(service, deployment);
ScalableResource scalableResourceIngress = Mockito.mock(ScalableResource.class);
String ingressName = ContainerBasedGatewayConstants.PRIVATE_JET_API_PREFIX + LABEL_SUFFIX + ContainerBasedGatewayConstants.CMS_INGRESS_SUFFIX;
Mockito.when(openShiftClient.extensions().ingresses().inNamespace(NAMESPACE)).thenReturn(nonNamespaceOperation);
Mockito.when(nonNamespaceOperation.withName(ingressName)).thenReturn(scalableResourceIngress);
Mockito.when(scalableResourceIngress.get()).thenThrow(KubernetesClientException.class);
API api = SampleTestObjectCreator.createDefaultAPI().build();
try {
kubernetesGateway.createContainerGateway(ContainerBasedGatewayConstants.PRIVATE_JET_API_PREFIX + LABEL_SUFFIX, api);
} catch (ContainerBasedGatewayException e) {
Assert.assertEquals(e.getErrorHandler(), ExceptionCodes.DEDICATED_CONTAINER_GATEWAY_CREATION_FAILED);
}
}
use of io.fabric8.kubernetes.api.model.extensions.Deployment in project carbon-apimgt by wso2.
the class KubernetesGatewayImplTestCase method createDeployment.
/**
* Create Deployment resource
*
* @param openShiftClient Openshift client
* @param nonNamespaceOperation NonNamespaceOperation instance
* @param scalableResource ScalableResource instance
*/
private Deployment createDeployment(OpenShiftClient openShiftClient, NonNamespaceOperation nonNamespaceOperation, ScalableResource scalableResource) {
String deploymentName = ContainerBasedGatewayConstants.PRIVATE_JET_API_PREFIX + LABEL_SUFFIX + ContainerBasedGatewayConstants.CMS_DEPLOYMENT_SUFFIX;
Mockito.when(openShiftClient.extensions().deployments().inNamespace(NAMESPACE)).thenReturn(nonNamespaceOperation);
Mockito.when(nonNamespaceOperation.withName(deploymentName)).thenReturn(scalableResource);
Deployment deployment = Mockito.mock(Deployment.class, Mockito.RETURNS_DEEP_STUBS);
return deployment;
}
use of io.fabric8.kubernetes.api.model.extensions.Deployment in project fabric8 by jboss-fuse.
the class DeploymentUpdater method updateDeployment.
public void updateDeployment(Git git, File baseDir, CredentialsProvider credentials) throws Exception {
Set<String> bundles = new LinkedHashSet<String>();
Set<Feature> features = new LinkedHashSet<Feature>();
Profile overlayProfile = container.getOverlayProfile();
Profile effectiveProfile = Profiles.getEffectiveProfile(fabricService, overlayProfile);
bundles.addAll(effectiveProfile.getBundles());
AgentUtils.addFeatures(features, fabricService, downloadManager, effectiveProfile);
if (copyFilesIntoGit) {
copyDeploymentsIntoGit(git, baseDir, bundles, features);
} else {
addDeploymentsIntoPom(git, baseDir, effectiveProfile, bundles, features);
}
// now lets do a commit
String message = "updating deployment";
git.commit().setMessage(message).call();
enableDeployDirectory(git, baseDir);
String branch = GitHelpers.currentBranch(git);
LOG.info("Pushing deployment changes to branch " + branch + " credentials " + credentials + " for container " + container.getId());
try {
Iterable<PushResult> results = git.push().setCredentialsProvider(credentials).setRefSpecs(new RefSpec(branch)).setOutputStream(new LoggingOutputStream(LOG)).call();
/*
for (PushResult result : results) {
LOG.info(result.getMessages());
}
*/
LOG.info("Pushed deployment changes to branch " + branch + " for container " + container.getId());
} catch (GitAPIException e) {
LOG.error("Failed to push deployment changes to branch " + branch + " for container " + container.getId() + ". Reason: " + e, e);
}
}
use of io.fabric8.kubernetes.api.model.extensions.Deployment in project fabric8 by jboss-fuse.
the class MavenProxyResolutionTest method releaseIsAvailableInRemoteRepositoryNotUpdatingRelease.
@Test
public void releaseIsAvailableInRemoteRepositoryNotUpdatingRelease() throws IOException, InvalidMavenArtifactRequest {
File remoteRepository = initFileRepository("rr");
MavenResolver resolver = new ResolverBuilder().withRemoteRepositories(Collections.singletonList(remoteRepository)).withUpdatePolicy(RepositoryPolicy.UPDATE_POLICY_ALWAYS).build();
MavenDownloadProxyServlet servlet = new MavenDownloadProxyServlet(resolver, runtime, null, 1, 0);
mvnInstall(remoteRepository, "io.fabric8.test", "universalis-api", "0.1.0", at("10:00"), "a");
File file = servlet.download("io/fabric8/test/universalis-api/0.1.0/universalis-api-0.1.0.jar");
// first resolution
assertThat(FileUtils.readFileToString(file), equalTo("a"));
// don't do that, it's not proper use of maven. But sometimes we just have another deployment to public repository...
mvnInstall(remoteRepository, "io.fabric8.test", "universalis-api", "0.1.0", at("11:00"), "b");
// second resolution
file = servlet.download("io/fabric8/test/universalis-api/0.1.0/universalis-api-0.1.0.jar");
assertThat("Artifact won't be updated for release version", FileUtils.readFileToString(file), equalTo("a"));
}
use of io.fabric8.kubernetes.api.model.extensions.Deployment in project fabric8 by jboss-fuse.
the class Deployer method logDeployment.
protected void logDeployment(Deployer.Deployment overallDeployment, int verbose) {
if (overallDeployment.regions.isEmpty()) {
print("No deployment change.", verbose);
return;
}
print("Changes to perform:", verbose);
for (Map.Entry<String, RegionDeployment> region : overallDeployment.regions.entrySet()) {
Deployer.RegionDeployment deployment = region.getValue();
print(" Region: " + region.getKey(), verbose);
if (!deployment.toDelete.isEmpty()) {
print(" Bundles to uninstall:", verbose);
for (Bundle bundle : deployment.toDelete) {
print(" " + bundle.getSymbolicName() + " / " + bundle.getVersion(), verbose);
}
}
if (!deployment.toUpdate.isEmpty()) {
print(" Bundles to update:", verbose);
for (Map.Entry<Bundle, Resource> entry : deployment.toUpdate.entrySet()) {
print(" " + entry.getKey().getSymbolicName() + " / " + entry.getKey().getVersion() + " with " + getUri(entry.getValue()), verbose);
}
}
if (!deployment.toInstall.isEmpty()) {
print(" Bundles to install:", verbose);
for (Resource resource : deployment.toInstall) {
print(" " + getUri(resource), verbose);
}
}
}
}
Aggregations