Search in sources :

Example 11 with DeploymentConfig

use of io.fabric8.openshift.api.model.DeploymentConfig in project strimzi by strimzi.

the class KafkaConnectS2IAssemblyOperatorTest method testUpdateClusterNoDiff.

@Test
public void testUpdateClusterNoDiff(TestContext context) {
    ConfigMapOperator mockCmOps = mock(ConfigMapOperator.class);
    ServiceOperator mockServiceOps = mock(ServiceOperator.class);
    DeploymentConfigOperator mockDcOps = mock(DeploymentConfigOperator.class);
    BuildConfigOperator mockBcOps = mock(BuildConfigOperator.class);
    ImageStreamOperator mockIsOps = mock(ImageStreamOperator.class);
    String clusterCmName = "foo";
    String clusterCmNamespace = "test";
    ConfigMap clusterCm = ResourceUtils.createEmptyKafkaConnectS2IClusterConfigMap(clusterCmNamespace, clusterCmName);
    KafkaConnectS2ICluster connect = KafkaConnectS2ICluster.fromConfigMap(clusterCm);
    when(mockCmOps.get(clusterCmNamespace, clusterCmName)).thenReturn(clusterCm);
    when(mockServiceOps.get(clusterCmNamespace, connect.getName())).thenReturn(connect.generateService());
    when(mockDcOps.get(clusterCmNamespace, connect.getName())).thenReturn(connect.generateDeploymentConfig());
    when(mockIsOps.get(clusterCmNamespace, connect.getSourceImageStreamName())).thenReturn(connect.generateSourceImageStream());
    when(mockIsOps.get(clusterCmNamespace, connect.getName())).thenReturn(connect.generateTargetImageStream());
    when(mockBcOps.get(clusterCmNamespace, connect.getName())).thenReturn(connect.generateBuildConfig());
    ArgumentCaptor<String> serviceNamespaceCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> serviceNameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<Service> serviceCaptor = ArgumentCaptor.forClass(Service.class);
    when(mockServiceOps.reconcile(serviceNamespaceCaptor.capture(), serviceNameCaptor.capture(), serviceCaptor.capture())).thenReturn(Future.succeededFuture());
    ArgumentCaptor<String> dcNamespaceCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> dcNameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<DeploymentConfig> dcCaptor = ArgumentCaptor.forClass(DeploymentConfig.class);
    when(mockDcOps.reconcile(dcNamespaceCaptor.capture(), dcNameCaptor.capture(), dcCaptor.capture())).thenReturn(Future.succeededFuture());
    ArgumentCaptor<String> dcScaleUpNamespaceCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> dcScaleUpNameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<Integer> dcScaleUpReplicasCaptor = ArgumentCaptor.forClass(Integer.class);
    when(mockDcOps.scaleUp(dcScaleUpNamespaceCaptor.capture(), dcScaleUpNameCaptor.capture(), dcScaleUpReplicasCaptor.capture())).thenReturn(Future.succeededFuture());
    ArgumentCaptor<String> dcScaleDownNamespaceCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> dcScaleDownNameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<Integer> dcScaleDownReplicasCaptor = ArgumentCaptor.forClass(Integer.class);
    when(mockDcOps.scaleDown(dcScaleDownNamespaceCaptor.capture(), dcScaleDownNameCaptor.capture(), dcScaleDownReplicasCaptor.capture())).thenReturn(Future.succeededFuture());
    ArgumentCaptor<String> isNamespaceCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> isNameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<ImageStream> isCaptor = ArgumentCaptor.forClass(ImageStream.class);
    when(mockIsOps.reconcile(isNamespaceCaptor.capture(), isNameCaptor.capture(), isCaptor.capture())).thenReturn(Future.succeededFuture());
    ArgumentCaptor<String> bcNamespaceCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> bcNameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<BuildConfig> bcCaptor = ArgumentCaptor.forClass(BuildConfig.class);
    when(mockBcOps.reconcile(bcNamespaceCaptor.capture(), bcNameCaptor.capture(), bcCaptor.capture())).thenReturn(Future.succeededFuture());
    KafkaConnectS2IAssemblyOperator ops = new KafkaConnectS2IAssemblyOperator(vertx, true, mockCmOps, mockDcOps, mockServiceOps, mockIsOps, mockBcOps);
    Async async = context.async();
    ops.createOrUpdate(new Reconciliation("test-trigger", AssemblyType.CONNECT_S2I, clusterCmNamespace, clusterCmName), clusterCm, createResult -> {
        context.assertTrue(createResult.succeeded());
        // Vertify service
        List<Service> capturedServices = serviceCaptor.getAllValues();
        context.assertEquals(1, capturedServices.size());
        // Verify Deployment Config
        List<DeploymentConfig> capturedDc = dcCaptor.getAllValues();
        context.assertEquals(1, capturedDc.size());
        // Verify Build Config
        List<BuildConfig> capturedBc = bcCaptor.getAllValues();
        context.assertEquals(1, capturedBc.size());
        // Verify Image Streams
        List<ImageStream> capturedIs = isCaptor.getAllValues();
        context.assertEquals(2, capturedIs.size());
        // Verify scaleDown / scaleUp were not called
        context.assertEquals(1, dcScaleDownNameCaptor.getAllValues().size());
        context.assertEquals(1, dcScaleUpNameCaptor.getAllValues().size());
        async.complete();
    });
}
Also used : ImageStream(io.fabric8.openshift.api.model.ImageStream) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ServiceOperator(io.strimzi.controller.cluster.operator.resource.ServiceOperator) Async(io.vertx.ext.unit.Async) Reconciliation(io.strimzi.controller.cluster.Reconciliation) BuildConfig(io.fabric8.openshift.api.model.BuildConfig) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Service(io.fabric8.kubernetes.api.model.Service) KafkaConnectS2ICluster(io.strimzi.controller.cluster.model.KafkaConnectS2ICluster) BuildConfigOperator(io.strimzi.controller.cluster.operator.resource.BuildConfigOperator) ImageStreamOperator(io.strimzi.controller.cluster.operator.resource.ImageStreamOperator) ConfigMapOperator(io.strimzi.controller.cluster.operator.resource.ConfigMapOperator) DeploymentConfigOperator(io.strimzi.controller.cluster.operator.resource.DeploymentConfigOperator) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) Test(org.junit.Test)

