Skip to content

Commit

Permalink
chore(e2e): run option with destination path
Browse files Browse the repository at this point in the history
  • Loading branch information
squakez committed Jun 16, 2021
1 parent d6cc032 commit 8033103
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/cli/modeline.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ The following is a partial list of useful options:
|Add a runtime property or properties file (syntax: _[my-key=my-value\|file:/path/to/my-conf.properties]_)

|resource
|Add a runtime resource from a Configmap, a Secret or a file (syntax: _[configmap\|secret\|file]:name)_
|Add a runtime resource from a Configmap, a Secret or a file (syntax: _[configmap\|secret\|file]:name[@path])_

|trait
|Configure a trait, e.g. `trait=service.enabled=false`
Expand Down
19 changes: 19 additions & 0 deletions e2e/common/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ func TestRunConfigExamples(t *testing.T) {
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})

t.Run("Resource configmap with destination", func(t *testing.T) {
// We can reuse the configmap created previously

Expect(Kamel("run", "-n", ns, "./files/resource-configmap-location-route.groovy", "--resource", "configmap:my-cm@/tmp/app").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "resource-configmap-location-route"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
Eventually(IntegrationCondition(ns, "resource-configmap-location-route", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
Eventually(IntegrationLogs(ns, "resource-configmap-location-route"), TestTimeoutShort).Should(ContainSubstring(cmData["my-configmap-key"]))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})

// Secret

// Store a secret on the cluster
Expand Down Expand Up @@ -125,6 +135,14 @@ func TestRunConfigExamples(t *testing.T) {
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})

t.Run("Plain text resource file with destination path", func(t *testing.T) {
Expect(Kamel("run", "-n", ns, "./files/resource-file-location-route.groovy", "--resource", "file:./files/resources-data.txt@/tmp/file.txt").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "resource-file-location-route"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
Eventually(IntegrationCondition(ns, "resource-file-location-route", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
Eventually(IntegrationLogs(ns, "resource-file-location-route"), TestTimeoutShort).Should(ContainSubstring("the file body"))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})

t.Run("Binary (zip) resource file", func(t *testing.T) {
Expect(Kamel("run", "-n", ns, "./files/resource-file-binary-route.groovy", "--resource", "file:./files/resources-data.zip", "-d", "camel-zipfile").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "resource-file-binary-route"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
Expand Down Expand Up @@ -176,5 +194,6 @@ func TestRunConfigExamples(t *testing.T) {
Eventually(IntegrationLogs(ns, "build-property-file-route"), TestTimeoutShort).Should(ContainSubstring("my-super-application"))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})

})
}
20 changes: 20 additions & 0 deletions e2e/common/config/files/resource-configmap-location-route.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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.
*/

from('file:/tmp/app/?fileName=my-configmap-key&noop=true&idempotent=false')
.log('resource file content is: ${body}')
20 changes: 20 additions & 0 deletions e2e/common/config/files/resource-file-location-route.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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.
*/

from('file:/tmp/?fileName=file.txt&noop=true&idempotent=false')
.log('resource file content is: ${body}')

0 comments on commit 8033103

Please sign in to comment.