fabric8io / fabric8-forge

Supports JBoss Forge plugins for the Fabric8 iPaaS along with using Forge as a REST service inside Fabric8 DevOps
Apache License 2.0
11 stars 21 forks source link

generate an OOTB system test for imported projects if there isn't one already #335

Closed jstrachan closed 8 years ago

jstrachan commented 8 years ago

we should be able to generate a generic system test for a project like this: https://github.com/fabric8io/fabric8/issues/5326#issuecomment-228323850

import io.fabric8.kubernetes.client.KubernetesClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.junit.Test;
import org.junit.runner.RunWith;

import static io.fabric8.kubernetes.assertions.Assertions.assertThat;

@RunWith(Arquillian.class)
public class KubernetesIntegrationKT {

    @ArquillianResource
    KubernetesClient client;

    @Test
    public void testAppProvisionsRunningPods() throws Exception {
        assertThat(client).deployments().pods().isPodReadyForPeriod();
    }
}

which automatically ensures that the pod for the projects Deployment/DC/RS/RC starts a pod which becomes Ready and stays up for the default amount of time. Given we auto-generate health checks (so far only for spring boot); this is a pretty decent test that catches 80% of errors in packaging and configuring

davsclaus commented 8 years ago

For our own quickstarts / archetypes, can we not just add this in the source code so its already there?

jstrachan commented 8 years ago

for sure - was just thinking of users importing arbitrary maven projects they already have to start using, say, a spring boot app on kubernetes

davsclaus commented 8 years ago

That latest code requires a new fabric8 release I think. But sure we could add to fabric8-setup an option [x] integration tests. That would setup this source code and add those mvn deps and the plugin settings.

So in this quickstart that has an KT test its set to exclude it at https://github.com/fabric8io/ipaas-quickstarts/blob/master/quickstart/spring-boot/camel-amq/pom.xml#L131

So does the integration test CI/CD phase override this and runs all KT tests? Or how does it work to ensure those KT tests are only run there on the kubernetes cluster, and not if the user does a local mvn clean test run.

davsclaus commented 8 years ago

Ah so it looks like there is a maven profile named kit that will run these tests.

I was able to add NewIntegrationTestClassCommand to the fabric8-setup command so its run afterwards and create the integration tests.

davsclaus commented 8 years ago

The fabric8-setup command now adds the integration test out of the box.

We should upgrade the source code to the newer nicer way you can do when we have a new release.