Skip to content

Commit

Permalink
fix apache#693: add e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaferraro committed Jun 20, 2019
1 parent e05ff80 commit f027db3
Show file tree
Hide file tree
Showing 17 changed files with 668 additions and 436 deletions.
40 changes: 40 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 27 additions & 13 deletions test/cluster_integration_test.go → e2e/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,39 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package test
package e2e

import (
"testing"
"time"

"github.com/apache/camel-k/pkg/install"
"github.com/stretchr/testify/assert"
"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
. "github.com/onsi/gomega"
)

func TestInstallation(t *testing.T) {
installedCtxCRD, err := install.IsCRDInstalled(testContext, testClient, "IntegrationKit")
assert.Nil(t, err)
assert.True(t, installedCtxCRD)
func TestKitJVMFullBuild(t *testing.T) {
doNamedKitFullBuild(t, "jvm")
}

func TestKitGroovyFullBuild(t *testing.T) {
doNamedKitFullBuild(t, "groovy")
}

installedCRD, err := install.IsCRDInstalled(testContext, testClient, "Integration")
assert.Nil(t, err)
assert.True(t, installedCRD)
func TestKitKotlinFullBuild(t *testing.T) {
doNamedKitFullBuild(t, "kotlin")
}

func TestKitHealthFullBuild(t *testing.T) {
doNamedKitFullBuild(t, "knative")
}

installedClusterRole, err := install.IsClusterRoleInstalled(testContext, testClient)
assert.Nil(t, err)
assert.True(t, installedClusterRole)
func doNamedKitFullBuild(t *testing.T, name string) {
withNewTestNamespace(func(ns string) {
RegisterTestingT(t)
Expect(kamel("install", "-n", ns, "--kit", name).Execute()).Should(BeNil())
Eventually(build(ns, name)).ShouldNot(BeNil())
Eventually(func() v1alpha1.BuildPhase {
return build(ns, name)().Status.Phase
}, 5*time.Minute).Should(Equal(v1alpha1.BuildPhaseSucceeded))
})
}
28 changes: 28 additions & 0 deletions e2e/files/Java.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import org.apache.camel.builder.RouteBuilder;

public class Java extends RouteBuilder {
@Override
public void configure() throws Exception {
from("timer:tick")
.setHeader("m").constant("string!")
.setBody().simple("Magic${header.m}")
.log("${body}");
}
}
23 changes: 23 additions & 0 deletions e2e/files/groovy.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

from('timer:groovy?period=1s')
.routeId('groovy')
.setHeader("m").constant("string!")
.setBody()
.simple('Magic${header.m}')
.to('log:info?showAll=false')
21 changes: 21 additions & 0 deletions e2e/files/js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

from('timer:js?period=1s')
.routeId('js')
.setHeader("m").constant("string!")
.setBody()
.simple('Magic${header.m}')
.to('log:info')
23 changes: 23 additions & 0 deletions e2e/files/kotlin.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

from("timer:kotlin?period=1s")
.routeId("kotlin")
.setHeader("m").constant("string!")
.setBody()
.simple("Magic\${header.m}")
.to("log:info")
33 changes: 33 additions & 0 deletions e2e/files/xml.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://camel.apache.org/schema/spring"
xsi:schemaLocation="
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">

<route id="hello">
<from uri="timer:hello?period=3s"/>
<setHeader headerName="m">
<constant>string!</constant>
</setHeader>
<setBody>
<simple>Magic${header.m}</simple>
</setBody>
<to uri="log:info"/>
</route>

</routes>
64 changes: 64 additions & 0 deletions e2e/install_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// +build integration

// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"

/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package e2e

import (
"testing"

. "github.com/onsi/gomega"
)

func TestBasicInstallation(t *testing.T) {
withNewTestNamespace(func(ns string) {
RegisterTestingT(t)
Expect(kamel("install", "-n", ns).Execute()).Should(BeNil())
Eventually(operatorPod(ns)).ShouldNot(BeNil())
})
}

func TestAlternativeImageInstallation(t *testing.T) {
withNewTestNamespace(func(ns string) {
RegisterTestingT(t)
Expect(kamel("install", "-n", ns, "--operatorPod-image", "x/y:latest").Execute()).Should(BeNil())
Eventually(operatorImage(ns)).Should(Equal("x/y:latest"))
})
}

func TestKitJVMInstallation(t *testing.T) {
withNewTestNamespace(func(ns string) {
RegisterTestingT(t)
Expect(kamel("install", "-n", ns, "--kit", "jvm").Execute()).Should(BeNil())
Eventually(build(ns, "jvm")).ShouldNot(BeNil())
})
}

func TestMavenRepositoryInstallation(t *testing.T) {
withNewTestNamespace(func(ns string) {
RegisterTestingT(t)
Expect(kamel("install", "-n", ns, "--maven-repository", "https://my.repo.org/public/").Execute()).Should(BeNil())
Eventually(configmap(ns, "camel-k-maven-settings")).Should(Not(BeNil()))
Eventually(func()string {
return configmap(ns, "camel-k-maven-settings")().Data["settings.xml"]
}).Should(ContainSubstring("https://my.repo.org/public/"))
})
}

Loading

0 comments on commit f027db3

Please sign in to comment.