You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2020/03/04 14:53:11 UTC

[GitHub] [camel-k] bouskaJ opened a new pull request #1324: [ADD] Add rest test

bouskaJ opened a new pull request #1324: [ADD] Add rest test
URL: https://github.com/apache/camel-k/pull/1324
 
 
   Add test for REST service. This test covers:
   - REST DSL route
   - dependency trait (see `"run", "-n", ns, "files/RestConsumer.java", "-d", "camel:undertow`
   - custom properties (`"run", "-n", ns, "files/RestProducer.groovy", "-p", "serviceIp="+service().Spec.ClusterIP, "-p", "name="+name`)
   - service trait
   - route trait

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-k] nicolaferraro merged pull request #1324: [ADD] Add rest test

Posted by GitBox <gi...@apache.org>.
nicolaferraro merged pull request #1324: [ADD] Add rest test
URL: https://github.com/apache/camel-k/pull/1324
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-k] bouskaJ commented on a change in pull request #1324: [ADD] Add rest test

Posted by GitBox <gi...@apache.org>.
bouskaJ commented on a change in pull request #1324: [ADD] Add rest test
URL: https://github.com/apache/camel-k/pull/1324#discussion_r387748146
 
 

 ##########
 File path: e2e/rest_test.go
 ##########
 @@ -0,0 +1,86 @@
