Search in sources :

Example 1 with Component

use of io.syndesis.qe.component.Component in project syndesis-qe by syndesisio.

the class OperatorValidationSteps method checkThatMeteringLabelsHaveCorrectValues.

/**
 * Checks whether pods contains metering labels with correct values.
 * It is a feature for Fuse Online product, therefore check runs only in case of the productized build.
 */
@Then("check that metering labels have correct values for \"([^\"]*)\"$")
public void checkThatMeteringLabelsHaveCorrectValues(Component component) {
    final String version = "8.0";
    final String company = "Red_Hat";
    final String prodName = "Red_Hat_Integration";
    final String componentName = "Fuse";
    final String subcomponent_t = "infrastructure";
    List<Pod> pods = OpenShiftUtils.getInstance().pods().withLabel("syndesis.io/component").list().getItems().stream().filter(p -> !"integration".equals(p.getMetadata().getLabels().get("syndesis.io/component"))).collect(Collectors.toList());
    for (Pod p : pods) {
        if (p.getStatus().getPhase().contains("Running") && p.getMetadata().getName().contains(component.getName())) {
            Map<String, String> labels = p.getMetadata().getLabels();
            assertThat(labels).containsKey("com.company");
            assertThat(labels).containsKey("rht.prod_name");
            assertThat(labels).containsKey("rht.prod_ver");
            assertThat(labels).containsKey("rht.comp");
            assertThat(labels).containsKey("rht.comp_ver");
            assertThat(labels).containsKey("rht.subcomp");
            assertThat(labels).containsKey("rht.subcomp_t");
            assertThat(labels.get("com.company")).isEqualTo(company);
            assertThat(labels.get("rht.prod_name")).isEqualTo(prodName);
            assertThat(labels.get("rht.prod_ver")).isEqualTo(version);
            assertThat(labels.get("rht.comp")).isEqualTo(componentName);
            assertThat(labels.get("rht.comp_ver")).isEqualTo(version);
            assertThat(labels.get("rht.subcomp")).isEqualTo(component.getName());
            assertThat(labels.get("rht.subcomp_t")).isEqualTo(subcomponent_t);
        }
    }
}
Also used : Quantity(io.fabric8.kubernetes.api.model.Quantity) Arrays(java.util.Arrays) Enumeration(java.util.Enumeration) Date(java.util.Date) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Autowired(org.springframework.beans.factory.annotation.Autowired) TimeoutException(java.util.concurrent.TimeoutException) Random(java.util.Random) StringUtils(org.apache.commons.lang3.StringUtils) JSONObject(org.json.JSONObject) Matcher(java.util.regex.Matcher) IntegrationsEndpoint(io.syndesis.qe.endpoint.IntegrationsEndpoint) Map(java.util.Map) Addon(io.syndesis.qe.addon.Addon) ZipFile(java.util.zip.ZipFile) Syndesis(io.syndesis.qe.resource.impl.Syndesis) Path(java.nio.file.Path) ZipEntry(java.util.zip.ZipEntry) Affinity(io.fabric8.kubernetes.api.model.Affinity) AccountsDirectory(io.syndesis.qe.account.AccountsDirectory) Set(java.util.Set) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) Jaeger(io.syndesis.qe.resource.impl.Jaeger) DoneablePersistentVolume(io.fabric8.kubernetes.api.model.DoneablePersistentVolume) Collectors(java.util.stream.Collectors) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Assertions.fail(org.assertj.core.api.Assertions.fail) S3BucketNameBuilder(io.syndesis.qe.utils.aws.S3BucketNameBuilder) ResourceFactory(io.syndesis.qe.resource.ResourceFactory) Optional(java.util.Optional) Lazy(org.springframework.context.annotation.Lazy) Pattern(java.util.regex.Pattern) Component(io.syndesis.qe.component.Component) OpenShiftWaitUtils(io.syndesis.qe.wait.OpenShiftWaitUtils) SoftAssertions(org.assertj.core.api.SoftAssertions) NodeSelectorTerm(io.fabric8.kubernetes.api.model.NodeSelectorTerm) Then(io.cucumber.java.en.Then) ComponentUtils(io.syndesis.qe.component.ComponentUtils) LocalPortForward(io.fabric8.kubernetes.client.LocalPortForward) HashMap(java.util.HashMap) Yaml(org.yaml.snakeyaml.Yaml) Given(io.cucumber.java.en.Given) DataTable(io.cucumber.datatable.DataTable) Node(io.fabric8.kubernetes.api.model.Node) OutputStream(java.io.OutputStream) PersistentVolumeFluent(io.fabric8.kubernetes.api.model.PersistentVolumeFluent) Endpoints(io.fabric8.kubernetes.api.model.Endpoints) Files(java.nio.file.Files) When(io.cucumber.java.en.When) S3Utils(io.syndesis.qe.utils.aws.S3Utils) FileOutputStream(java.io.FileOutputStream) Pod(io.fabric8.kubernetes.api.model.Pod) FileUtils(org.apache.commons.io.FileUtils) IOException(java.io.IOException) NodeSelector(io.fabric8.kubernetes.api.model.NodeSelector) Toleration(io.fabric8.kubernetes.api.model.Toleration) OpenShiftUtils(io.syndesis.qe.utils.OpenShiftUtils) FileInputStream(java.io.FileInputStream) Account(io.syndesis.qe.account.Account) File(java.io.File) NodeAffinity(io.fabric8.kubernetes.api.model.NodeAffinity) HTTPUtils(io.syndesis.qe.utils.http.HTTPUtils) TestUtils(io.syndesis.qe.utils.TestUtils) Paths(java.nio.file.Paths) SecretBuilder(io.fabric8.kubernetes.api.model.SecretBuilder) ExternalDatabase(io.syndesis.qe.resource.impl.ExternalDatabase) JSONArray(org.json.JSONArray) InputStream(java.io.InputStream) Pod(io.fabric8.kubernetes.api.model.Pod) Then(io.cucumber.java.en.Then)

