-
Notifications
You must be signed in to change notification settings - Fork 581
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Setup CI to run tests that require external resources (#191)
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
- Loading branch information
1 parent
6585cf1
commit c318cd3
Showing
7 changed files
with
200 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
# Copyright The OpenTelemetry Authors | ||
# | ||
# Licensed 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. | ||
|
||
# Returns 0 (true) when the current diff contains files in the provided | ||
# target directory. TARGET should be a unique package name in the directory | ||
# structure. For example, for the gocql integration, set TARGET=gocql so that | ||
# a diff in any of the files in the instrumentation/gocql/gocql directory | ||
# will be picked up by the grep. Diffs are compared against the master branch. | ||
|
||
TARGET=$1 | ||
|
||
if [ -z "$TARGET" ]; then | ||
echo "TARGET is undefined" | ||
exit 1 | ||
fi | ||
|
||
if git diff --name-only origin/master HEAD | grep -q "$TARGET"; then | ||
exit 0 | ||
else | ||
echo "no changes found for $TARGET. skipping tests..." | ||
exit 1 | ||
fi | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/bash | ||
|
||
# Copyright The OpenTelemetry Authors | ||
# | ||
# Licensed 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. | ||
|
||
wait_for_cassandra () { | ||
for ((i = 0; i < 5; ++i)); do | ||
if docker exec "$1" nodetool status | grep "^UN"; then | ||
exit 0 | ||
fi | ||
echo "Cassandra not yet available" | ||
sleep 10 | ||
done | ||
echo "Timeout waiting for cassandra to initialize" | ||
exit 1 | ||
} | ||
|
||
wait_for_mongo () { | ||
for ((i = 0; i < 5; ++i)); do | ||
if docker exec "$1" mongo; then | ||
exit 0 | ||
fi | ||
echo "Mongo not yet available..." | ||
sleep 10 | ||
done | ||
echo "Timeout waiting for mongo to initialize" | ||
exit 1 | ||
} | ||
|
||
if [ -z "$CMD" ]; then | ||
echo "CMD is undefined. exiting..." | ||
exit 1 | ||
elif [ -z "$IMG_NAME" ]; then | ||
echo "IMG_NAME is undefined. exiting..." | ||
exit 1 | ||
fi | ||
|
||
if [ "$CMD" == "cassandra" ]; then | ||
wait_for_cassandra "$IMG_NAME" | ||
elif [ "$CMD" == "mongo" ]; then | ||
wait_for_mongo "$IMG_NAME" | ||
else | ||
echo "unknown CMD" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed 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 util | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
func IntegrationShouldRun(name string) { | ||
if val, ok := os.LookupEnv("INTEGRATION"); !ok || val != name { | ||
fmt.Println( | ||
"--- SKIP: to enable integration test, set the INTEGRATION environment variable", | ||
"to", | ||
fmt.Sprintf("\"%s\"", name), | ||
) | ||
os.Exit(0) | ||
} | ||
} |