Example 12 with DeploymentConfig

use of io.fabric8.openshift.api.model.DeploymentConfig in project strimzi by strimzi.

the class KafkaConnectS2IAssemblyOperatorTest method testCreateCluster.

@Test
public void testCreateCluster(TestContext context) {
    ConfigMapOperator mockCmOps = mock(ConfigMapOperator.class);
    ServiceOperator mockServiceOps = mock(ServiceOperator.class);
    DeploymentConfigOperator mockDcOps = mock(DeploymentConfigOperator.class);
    BuildConfigOperator mockBcOps = mock(BuildConfigOperator.class);
    ImageStreamOperator mockIsOps = mock(ImageStreamOperator.class);
    String clusterCmName = "foo";
    String clusterCmNamespace = "test";
    ConfigMap clusterCm = ResourceUtils.createEmptyKafkaConnectS2IClusterConfigMap(clusterCmNamespace, clusterCmName);
    when(mockCmOps.get(clusterCmNamespace, clusterCmName)).thenReturn(clusterCm);
    ArgumentCaptor<Service> serviceCaptor = ArgumentCaptor.forClass(Service.class);
    when(mockServiceOps.reconcile(anyString(), anyString(), serviceCaptor.capture())).thenReturn(Future.succeededFuture());
    ArgumentCaptor<DeploymentConfig> dcCaptor = ArgumentCaptor.forClass(DeploymentConfig.class);
    when(mockDcOps.reconcile(anyString(), anyString(), dcCaptor.capture())).thenReturn(Future.succeededFuture());
    when(mockDcOps.scaleDown(anyString(), anyString(), anyInt())).thenReturn(Future.succeededFuture(42));
    when(mockDcOps.scaleUp(anyString(), anyString(), anyInt())).thenReturn(Future.succeededFuture(42));
    ArgumentCaptor<ImageStream> isCaptor = ArgumentCaptor.forClass(ImageStream.class);
    when(mockIsOps.reconcile(anyString(), anyString(), isCaptor.capture())).thenReturn(Future.succeededFuture());
    ArgumentCaptor<BuildConfig> bcCaptor = ArgumentCaptor.forClass(BuildConfig.class);
    when(mockBcOps.reconcile(anyString(), anyString(), bcCaptor.capture())).thenReturn(Future.succeededFuture());
    KafkaConnectS2IAssemblyOperator ops = new KafkaConnectS2IAssemblyOperator(vertx, true, mockCmOps, mockDcOps, mockServiceOps, mockIsOps, mockBcOps);
    KafkaConnectS2ICluster connect = KafkaConnectS2ICluster.fromConfigMap(clusterCm);
    Async async = context.async();
    ops.createOrUpdate(new Reconciliation("test-trigger", AssemblyType.CONNECT_S2I, clusterCmNamespace, clusterCmName), clusterCm, createResult -> {
        context.assertTrue(createResult.succeeded());
        // Vertify service
        List<Service> capturedServices = serviceCaptor.getAllValues();
        context.assertEquals(1, capturedServices.size());
        Service service = capturedServices.get(0);
        context.assertEquals(connect.getName(), service.getMetadata().getName());
        context.assertEquals(connect.generateService(), service, "Services are not equal");
        // Verify Deployment Config
        List<DeploymentConfig> capturedDc = dcCaptor.getAllValues();
        context.assertEquals(1, capturedDc.size());
        DeploymentConfig dc = capturedDc.get(0);
        context.assertEquals(connect.getName(), dc.getMetadata().getName());
        context.assertEquals(connect.generateDeploymentConfig(), dc, "Deployment Configs are not equal");
        // Verify Build Config
        List<BuildConfig> capturedBc = bcCaptor.getAllValues();
        context.assertEquals(1, capturedBc.size());
        BuildConfig bc = capturedBc.get(0);
        context.assertEquals(connect.getName(), dc.getMetadata().getName());
        context.assertEquals(connect.generateBuildConfig(), bc, "Build Configs are not equal");
        // Verify Image Streams
        List<ImageStream> capturedIs = isCaptor.getAllValues();
        context.assertEquals(2, capturedIs.size());
        int sisIndex = (connect.getSourceImageStreamName()).equals(capturedIs.get(0).getMetadata().getName()) ? 0 : 1;
        int tisIndex = (connect.getName()).equals(capturedIs.get(0).getMetadata().getName()) ? 0 : 1;
        ImageStream sis = capturedIs.get(sisIndex);
        context.assertEquals(connect.getSourceImageStreamName(), sis.getMetadata().getName());
        context.assertEquals(connect.generateSourceImageStream(), sis, "Source Image Streams are not equal");
        ImageStream tis = capturedIs.get(tisIndex);
        context.assertEquals(connect.getName(), tis.getMetadata().getName());
        context.assertEquals(connect.generateTargetImageStream(), tis, "Target Image Streams are not equal");
        async.complete();
    });
}
Also used : ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Service(io.fabric8.kubernetes.api.model.Service) ImageStream(io.fabric8.openshift.api.model.ImageStream) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ServiceOperator(io.strimzi.controller.cluster.operator.resource.ServiceOperator) KafkaConnectS2ICluster(io.strimzi.controller.cluster.model.KafkaConnectS2ICluster) BuildConfigOperator(io.strimzi.controller.cluster.operator.resource.BuildConfigOperator) ImageStreamOperator(io.strimzi.controller.cluster.operator.resource.ImageStreamOperator) Async(io.vertx.ext.unit.Async) Reconciliation(io.strimzi.controller.cluster.Reconciliation) ConfigMapOperator(io.strimzi.controller.cluster.operator.resource.ConfigMapOperator) BuildConfig(io.fabric8.openshift.api.model.BuildConfig) DeploymentConfigOperator(io.strimzi.controller.cluster.operator.resource.DeploymentConfigOperator) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) Test(org.junit.Test)