Example 2 with Component

use of io.syndesis.qe.component.Component in project syndesis-qe by syndesisio.

the class Syndesis method deployOperator.

public void deployOperator() {
    List<HasMetadata> resourceList = getOperatorResources();
    final String operatorResourcesName = "syndesis-operator";
    Optional<HasMetadata> serviceAccount = resourceList.stream().filter(resource -> "ServiceAccount".equals(resource.getKind()) && operatorResourcesName.equals(resource.getMetadata().getName())).findFirst();
    if (serviceAccount.isPresent()) {
        ((ServiceAccount) serviceAccount.get()).getImagePullSecrets().add(new LocalObjectReference(TestConfiguration.syndesisPullSecretName()));
    } else {
        log.error("Service account not found in resources");
    }
    OpenShiftUtils.getInstance().serviceAccounts().withName("default").edit().addToImagePullSecrets(new LocalObjectReference(TestConfiguration.syndesisPullSecretName())).done();
    List<EnvVar> envVarsToAdd = new ArrayList<>();
    envVarsToAdd.add(new EnvVar("TEST_SUPPORT", "true", null));
    // For upgrade, we want to override images only for "current" version
    if (operatorImage.equals(TestConfiguration.syndesisOperatorImage())) {
        Set<Image> images = EnumSet.allOf(Image.class);
        for (Image image : images) {
            if (TestConfiguration.image(image) != null) {
                // override image, e.g. from BUILD_PROPERTIES
                log.info("Overriding " + image.name().toLowerCase() + " image with " + TestConfiguration.image(image));
                envVarsToAdd.add(new EnvVar("RELATED_IMAGE_" + image.name(), TestConfiguration.image(image), null));
            } else {
                // use images from Quay instead of DockerHub for Syndesis components
                switch(image) {
                    case META:
                    case S2I:
                    case UI:
                    case SERVER:
                    case UPGRADE:
                        log.info("Overriding " + image.name().toLowerCase() + " image with quay variant");
                        String version = TestConfiguration.syndesisInstallVersion() != null ? TestConfiguration.syndesisInstallVersion() : "latest";
                        envVarsToAdd.add(new EnvVar("RELATED_IMAGE_" + image.name(), String.format("%s/syndesis/syndesis-%s:%s", TestConfiguration.get().readValue(SYNDESIS_DOCKER_REGISTRY), image.name().toLowerCase(), version), null));
                }
            }
        }
    }
    if ((TestUtils.isProdBuild() && getOperatorImage().contains("1.8")) || getOperatorImage().contains("1.11")) {
        // apply this hotfix for 1.8 prod version, needs for OSD because it doesn't see proxy eng repo
        if (TestUtils.isProdBuild()) {
            envVarsToAdd.add(new EnvVar("RELATED_IMAGE_PSQL_EXPORTER", "registry.redhat.io/fuse7/fuse-postgres-exporter-rhel7:1.8", null));
        }
        // needs for upgrade test when previous version is 1.11
        DeploymentConfig dc = (DeploymentConfig) resourceList.stream().filter(r -> "DeploymentConfig".equals(r.getKind()) && operatorResourcesName.equals(r.getMetadata().getName())).findFirst().orElseThrow(() -> new RuntimeException("Unable to find deployment config in operator resources"));
        dc.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv().addAll(envVarsToAdd);
    } else {
        Deployment deployment = (Deployment) resourceList.stream().filter(r -> "Deployment".equals(r.getKind()) && operatorResourcesName.equals(r.getMetadata().getName())).findFirst().orElseThrow(() -> new RuntimeException("Unable to find deployment in operator resources"));
        deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv().addAll(envVarsToAdd);
    }
    OpenShiftUtils.asRegularUser(() -> OpenShiftUtils.getInstance().resourceList(resourceList).createOrReplace());
    log.info("Waiting for syndesis-operator to be ready");
    try {
        OpenShiftUtils.getInstance().waiters().areExactlyNPodsReady(1, "syndesis.io/component", operatorResourcesName).interval(TimeUnit.SECONDS, 20).timeout(TimeUnit.MINUTES, 10).waitFor();
    } catch (WaiterException e) {
        InfraFail.fail("Unable to find operator pod in 10 minutes");
    }
}
Also used : URL(java.net.URL) TodoUtils(io.syndesis.qe.utils.TodoUtils) TimeoutException(java.util.concurrent.TimeoutException) RawCustomResourceOperationsImpl(io.fabric8.kubernetes.client.dsl.internal.RawCustomResourceOperationsImpl) StringUtils(org.apache.commons.lang3.StringUtils) JSONException(org.json.JSONException) CustomResourceDefinitionContext(io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext) JSONObject(org.json.JSONObject) Map(java.util.Map) Addon(io.syndesis.qe.addon.Addon) Bundle(io.syndesis.qe.marketplace.manifests.Bundle) WaiterException(cz.xtf.core.waiting.WaiterException) EnumSet(java.util.EnumSet) QuayUser(io.syndesis.qe.marketplace.quay.QuayUser) TestConfiguration(io.syndesis.qe.TestConfiguration) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException) InfraFail(io.syndesis.qe.test.InfraFail) Opm(io.syndesis.qe.marketplace.manifests.Opm) Set(java.util.Set) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) CommonSteps(io.syndesis.qe.common.CommonSteps) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) StandardCharsets(java.nio.charset.StandardCharsets) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Assertions.fail(org.assertj.core.api.Assertions.fail) Index(io.syndesis.qe.marketplace.manifests.Index) ResourceFactory(io.syndesis.qe.resource.ResourceFactory) Optional(java.util.Optional) Component(io.syndesis.qe.component.Component) SYNDESIS_DOCKER_REGISTRY(io.syndesis.qe.TestConfiguration.SYNDESIS_DOCKER_REGISTRY) OpenShiftWaitUtils(io.syndesis.qe.wait.OpenShiftWaitUtils) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) Setter(lombok.Setter) Getter(lombok.Getter) OpenShiftService(io.syndesis.qe.marketplace.openshift.OpenShiftService) ComponentUtils(io.syndesis.qe.component.ComponentUtils) ArrayUtils(org.apache.commons.lang3.ArrayUtils) HashMap(java.util.HashMap) LocalObjectReference(io.fabric8.kubernetes.api.model.LocalObjectReference) Yaml(org.yaml.snakeyaml.Yaml) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) PortForwardUtils(io.syndesis.qe.utils.PortForwardUtils) Image(io.syndesis.qe.image.Image) CustomResourceDefinitionVersion(io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinitionVersion) Pod(io.fabric8.kubernetes.api.model.Pod) IOException(java.io.IOException) OpenShiftUtils(io.syndesis.qe.utils.OpenShiftUtils) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) Resource(io.syndesis.qe.resource.Resource) CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinition) TestUtils(io.syndesis.qe.utils.TestUtils) ServiceAccount(io.fabric8.kubernetes.api.model.ServiceAccount) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) JSONArray(org.json.JSONArray) InputStream(java.io.InputStream) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) ArrayList(java.util.ArrayList) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) WaiterException(cz.xtf.core.waiting.WaiterException) Image(io.syndesis.qe.image.Image) LocalObjectReference(io.fabric8.kubernetes.api.model.LocalObjectReference) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig)

Aggregations

Pod (io.fabric8.kubernetes.api.model.Pod)2 DeploymentConfig (io.fabric8.openshift.api.model.DeploymentConfig)2 Addon (io.syndesis.qe.addon.Addon)2 Component (io.syndesis.qe.component.Component)2 ComponentUtils (io.syndesis.qe.component.ComponentUtils)2 ResourceFactory (io.syndesis.qe.resource.ResourceFactory)2 OpenShiftUtils (io.syndesis.qe.utils.OpenShiftUtils)2 TestUtils (io.syndesis.qe.utils.TestUtils)2 OpenShiftWaitUtils (io.syndesis.qe.wait.OpenShiftWaitUtils)2 File (java.io.File)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Set (java.util.Set)2 TimeoutException (java.util.concurrent.TimeoutException)2 Slf4j (lombok.extern.slf4j.Slf4j)2 IOUtils (org.apache.commons.io.IOUtils)2