This repository has been archived by the owner on May 12, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add helper script to run test from jenkins and provide jenkins job re…
…lated information. Make waits longer to increase propability to pass bogus fails. Do not run fast-data-dev internal tests. Add README for repo. Signed-off-by: Marios Andreopoulos <opensource@andmarios.com>
- Loading branch information
Showing
5 changed files
with
115 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,8 @@ | |
.idea | ||
out.html | ||
coyote.html | ||
/results | ||
latest.html | ||
*-connector.properties.json | ||
/exitcode | ||
/status.txt |
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,44 @@ | ||
# Connector Tests # | ||
|
||
Basic testing of various connectors using docker and coyote. | ||
|
||
|
||
|
||
## Prepare Test Server ## | ||
|
||
For now we use Cloudera03 server. This will hopefully not be a permanent setup | ||
because it gives too much rights to jenkins. | ||
Thus instead of automating the needed steps via ansible, we will document them | ||
here. | ||
|
||
Permit Jenkins user to run docker and generally have some root rights by addding | ||
it to root group: | ||
|
||
sudo usermod -aG docker jenkins | ||
|
||
Install docker compose via an official release since it isn't yet available in | ||
centos. | ||
Visit [compose github release page](https://github.com/docker/compose/releases) | ||
for the latest release. In general, you will run something like this: | ||
|
||
sudo su | ||
curl -L https://github.com/docker/compose/releases/download/1.8.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose | ||
chmod +x /usr/local/bin/docker-compose | ||
|
||
## Running in Jenkins | ||
|
||
We have many tests which we want to run separately and in parallel. This leads | ||
to one jenkins job per test design, which unfortunately is time-consuming to | ||
maintain, as for each little change, we would have to update tens of jenkins' | ||
jobs. | ||
|
||
For this we created the `helpers` directory and there we store scripts we use | ||
to run the tests from jenkins, thus moving the better part of the run logic to | ||
this repo. | ||
|
||
To run a test from Jenkins, you would run something like: | ||
|
||
helpers/jenkins-test-runner.sh kafka-connect-redis | ||
|
||
This runs the tests and creates such files (as status.txt and exitcode) that | ||
the jenkins job can use to set the build name, exit status, etc. |
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,63 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script can be used by jenkins to run the tests. | ||
# We use it to avoid having to manage too many similar jenkins jobs. | ||
# Instead of having to apply a small change to 20 jobs, we apply it here. | ||
# | ||
# The only argument it takes is the test directory name. | ||
|
||
set -e | ||
|
||
TEST_DIR="$1" | ||
RESULTS_DIR="results" | ||
|
||
# Set current dir (which should be repo's top dir) to workspace so we can test | ||
# outside jenkins | ||
WORKSPACE="${WORKSPACE:-$(pwd)}" | ||
|
||
# Remove old files it they exist: | ||
rm -f "$WORKSPACE"/status.txt | ||
rm -f "$WORKSPACE"/exitcode | ||
|
||
# Check if test directory exists | ||
if [[ ! -d "$1" ]]; then | ||
echo "Test directory not found. The '\$1' argument is: $1." | ||
exit 255 | ||
fi | ||
|
||
# Download latest Coyote | ||
COYOTE=coyote-1.0-amd64 | ||
wget -nc https://github.com/Landoop/coyote/releases/download/v1.0/$COYOTE | ||
chmod +x $COYOTE | ||
|
||
# Set path for jenkins | ||
export PATH="$PATH:/usr/local/bin" | ||
alias docker-compose="sudo /usr/local/bin/docker-compose" | ||
|
||
# cd into workdir and run coyote | ||
pushd "$TEST_DIR" | ||
set +e | ||
$WORKSPACE/$COYOTE | ||
EXITCODE="$?" | ||
set -e | ||
popd | ||
|
||
# Store error number for jenkins build name | ||
if [[ $EXITCODE -eq 0 ]]; then | ||
echo "" > "$WORKSPACE"/status.txt | ||
elif [[ $EXITCODE -eq 1 ]]; then | ||
echo "_${EXITCODE}_err" > "$WORKSPACE"/status.txt | ||
else | ||
echo "_${EXITCODE}_errs" > "$WORKSPACE"/status.txt | ||
fi | ||
|
||
# Store exitcode to use for output | ||
echo "$EXITCODE" > "$WORKSPACE"/exitcode | ||
|
||
|
||
# Copy test results to results directory | ||
mkdir -p "$RESULTS_DIR" | ||
DATE="$(date '+%Y%m%d-%H%M')" | ||
cp "$TEST_DIR"/coyote.html "$RESULTS_DIR"/"$(basename ${TEST_DIR})-${DATE}$(cat status.txt).html" | ||
rm -f latest.html | ||
mv "$TEST_DIR"/coyote.html latest.html |
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