Skip to content

Commit a55bf7c

Browse files
authored
setup integration tests (#1)
1 parent 7d5be55 commit a55bf7c

4 files changed

Lines changed: 38 additions & 9 deletions

File tree

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ before_script:
5353
|| true
5454
5555
script:
56-
- mvn clean verify $MVN_ARGS
56+
- mvn clean verify $MVN_ARGS
57+
- mvn package
58+
- ./test-integration.sh
5759

5860
# To enable semantic-release, uncomment these sections.
5961
before_deploy:

modules/examples/README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
## Running the example
44

5-
To run the example, create a Code Engine project from the Console or Code Engine CLI. Next, set the following environment variables in the shell where your Java executables run:
6-
```
7-
CE_API_KEY=<Your IBM Cloud API key>
8-
CE_PROJECT_ID=<Your Code Engine project ID>
9-
CE_PROJECT_REGION=<The region (e.g. 'us-south') of your Code Engine project>
10-
```
11-
Finally, run the `IbmCloudCodeEngineExamples` Class.
5+
To run the example, create a Code Engine project from the Console or Code Engine CLI. Next, from the root directory, set the following environment variables, build the project, and execute the `IbmCloudCodeEngineExamples` class:
6+
1. `export CE_API_KEY=<Your IBM Cloud API key>`
7+
2. `export CE_PROJECT_ID=<Your Code Engine project ID>`
8+
3. `export CE_PROJECT_REGION=<The region (e.g. 'us-south') of your Code Engine project>`
9+
4. `mvn package`
10+
5. `java -jar ./modules/examples/target/code-engine-examples-1.0.0-SNAPSHOT.jar`
1211

1312
## How-to
1413

modules/examples/pom.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@
6868
<configuration>
6969
<archive>
7070
<manifest>
71-
<mainClass>com.ibm.cloud.code-engine-examples.v1.IbmCloudCodeEngineExamples</mainClass>
71+
<addClasspath>true</addClasspath>
72+
<mainClass>com.ibm.cloud.code_engine.ibm_cloud_code_engine.v1.IbmCloudCodeEngineExamples</mainClass>
7273
</manifest>
7374
</archive>
7475
</configuration>
76+
7577
</plugin>
7678
<!-- No need to deploy this artifact -->
7779
<plugin>

test-integration.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Code Engine Java SDK Integration tests
2+
# Requires the following env. variables (provdied to TravisCI)
3+
# - CE_API_KEY: IBM Cloud API Key
4+
# - CE_PROJECT_ID: GUID of Code Engine project to target
5+
# - CE_PROJECT_REGION: region for API URL
6+
7+
echo "Running integration tests..."
8+
9+
# Run example, get exit code
10+
exampleoutput=$(java -jar ./modules/examples/target/code-engine-examples-1.0.0-SNAPSHOT.jar)
11+
exampleexit=$?
12+
if [ $exampleexit -ne 0 ]; then
13+
echo "Integration tests failed with exit code $exampleexit"
14+
echo $exampleoutput
15+
exit $exampleexit
16+
fi
17+
18+
# Check if output is expected
19+
outputcheck="2 configmaps"
20+
if [[ $exampleoutput != *$outputcheck* ]]; then
21+
echo "Intergration test output is incorrect:"
22+
echo "Expected '$exampleoutput' to contain '$outputcheck'"
23+
exit 1
24+
fi
25+
26+
echo "Success!"

0 commit comments

Comments
 (0)