Skip to content

Commit

Permalink
feat(e2e): property test
Browse files Browse the repository at this point in the history
Ref #2003
  • Loading branch information
squakez authored and astefanutti committed May 17, 2021
1 parent 434e08c commit e0b9be1
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 0 deletions.
2 changes: 2 additions & 0 deletions e2e/config/files/my.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
my.key.1=hello
my.key.2=world
27 changes: 27 additions & 0 deletions e2e/config/files/property-file-route.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// camel-k: language=groovy
/*
* 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.
*/

//
// To run this integrations use:
//
// kamel run --property-file my.properties property-file-route.groovy --dev
//

from('timer:property-file')
.routeId('property-file')
.log('property file content is: {{my.key.1}} {{my.key.2}}')
27 changes: 27 additions & 0 deletions e2e/config/files/property-route.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// camel-k: language=groovy
/*
* 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.
*/

//
// To run this integrations use:
//
// kamel run -p my.message=test-property property-route.groovy --dev
//

from('timer:property')
.routeId('property')
.log('property content is: {{my.message}}')
55 changes: 55 additions & 0 deletions e2e/config/properties_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// +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 resources

import (
"testing"

. "github.com/onsi/gomega"

v1 "k8s.io/api/core/v1"

. "github.com/apache/camel-k/e2e/support"
camelv1 "github.com/apache/camel-k/pkg/apis/camel/v1"
)

func TestRunPropertyExamples(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())

t.Run("Simple property", func(t *testing.T) {
Expect(Kamel("run", "-n", ns, "./files/property-route.groovy", "-p", "my.message=test-property").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "property-route"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
Eventually(IntegrationCondition(ns, "property-route", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
Eventually(IntegrationLogs(ns, "property-route"), TestTimeoutShort).Should(ContainSubstring("test-property"))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})

t.Run("Property file", func(t *testing.T) {
Expect(Kamel("run", "-n", ns, "./files/property-file-route.groovy", "--property-file", "./files/my.properties").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "property-file-route"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
Eventually(IntegrationCondition(ns, "property-file-route", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
Eventually(IntegrationLogs(ns, "property-file-route"), TestTimeoutShort).Should(ContainSubstring("hello world"))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
})
}

0 comments on commit e0b9be1

Please sign in to comment.