+// +build integration
+
+// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "knative"
+
+/*
+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 (
+	"fmt"
+	"net/http"
+	"testing"
+	"bytes"
+
+	"github.com/apache/camel-k/pkg/util/openshift"
+	. "github.com/onsi/gomega"
+	"github.com/stretchr/testify/assert"
+	v1 "k8s.io/api/core/v1"
+)
+
+func TestRunREST(t *testing.T) {
+	withNewTestNamespace(t, func(ns string) {
+		var profile string
+		ocp, err := openshift.IsOpenShift(testClient)
+		assert.Nil(t, err)
+		if ocp {
+			profile = "OpenShift"
+		} else {
+			profile = "Kubernetes"
+		}
+
+		Expect(kamel("install", "-n", ns, "--trait-profile", profile).Execute()).Should(BeNil())
+		Expect(kamel("run", "-n", ns, "files/RestConsumer.java", "-d", "camel:undertow").Execute()).Should(BeNil())
+		Eventually(integrationPodPhase(ns, "rest-consumer"), testTimeoutMedium).Should(Equal(v1.PodRunning))
+
+		t.Run("Service works", func(t *testing.T) {
+			name := "John"
+			service := service(ns, "rest-consumer")
+			Eventually(service, testTimeoutShort).ShouldNot(BeNil())
+			Expect(kamel("run", "-n", ns, "files/RestProducer.groovy", "-p", "serviceIp="+service().Spec.ClusterIP, "-p", "name="+name).Execute()).Should(BeNil())
 
 Review comment:
   Fixed.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-k] bouskaJ commented on issue #1324: [ADD] Add rest test

Posted by GitBox <gi...@apache.org>.
bouskaJ commented on issue #1324: [ADD] Add rest test
URL: https://github.com/apache/camel-k/pull/1324#issuecomment-597019486
 
 
   @nicolaferraro It does not seem that CI failed because of my changes.
   
   ```
   === RUN   TestRunREST
   Camel K installed in namespace test-ed54d5f2-cbe2-453f-998e-015f6bacd6c1 
   integration "rest-consumer" created
   === RUN   TestRunREST/Service_works
   integration "rest-producer" created
   2 integration(s) deleted
   --- PASS: TestRunREST (89.55s)
       --- PASS: TestRunREST/Service_works (42.78s)
   ```
   Is there any way how to rerun the CI?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-k] heiko-braun commented on issue #1324: [ADD] Add rest test

Posted by GitBox <gi...@apache.org>.
heiko-braun commented on issue #1324: [ADD] Add rest test
URL: https://github.com/apache/camel-k/pull/1324#issuecomment-597508531
 
 
   Thanks @bouskaJ !

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-k] bouskaJ commented on a change in pull request #1324: [ADD] Add rest test

Posted by GitBox <gi...@apache.org>.
bouskaJ commented on a change in pull request #1324: [ADD] Add rest test
URL: https://github.com/apache/camel-k/pull/1324#discussion_r387747978
 
 

 ##########
 File path: e2e/rest_test.go
 ##########
 @@ -0,0 +1,86 @@
+// +build integration
+
+// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "knative"
+
+/*
+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 (
+	"fmt"
+	"net/http"
+	"testing"
+	"bytes"
+
+	"github.com/apache/camel-k/pkg/util/openshift"
+	. "github.com/onsi/gomega"
+	"github.com/stretchr/testify/assert"
+	v1 "k8s.io/api/core/v1"
+)
+
+func TestRunREST(t *testing.T) {
+	withNewTestNamespace(t, func(ns string) {
+		var profile string
+		ocp, err := openshift.IsOpenShift(testClient)
+		assert.Nil(t, err)
+		if ocp {
+			profile = "OpenShift"
+		} else {
+			profile = "Kubernetes"
+		}
+
+		Expect(kamel("install", "-n", ns, "--trait-profile", profile).Execute()).Should(BeNil())
+		Expect(kamel("run", "-n", ns, "files/RestConsumer.java", "-d", "camel:undertow").Execute()).Should(BeNil())
+		Eventually(integrationPodPhase(ns, "rest-consumer"), testTimeoutMedium).Should(Equal(v1.PodRunning))
+
+		t.Run("Service works", func(t *testing.T) {
+			name := "John"
+			service := service(ns, "rest-consumer")
+			Eventually(service, testTimeoutShort).ShouldNot(BeNil())
+			Expect(kamel("run", "-n", ns, "files/RestProducer.groovy", "-p", "serviceIp="+service().Spec.ClusterIP, "-p", "name="+name).Execute()).Should(BeNil())
 
 Review comment:
   You are right. Thank you for the suggestion. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-k] nicolaferraro commented on issue #1324: [ADD] Add rest test

Posted by GitBox <gi...@apache.org>.
nicolaferraro commented on issue #1324: [ADD] Add rest test
URL: https://github.com/apache/camel-k/pull/1324#issuecomment-597038258
 
 
   I restarted them from the action panel

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-k] nicolaferraro commented on a change in pull request #1324: [ADD] Add rest test

Posted by GitBox <gi...@apache.org>.
nicolaferraro commented on a change in pull request #1324: [ADD] Add rest test
URL: https://github.com/apache/camel-k/pull/1324#discussion_r387721438
 
 

 ##########
 File path: e2e/rest_test.go
 ##########
 @@ -0,0 +1,86 @@
+// +build integration
+
+// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "knative"
+
+/*
+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 (
+	"fmt"
+	"net/http"
+	"testing"
+	"bytes"
+
+	"github.com/apache/camel-k/pkg/util/openshift"
+	. "github.com/onsi/gomega"
+	"github.com/stretchr/testify/assert"
+	v1 "k8s.io/api/core/v1"
+)
+
+func TestRunREST(t *testing.T) {
+	withNewTestNamespace(t, func(ns string) {
+		var profile string
+		ocp, err := openshift.IsOpenShift(testClient)
+		assert.Nil(t, err)
+		if ocp {
+			profile = "OpenShift"
+		} else {
+			profile = "Kubernetes"
+		}
+
+		Expect(kamel("install", "-n", ns, "--trait-profile", profile).Execute()).Should(BeNil())
+		Expect(kamel("run", "-n", ns, "files/RestConsumer.java", "-d", "camel:undertow").Execute()).Should(BeNil())
+		Eventually(integrationPodPhase(ns, "rest-consumer"), testTimeoutMedium).Should(Equal(v1.PodRunning))
+
+		t.Run("Service works", func(t *testing.T) {
+			name := "John"
+			service := service(ns, "rest-consumer")
+			Eventually(service, testTimeoutShort).ShouldNot(BeNil())
+			Expect(kamel("run", "-n", ns, "files/RestProducer.groovy", "-p", "serviceIp="+service().Spec.ClusterIP, "-p", "name="+name).Execute()).Should(BeNil())
+			Eventually(integrationPodPhase(ns, "rest-producer"), testTimeoutMedium).Should(Equal(v1.PodRunning))
+			Eventually(integrationLogs(ns, "rest-consumer"), testTimeoutShort).Should(ContainSubstring(fmt.Sprintf("get %s", name)))
+			Eventually(integrationLogs(ns, "rest-producer"), testTimeoutShort).Should(ContainSubstring(fmt.Sprintf("%s Doe", name)))
+		})
+
+		if ocp {
+			t.Run("Route works", func(t *testing.T) {
+				name := "Peter"
+				route := route(ns, "rest-consumer")
+				Eventually(route, testTimeoutShort).ShouldNot(BeNil())
+				response := httpReqest(t, fmt.Sprintf("http://%s/customers/%s", route().Spec.Host, name))
+				assert.Equal(t, fmt.Sprintf("%s Doe", name), response)
 
 Review comment:
   Awesome

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-k] nicolaferraro commented on a change in pull request #1324: [ADD] Add rest test

Posted by GitBox <gi...@apache.org>.
nicolaferraro commented on a change in pull request #1324: [ADD] Add rest test
URL: https://github.com/apache/camel-k/pull/1324#discussion_r387724815
 
 

 ##########
 File path: e2e/rest_test.go
 ##########
 @@ -0,0 +1,86 @@
+// +build integration
+
+// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "knative"
+
+/*
+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 (
+	"fmt"
+	"net/http"
+	"testing"
+	"bytes"
+
+	"github.com/apache/camel-k/pkg/util/openshift"
+	. "github.com/onsi/gomega"
+	"github.com/stretchr/testify/assert"
+	v1 "k8s.io/api/core/v1"
+)
+
+func TestRunREST(t *testing.T) {
+	withNewTestNamespace(t, func(ns string) {
+		var profile string
+		ocp, err := openshift.IsOpenShift(testClient)
+		assert.Nil(t, err)
+		if ocp {
+			profile = "OpenShift"
+		} else {
+			profile = "Kubernetes"
+		}
+
+		Expect(kamel("install", "-n", ns, "--trait-profile", profile).Execute()).Should(BeNil())
+		Expect(kamel("run", "-n", ns, "files/RestConsumer.java", "-d", "camel:undertow").Execute()).Should(BeNil())
+		Eventually(integrationPodPhase(ns, "rest-consumer"), testTimeoutMedium).Should(Equal(v1.PodRunning))
+
+		t.Run("Service works", func(t *testing.T) {
+			name := "John"
+			service := service(ns, "rest-consumer")
+			Eventually(service, testTimeoutShort).ShouldNot(BeNil())
+			Expect(kamel("run", "-n", ns, "files/RestProducer.groovy", "-p", "serviceIp="+service().Spec.ClusterIP, "-p", "name="+name).Execute()).Should(BeNil())
 
 Review comment:
   ```suggestion
   			Expect(kamel("run", "-n", ns, "files/RestProducer.groovy", "-p", "serviceIp=rest-consumer", "-p", "name="+name).Execute()).Should(BeNil())
   ```
   
   Shouldn't this be enough? We usually tell users to use DNS

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services