Example 13 with DeploymentConfig

use of io.fabric8.openshift.api.model.DeploymentConfig in project strimzi by strimzi.

the class KafkaConnectS2IAssemblyOperatorTest method testUpdateCluster.

@Test
public void testUpdateCluster(TestContext context) {
    ConfigMapOperator mockCmOps = mock(ConfigMapOperator.class);
    ServiceOperator mockServiceOps = mock(ServiceOperator.class);
    DeploymentConfigOperator mockDcOps = mock(DeploymentConfigOperator.class);
    BuildConfigOperator mockBcOps = mock(BuildConfigOperator.class);
    ImageStreamOperator mockIsOps = mock(ImageStreamOperator.class);
    String clusterCmName = "foo";
    String clusterCmNamespace = "test";
    ConfigMap clusterCm = ResourceUtils.createEmptyKafkaConnectS2IClusterConfigMap(clusterCmNamespace, clusterCmName);
    KafkaConnectS2ICluster connect = KafkaConnectS2ICluster.fromConfigMap(clusterCm);
    // Change the image to generate some diff
    clusterCm.getData().put("image", "some/different:image");
    when(mockCmOps.get(clusterCmNamespace, clusterCmName)).thenReturn(clusterCm);
    when(mockServiceOps.get(clusterCmNamespace, connect.getName())).thenReturn(connect.generateService());
    when(mockDcOps.get(clusterCmNamespace, connect.getName())).thenReturn(connect.generateDeploymentConfig());
    when(mockIsOps.get(clusterCmNamespace, connect.getSourceImageStreamName())).thenReturn(connect.generateSourceImageStream());
    when(mockIsOps.get(clusterCmNamespace, connect.getName())).thenReturn(connect.generateTargetImageStream());
    when(mockBcOps.get(clusterCmNamespace, connect.getName())).thenReturn(connect.generateBuildConfig());
    ArgumentCaptor<String> serviceNamespaceCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> serviceNameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<Service> serviceCaptor = ArgumentCaptor.forClass(Service.class);
    when(mockServiceOps.reconcile(serviceNamespaceCaptor.capture(), serviceNameCaptor.capture(), serviceCaptor.capture())).thenReturn(Future.succeededFuture());
    ArgumentCaptor<String> dcNamespaceCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> dcNameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<DeploymentConfig> dcCaptor = ArgumentCaptor.forClass(DeploymentConfig.class);
    when(mockDcOps.reconcile(dcNamespaceCaptor.capture(), dcNameCaptor.capture(), dcCaptor.capture())).thenReturn(Future.succeededFuture());
    ArgumentCaptor<String> dcScaleUpNamespaceCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> dcScaleUpNameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<Integer> dcScaleUpReplicasCaptor = ArgumentCaptor.forClass(Integer.class);
    when(mockDcOps.scaleUp(dcScaleUpNamespaceCaptor.capture(), dcScaleUpNameCaptor.capture(), dcScaleUpReplicasCaptor.capture())).thenReturn(Future.succeededFuture());
    ArgumentCaptor<String> dcScaleDownNamespaceCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> dcScaleDownNameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<Integer> dcScaleDownReplicasCaptor = ArgumentCaptor.forClass(Integer.class);
    when(mockDcOps.scaleDown(dcScaleDownNamespaceCaptor.capture(), dcScaleDownNameCaptor.capture(), dcScaleDownReplicasCaptor.capture())).thenReturn(Future.succeededFuture());
    ArgumentCaptor<String> isNamespaceCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> isNameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<ImageStream> isCaptor = ArgumentCaptor.forClass(ImageStream.class);
    when(mockIsOps.reconcile(isNamespaceCaptor.capture(), isNameCaptor.capture(), isCaptor.capture())).thenReturn(Future.succeededFuture());
    ArgumentCaptor<String> bcNamespaceCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> bcNameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<BuildConfig> bcCaptor = ArgumentCaptor.forClass(BuildConfig.class);
    when(mockBcOps.reconcile(bcNamespaceCaptor.capture(), bcNameCaptor.capture(), bcCaptor.capture())).thenReturn(Future.succeededFuture());
    KafkaConnectS2IAssemblyOperator ops = new KafkaConnectS2IAssemblyOperator(vertx, true, mockCmOps, mockDcOps, mockServiceOps, mockIsOps, mockBcOps);
    Async async = context.async();
    ops.createOrUpdate(new Reconciliation("test-trigger", AssemblyType.CONNECT_S2I, clusterCmNamespace, clusterCmName), clusterCm, createResult -> {
        context.assertTrue(createResult.succeeded());
        KafkaConnectS2ICluster compareTo = KafkaConnectS2ICluster.fromConfigMap(clusterCm);
        // Vertify service
        List<Service> capturedServices = serviceCaptor.getAllValues();
        context.assertEquals(1, capturedServices.size());
        Service service = capturedServices.get(0);
        context.assertEquals(compareTo.getName(), service.getMetadata().getName());
        context.assertEquals(compareTo.generateService(), service, "Services are not equal");
        // Verify Deployment Config
        List<DeploymentConfig> capturedDc = dcCaptor.getAllValues();
        context.assertEquals(1, capturedDc.size());
        DeploymentConfig dc = capturedDc.get(0);
        context.assertEquals(compareTo.getName(), dc.getMetadata().getName());
        context.assertEquals(compareTo.generateDeploymentConfig(), dc, "Deployment Configs are not equal");
        // Verify Build Config
        List<BuildConfig> capturedBc = bcCaptor.getAllValues();
        context.assertEquals(1, capturedBc.size());
        BuildConfig bc = capturedBc.get(0);
        context.assertEquals(compareTo.getName(), dc.getMetadata().getName());
        context.assertEquals(compareTo.generateBuildConfig(), bc, "Build Configs are not equal");
        // Verify Image Streams
        List<ImageStream> capturedIs = isCaptor.getAllValues();
        context.assertEquals(2, capturedIs.size());
        int sisIndex = (compareTo.getSourceImageStreamName()).equals(capturedIs.get(0).getMetadata().getName()) ? 0 : 1;
        int tisIndex = (compareTo.getName()).equals(capturedIs.get(0).getMetadata().getName()) ? 0 : 1;
        ImageStream sis = capturedIs.get(sisIndex);
        context.assertEquals(compareTo.getSourceImageStreamName(), sis.getMetadata().getName());
        context.assertEquals(compareTo.generateSourceImageStream(), sis, "Source Image Streams are not equal");
        ImageStream tis = capturedIs.get(tisIndex);
        context.assertEquals(compareTo.getName(), tis.getMetadata().getName());
        context.assertEquals(compareTo.generateTargetImageStream(), tis, "Target Image Streams are not equal");
        async.complete();
    });
}
Also used : ImageStream(io.fabric8.openshift.api.model.ImageStream) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ServiceOperator(io.strimzi.controller.cluster.operator.resource.ServiceOperator) Async(io.vertx.ext.unit.Async) Reconciliation(io.strimzi.controller.cluster.Reconciliation) BuildConfig(io.fabric8.openshift.api.model.BuildConfig) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Service(io.fabric8.kubernetes.api.model.Service) KafkaConnectS2ICluster(io.strimzi.controller.cluster.model.KafkaConnectS2ICluster) BuildConfigOperator(io.strimzi.controller.cluster.operator.resource.BuildConfigOperator) ImageStreamOperator(io.strimzi.controller.cluster.operator.resource.ImageStreamOperator) ConfigMapOperator(io.strimzi.controller.cluster.operator.resource.ConfigMapOperator) DeploymentConfigOperator(io.strimzi.controller.cluster.operator.resource.DeploymentConfigOperator) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) Test(org.junit.Test)

