This repository has been archived by the owner on Oct 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
275 additions
and
15 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
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,86 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.kercoin.magrit</groupId> | ||
<artifactId>magrit</artifactId> | ||
<version>rebecca-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>magrit-robot</artifactId> | ||
<packaging>pom</packaging> | ||
|
||
<name>magrit-robot</name> | ||
<description>Automatated Regression Tests for Magrit.</description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<magrit.installer.directory>${project.build.directory}</magrit.installer.directory> | ||
<magrit.installer.filename>magrit-last.jar</magrit.installer.filename> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>copy-server</id> | ||
<phase>pre-integration-test</phase> | ||
<goals> | ||
<goal>copy</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<artifactItems> | ||
<artifactItem> | ||
<groupId>org.kercoin.magrit</groupId> | ||
<artifactId>magrit-installer</artifactId> | ||
<version>${project.version}</version> | ||
<type>jar</type> | ||
<overWrite>false</overWrite> | ||
<outputDirectory>${magrit.installer.directory}</outputDirectory> | ||
<destFileName>${magrit.installer.filename}</destFileName> | ||
</artifactItem> | ||
</artifactItems> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<version>1.2.1</version> | ||
<executions> | ||
<execution> | ||
<id>integration-tests</id> | ||
<phase>integration-test</phase> | ||
<goals> | ||
<goal>exec</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<executable>bash</executable> | ||
<!-- optional --> | ||
<workingDirectory>${basedir}</workingDirectory> | ||
<arguments> | ||
<argument>run.sh</argument> | ||
<argument>${magrit.installer.directory}/${magrit.installer.filename}</argument> | ||
</arguments> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
|
||
<!--resources> | ||
<resource> | ||
<directory>src/main/bash</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources--> | ||
</build> | ||
|
||
</project> | ||
|
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,91 @@ | ||
#!/bin/bash | ||
|
||
function info { | ||
echo "[INFO]" $* | ||
} | ||
|
||
function error { | ||
echo "[ERROR]" $* | ||
} | ||
|
||
BASEDIR=$(pwd) | ||
|
||
failures=0 | ||
errors=0 | ||
oks=0 | ||
|
||
function lsTestCases { | ||
find . -maxdepth 1 -regex "\./t[0-9]*" -type d | ||
} | ||
|
||
function runTestCase { | ||
local tc=$1 | ||
cd $tc | ||
count=${#tc} | ||
local i=0 | ||
while [ $i -lt $count ]; do | ||
padding="-$padding" | ||
let "i ++" | ||
done | ||
echo "/-- $tc --------------------------------------------------------------------------\\" | ||
ts1=$(date +%s) | ||
ns1=$(date +%N) | ||
PATH=${BASEDIR}/${install_dir}/scripts:$PATH bash run.sh | ||
ec=$? | ||
ts2=$(date +%s) | ||
ns2=$(date +%N) | ||
echo "\\--$padding----------------------------------------------------------------------------/" | ||
sec=$(echo "scale=3; ($ts2 - $ts1) * 1 + $ns2 / 1000000000 - $ns1 / 1000000000" | bc -l) | ||
info "Took ${sec} sec" | ||
if [ $ec -gt 0 ]; then | ||
let "failures ++" | ||
elif [ $ec -lt 0 ]; then | ||
let "errors ++" | ||
else | ||
let "oks ++" | ||
fi | ||
cd $BASEDIR | ||
info "-----------------------------------" | ||
} | ||
|
||
info "-----------------------------------" | ||
info "Running integration tests" | ||
info | ||
|
||
installer=$1 | ||
install_dir='target/local' | ||
rm -rf ${install_dir} | ||
mkdir -p ${install_dir} | ||
|
||
info "Installing..." | ||
java -jar ${installer} --install ${install_dir} > /dev/null | ||
bash ${install_dir}/setup.sh | ||
info "Starting..." | ||
bash ${install_dir}/start.sh > target/output.log & | ||
PID=$(wait-tcp 2022 5) || exit 2 | ||
info "Server started" | ||
info "-----------------------------------" | ||
info "TESTS" | ||
for tc in $(lsTestCases); do | ||
runTestCase $tc | ||
done | ||
mistakes=$(( $failures + $errors )) | ||
total=$(( $oks + $mistakes )) | ||
info "OK: $oks" | ||
info "Failures: $failures" | ||
info "Errors: $errors" | ||
info "Total: $total" | ||
info "-----------------------------------" | ||
info "Killing server" | ||
kill $PID | ||
|
||
info "Done" | ||
|
||
info "-----------------------------------" | ||
if [ $mistakes -eq 0 ]; then | ||
info "TEST SUCCESSED" | ||
else | ||
error "TEST FAILED" | ||
fi | ||
exit $mistakes | ||
|
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,26 @@ | ||
#!/bin/bash | ||
|
||
function check { | ||
if [ $1 -gt 0 ]; then | ||
exit $1 | ||
fi | ||
} | ||
|
||
( | ||
magrit build-log -3 | ||
check $? | ||
) | tee output.log | ||
|
||
lines=$(wc -l <output.log) | ||
|
||
function assert { | ||
test $1 -eq $2 | ||
local ec=$? | ||
if [ $ec -gt 0 ]; then | ||
echo "{assert} Expected $1 but was $2" | ||
exit $ec | ||
fi | ||
} | ||
|
||
assert 4 $lines | ||
|