Example 14 with DeploymentConfig

use of io.fabric8.openshift.api.model.DeploymentConfig in project strimzi by strimzi.

the class KafkaConnectS2IAssemblyOperatorTest method testUpdateClusterFailure.

@Test
public void testUpdateClusterFailure(TestContext context) {
    ConfigMapOperator mockCmOps = mock(ConfigMapOperator.class);
    ServiceOperator mockServiceOps = mock(ServiceOperator.class);
    DeploymentConfigOperator mockDcOps = mock(DeploymentConfigOperator.class);
    BuildConfigOperator mockBcOps = mock(BuildConfigOperator.class);
    ImageStreamOperator mockIsOps = mock(ImageStreamOperator.class);
    String clusterCmName = "foo";
    String clusterCmNamespace = "test";
    ConfigMap clusterCm = ResourceUtils.createEmptyKafkaConnectS2IClusterConfigMap(clusterCmNamespace, clusterCmName);
    KafkaConnectS2ICluster connect = KafkaConnectS2ICluster.fromConfigMap(clusterCm);
    // Change the image to generate some diff
    clusterCm.getData().put("image", "some/different:image");
    when(mockCmOps.get(clusterCmNamespace, clusterCmName)).thenReturn(clusterCm);
    when(mockServiceOps.get(clusterCmNamespace, connect.getName())).thenReturn(connect.generateService());
    when(mockDcOps.get(clusterCmNamespace, connect.getName())).thenReturn(connect.generateDeploymentConfig());
    when(mockIsOps.get(clusterCmNamespace, connect.getSourceImageStreamName())).thenReturn(connect.generateSourceImageStream());
    when(mockIsOps.get(clusterCmNamespace, connect.getName())).thenReturn(connect.generateTargetImageStream());
    when(mockBcOps.get(clusterCmNamespace, connect.getName())).thenReturn(connect.generateBuildConfig());
    ArgumentCaptor<String> serviceNamespaceCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> serviceNameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<Service> serviceCaptor = ArgumentCaptor.forClass(Service.class);
    when(mockServiceOps.reconcile(serviceNamespaceCaptor.capture(), serviceNameCaptor.capture(), serviceCaptor.capture())).thenReturn(Future.succeededFuture());
    ArgumentCaptor<String> dcNamespaceCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> dcNameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<DeploymentConfig> dcCaptor = ArgumentCaptor.forClass(DeploymentConfig.class);
    when(mockDcOps.reconcile(dcNamespaceCaptor.capture(), dcNameCaptor.capture(), dcCaptor.capture())).thenReturn(Future.failedFuture("Failed"));
    ArgumentCaptor<String> dcScaleUpNamespaceCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> dcScaleUpNameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<Integer> dcScaleUpReplicasCaptor = ArgumentCaptor.forClass(Integer.class);
    when(mockDcOps.scaleUp(dcScaleUpNamespaceCaptor.capture(), dcScaleUpNameCaptor.capture(), dcScaleUpReplicasCaptor.capture())).thenReturn(Future.succeededFuture());
    ArgumentCaptor<String> dcScaleDownNamespaceCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> dcScaleDownNameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<Integer> dcScaleDownReplicasCaptor = ArgumentCaptor.forClass(Integer.class);
    when(mockDcOps.scaleDown(dcScaleDownNamespaceCaptor.capture(), dcScaleDownNameCaptor.capture(), dcScaleDownReplicasCaptor.capture())).thenReturn(Future.succeededFuture());
    ArgumentCaptor<String> isNamespaceCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> isNameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<ImageStream> isCaptor = ArgumentCaptor.forClass(ImageStream.class);
    when(mockIsOps.reconcile(isNamespaceCaptor.capture(), isNameCaptor.capture(), isCaptor.capture())).thenReturn(Future.succeededFuture());
    ArgumentCaptor<String> bcNamespaceCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> bcNameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<BuildConfig> bcCaptor = ArgumentCaptor.forClass(BuildConfig.class);
    when(mockBcOps.reconcile(bcNamespaceCaptor.capture(), bcNameCaptor.capture(), bcCaptor.capture())).thenReturn(Future.succeededFuture());
    KafkaConnectS2IAssemblyOperator ops = new KafkaConnectS2IAssemblyOperator(vertx, true, mockCmOps, mockDcOps, mockServiceOps, mockIsOps, mockBcOps);
    Async async = context.async();
    ops.createOrUpdate(new Reconciliation("test-trigger", AssemblyType.CONNECT_S2I, clusterCmNamespace, clusterCmName), clusterCm, createResult -> {
        context.assertFalse(createResult.succeeded());
        async.complete();
    });
}
Also used : ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Service(io.fabric8.kubernetes.api.model.Service) ImageStream(io.fabric8.openshift.api.model.ImageStream) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ServiceOperator(io.strimzi.controller.cluster.operator.resource.ServiceOperator) KafkaConnectS2ICluster(io.strimzi.controller.cluster.model.KafkaConnectS2ICluster) BuildConfigOperator(io.strimzi.controller.cluster.operator.resource.BuildConfigOperator) ImageStreamOperator(io.strimzi.controller.cluster.operator.resource.ImageStreamOperator) Async(io.vertx.ext.unit.Async) Reconciliation(io.strimzi.controller.cluster.Reconciliation) ConfigMapOperator(io.strimzi.controller.cluster.operator.resource.ConfigMapOperator) BuildConfig(io.fabric8.openshift.api.model.BuildConfig) DeploymentConfigOperator(io.strimzi.controller.cluster.operator.resource.DeploymentConfigOperator) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) Test(org.junit.Test)

Example 15 with DeploymentConfig

use of io.fabric8.openshift.api.model.DeploymentConfig in project vertx-openshift-it by cescoffier.

the class OpenShiftTestAssistant method deployApplication.

public String deployApplication() throws IOException {
    applicationName = System.getProperty("app.name");
    List<? extends HasMetadata> entities = deploy("application", new File("target/classes/META-INF/fabric8/openshift.yml"));
    Optional<String> first = entities.stream().filter(hm -> hm instanceof DeploymentConfig).map(hm -> (DeploymentConfig) hm).map(dc -> dc.getMetadata().getName()).findFirst();
    if (applicationName == null && first.isPresent()) {
        applicationName = first.get();
    }
    Route route = client.adapt(OpenShiftClient.class).routes().inNamespace(project).withName(applicationName).get();
    assertThat(route).isNotNull();
    RestAssured.baseURI = "http://" + Objects.requireNonNull(route).getSpec().getHost();
    System.out.println("Route url: " + RestAssured.baseURI);
    return applicationName;
}
Also used : KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException) Awaitility.await(org.awaitility.Awaitility.await) Predicate(java.util.function.Predicate) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Pod(io.fabric8.kubernetes.api.model.Pod) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) Collectors(java.util.stream.Collectors) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) File(java.io.File) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Route(io.fabric8.openshift.api.model.Route) Map(java.util.Map) Optional(java.util.Optional) RestAssured(io.restassured.RestAssured) Comparator(java.util.Comparator) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) File(java.io.File) Route(io.fabric8.openshift.api.model.Route)

Aggregations

DeploymentConfig (io.fabric8.openshift.api.model.DeploymentConfig)30 Deployment (io.fabric8.kubernetes.api.model.extensions.Deployment)11 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)10 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)10 Test (org.junit.Test)9 ReplicationController (io.fabric8.kubernetes.api.model.ReplicationController)8 Service (io.fabric8.kubernetes.api.model.Service)8 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)7 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)7 ReplicaSet (io.fabric8.kubernetes.api.model.extensions.ReplicaSet)7 BuildConfig (io.fabric8.openshift.api.model.BuildConfig)7 DeploymentConfigSpec (io.fabric8.openshift.api.model.DeploymentConfigSpec)6 ImageStream (io.fabric8.openshift.api.model.ImageStream)6 IOException (java.io.IOException)6 Controller (io.fabric8.kubernetes.api.Controller)5 Pod (io.fabric8.kubernetes.api.model.Pod)5 DeploymentSpec (io.fabric8.kubernetes.api.model.extensions.DeploymentSpec)5 ReplicationControllerSpec (io.fabric8.kubernetes.api.model.ReplicationControllerSpec)4 ReplicaSetSpec (io.fabric8.kubernetes.api.model.extensions.ReplicaSetSpec)4 Route (io.fabric8.openshift.api.model.Route)4