v1.1.3 : Travis functional testing & minor changes
This commit is contained in:
+25
-9
@@ -3,6 +3,9 @@ sudo: required
|
|||||||
dist: trusty
|
dist: trusty
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
|
- echo "Testing Docker Hub credentials"
|
||||||
|
- docker login -u=$DOCKER_USERNAME -p=$DOCKER_PASSWORD
|
||||||
|
- echo "Docker Hub credentials are working"
|
||||||
- sudo apt-get update -qq
|
- sudo apt-get update -qq
|
||||||
- sudo apt-get install -y software-properties-common
|
- sudo apt-get install -y software-properties-common
|
||||||
- sudo add-apt-repository -y ppa:mc3man/trusty-media
|
- sudo add-apt-repository -y ppa:mc3man/trusty-media
|
||||||
@@ -19,24 +22,37 @@ before_install:
|
|||||||
- sudo apt-get install -y libmysqlclient18
|
- sudo apt-get install -y libmysqlclient18
|
||||||
- sudo apt-get install -y mysql-client
|
- sudo apt-get install -y mysql-client
|
||||||
|
|
||||||
|
install:
|
||||||
|
- export DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
|
||||||
|
- export PACKAGE_NAME="cameradar_*_Debug_Linux"
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: linux
|
- os: linux
|
||||||
env: COMPILER_NAME=gcc CXX=g++-5 CC=gcc-5 CMAKE_CXX_COMPILER=g++-5
|
env: TEST_TYPE='BUILD' WORKDIR='deployment' COMPILER_NAME=gcc CXX=g++-5 CC=gcc-5 CMAKE_CXX_COMPILER=g++-5
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- g++-5
|
||||||
|
sources: &sources
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
- os: linux
|
||||||
|
env: TEST_TYPE='TEST' WORKDIR='test' COMPILER_NAME=gcc CXX=g++-5 CC=gcc-5 CMAKE_CXX_COMPILER=g++-5
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
- g++-5
|
- g++-5
|
||||||
sources: &sources
|
sources: &sources
|
||||||
- llvm-toolchain-precise-3.8
|
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- cd deployment
|
- cd ${WORKDIR}
|
||||||
- ./build_last_package.sh Debug
|
- ./build_last_package.sh Debug
|
||||||
- tar xvf cameradar_*_Debug_Linux.tar.gz
|
- tar xvf ${PACKAGE_NAME}.tar.gz
|
||||||
- cp /home/travis/build/EtixLabs/cameradar/deps/jsoncpp/src/deps.jsoncpp/src/lib_json/libjsoncpp*.so* cameradar_*_Debug_Linux/libraries/
|
- find ${DEPS_DIR} -name "*.so*" -exec cp {} ${PACKAGE_NAME}/libraries \;
|
||||||
- cp /home/travis/build/EtixLabs/cameradar/deps/mysql-connector/lib/libmysqlcppconn.so* cameradar_*_Debug_Linux/libraries/
|
- tar -czvf ${PACKAGE_NAME}.tar.gz ${PACKAGE_NAME}
|
||||||
- tar -czvf cameradar_*_Debug_Linux.tar.gz cameradar_*_Debug_Linux
|
- if [[ "$TEST_TYPE" == "BUILD" ]]; then docker build -t cameradar . && docker run -v /tmp/thumbs:/tmp/thumbs cameradar; else ./test.sh ; fi
|
||||||
- docker build -t cameradar .
|
|
||||||
- docker run -v /tmp/thumbs:/tmp/thumbs cameradar
|
after_success:
|
||||||
|
- echo "Test Success - Branch($TRAVIS_BRANCH) Pull Request($TRAVIS_PULL_REQUEST) Tag($TRAVIS_TAG)"
|
||||||
|
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then echo -e "Push Container to Docker Hub" && docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD && docker tag cameradar $DOCKER_REPO:latest && docker push $DOCKER_REPO; fi
|
||||||
|
|||||||
@@ -2,6 +2,20 @@
|
|||||||
|
|
||||||
This file lists all versions of the repository and precises all changes.
|
This file lists all versions of the repository and precises all changes.
|
||||||
|
|
||||||
|
## v1.1.3
|
||||||
|
|
||||||
|
#### Minor changes :
|
||||||
|
* Added automatic pushes to DockerHub to the travis integration
|
||||||
|
* Made travis configuration file better
|
||||||
|
* Changed the package generation scripts to make them report errors
|
||||||
|
* Removed old etix_rtsp_server binary from the test folder
|
||||||
|
|
||||||
|
#### Bugfixes :
|
||||||
|
* Fixed an issue that made it mandatory to launch tests at least once so that they can work the second time
|
||||||
|
* Fixed an issue that made the golang testing tool not compile in the testing script
|
||||||
|
* Fixed an issue that made the golang testing tool sometimes ignore some tests
|
||||||
|
* The previous known issue has been investigated and we don't know where it came from. However after a night of testing I have been unable to reproduce it, so I will consider it closed
|
||||||
|
|
||||||
## v1.1.2
|
## v1.1.2
|
||||||
|
|
||||||
#### Minor changes :
|
#### Minor changes :
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ project (${PROJECT_NAME})
|
|||||||
|
|
||||||
set (${PROJECT_NAME}_VERSION_MAJOR 1)
|
set (${PROJECT_NAME}_VERSION_MAJOR 1)
|
||||||
set (${PROJECT_NAME}_VERSION_MINOR 1)
|
set (${PROJECT_NAME}_VERSION_MINOR 1)
|
||||||
set (${PROJECT_NAME}_VERSION_PATCH 2)
|
set (${PROJECT_NAME}_VERSION_PATCH 3)
|
||||||
set (${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}${${PROJECT_NAME}_SUFFIX}")
|
set (${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}${${PROJECT_NAME}_SUFFIX}")
|
||||||
|
|
||||||
find_package(Git REQUIRED)
|
find_package(Git REQUIRED)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
[](#license)
|
[](#license)
|
||||||
[](https://hub.docker.com/r/ullaakut/cameradar/)
|
[](https://hub.docker.com/r/ullaakut/cameradar/)
|
||||||
[](https://travis-ci.org/EtixLabs/cameradar)
|
[](https://travis-ci.org/EtixLabs/cameradar)
|
||||||
[](https://github.com/EtixLabs/cameradar/releases/latest)
|
[](https://github.com/EtixLabs/cameradar/releases/latest)
|
||||||
|
|
||||||
|
|
||||||
#### Cameradar allows you to:
|
#### Cameradar allows you to:
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ size_t
|
|||||||
write_data(void* buffer, size_t size, size_t nmemb, void* userp) {
|
write_data(void* buffer, size_t size, size_t nmemb, void* userp) {
|
||||||
// I'm sorry for this
|
// I'm sorry for this
|
||||||
// Forget you ever saw it
|
// Forget you ever saw it
|
||||||
|
(void)userp;
|
||||||
if (not buffer || not size || not nmemb) return 0;
|
if (not buffer || not size || not nmemb) return 0;
|
||||||
|
|
||||||
return size * nmemb;
|
return size * nmemb;
|
||||||
|
|||||||
@@ -5,21 +5,51 @@ COL_RESET=$ESC_SEQ"39;49;00m"
|
|||||||
COL_RED=$ESC_SEQ"31;01m"
|
COL_RED=$ESC_SEQ"31;01m"
|
||||||
COL_GREEN=$ESC_SEQ"32;01m"
|
COL_GREEN=$ESC_SEQ"32;01m"
|
||||||
COL_YELLOW=$ESC_SEQ"33;01m"
|
COL_YELLOW=$ESC_SEQ"33;01m"
|
||||||
COL_BLUE=$ESC_SEQ"34;01m"
|
|
||||||
COL_MAGENTA=$ESC_SEQ"35;01m"
|
|
||||||
COL_CYAN=$ESC_SEQ"36;01m"
|
|
||||||
|
|
||||||
echo -e $COL_YELLOW"Deleting old package ... "$COL_RESET
|
echo -e $COL_YELLOW"Deleting old package ... "$COL_RESET
|
||||||
rm -f cameradar_*_${1:-"Release"}_Linux.tar.gz
|
rm -f cameradar_*_${1:-"Release"}_Linux.tar.gz
|
||||||
echo -e $COL_GREEN"OK!"$COL_RESET
|
echo -e $COL_GREEN"OK!"$COL_RESET
|
||||||
|
|
||||||
echo -e $COL_YELLOW"Creating package ... "$COL_RESET
|
echo -e $COL_YELLOW"Creating package ... "$COL_RESET
|
||||||
cd ..
|
|
||||||
mkdir build
|
cd ..
|
||||||
cd build
|
ret=$?
|
||||||
rm -f cameradar_*_${1:-"Release"}_Linux.tar.gz
|
if [ "$ret" -ne "0" ]; then
|
||||||
cmake .. -DCMAKE_BUILD_TYPE=${1:-"Release"}
|
echo -e $COL_RED"KO!"$COL_RESET;
|
||||||
make package
|
exit 1;
|
||||||
cp cameradar_*_${1:-"Release"}_Linux.tar.gz ../deployment
|
fi
|
||||||
cd ../deployment
|
|
||||||
|
mkdir build
|
||||||
|
|
||||||
|
cd build
|
||||||
|
ret=$?
|
||||||
|
if [ "$ret" -ne "0" ]; then
|
||||||
|
echo -e $COL_RED"KO!"$COL_RESET;
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f cameradar_*_${1:-"Release"}_Linux.tar.gz
|
||||||
|
|
||||||
|
cmake .. -DCMAKE_BUILD_TYPE=${1:-"Release"}
|
||||||
|
ret=$?
|
||||||
|
if [ "$ret" -ne "0" ]; then
|
||||||
|
echo -e $COL_RED"KO!"$COL_RESET;
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
make package
|
||||||
|
ret=$?
|
||||||
|
if [ "$ret" -ne "0" ]; then
|
||||||
|
echo -e $COL_RED"KO!"$COL_RESET;
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp cameradar_*_${1:-"Release"}_Linux.tar.gz ../deployment
|
||||||
|
|
||||||
|
cd ../deployment
|
||||||
|
ret=$?
|
||||||
|
if [ "$ret" -ne "0" ]; then
|
||||||
|
echo -e $COL_RED"KO!"$COL_RESET;
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
echo -e $COL_GREEN"OK!"$COL_RESET
|
echo -e $COL_GREEN"OK!"$COL_RESET
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
+42
-14
@@ -5,23 +5,51 @@ COL_RESET=$ESC_SEQ"39;49;00m"
|
|||||||
COL_RED=$ESC_SEQ"31;01m"
|
COL_RED=$ESC_SEQ"31;01m"
|
||||||
COL_GREEN=$ESC_SEQ"32;01m"
|
COL_GREEN=$ESC_SEQ"32;01m"
|
||||||
COL_YELLOW=$ESC_SEQ"33;01m"
|
COL_YELLOW=$ESC_SEQ"33;01m"
|
||||||
COL_BLUE=$ESC_SEQ"34;01m"
|
|
||||||
COL_MAGENTA=$ESC_SEQ"35;01m"
|
|
||||||
COL_CYAN=$ESC_SEQ"36;01m"
|
|
||||||
|
|
||||||
echo -e $COL_YELLOW"Deleting old package ... "$COL_RESET
|
echo -e $COL_YELLOW"Deleting old package ... "$COL_RESET
|
||||||
rm -f cameradar_*_Debug_Linux.tar.gz
|
rm -f cameradar_*_${1:-"Release"}_Linux.tar.gz
|
||||||
echo -e $COL_GREEN"OK!"$COL_RESET
|
echo -e $COL_GREEN"OK!"$COL_RESET
|
||||||
|
|
||||||
echo -e $COL_YELLOW"Creating package ... "$COL_RESET
|
echo -e $COL_YELLOW"Creating package ... "$COL_RESET
|
||||||
{
|
|
||||||
cd ..
|
cd ..
|
||||||
mkdir build
|
ret=$?
|
||||||
cd build
|
if [ "$ret" -ne "0" ]; then
|
||||||
rm -f cameradar_*_Debug_Linux.tar.gz
|
echo -e $COL_RED"KO!"$COL_RESET;
|
||||||
cmake .. -DCMAKE_BUILD_TYPE=Debug
|
exit 1;
|
||||||
make package
|
fi
|
||||||
cp cameradar_*_Debug_Linux.tar.gz ../test
|
|
||||||
cd ../test
|
mkdir build
|
||||||
} &> /dev/null
|
|
||||||
|
cd build
|
||||||
|
ret=$?
|
||||||
|
if [ "$ret" -ne "0" ]; then
|
||||||
|
echo -e $COL_RED"KO!"$COL_RESET;
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f cameradar_*_${1:-"Release"}_Linux.tar.gz
|
||||||
|
|
||||||
|
cmake .. -DCMAKE_BUILD_TYPE=${1:-"Release"}
|
||||||
|
ret=$?
|
||||||
|
if [ "$ret" -ne "0" ]; then
|
||||||
|
echo -e $COL_RED"KO!"$COL_RESET;
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
make package
|
||||||
|
ret=$?
|
||||||
|
if [ "$ret" -ne "0" ]; then
|
||||||
|
echo -e $COL_RED"KO!"$COL_RESET;
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp cameradar_*_${1:-"Release"}_Linux.tar.gz ../test
|
||||||
|
|
||||||
|
cd ../test
|
||||||
|
ret=$?
|
||||||
|
if [ "$ret" -ne "0" ]; then
|
||||||
|
echo -e $COL_RED"KO!"$COL_RESET;
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
echo -e $COL_GREEN"OK!"$COL_RESET
|
echo -e $COL_GREEN"OK!"$COL_RESET
|
||||||
|
|||||||
Binary file not shown.
@@ -14,6 +14,12 @@ cp /tmp/tests/*.xml ./
|
|||||||
# run test
|
# run test
|
||||||
./cameradartest /tmp/tests/cameradartest.conf.json
|
./cameradartest /tmp/tests/cameradartest.conf.json
|
||||||
|
|
||||||
|
ret=$?
|
||||||
|
|
||||||
|
echo "Tests exited with code ${ret}"
|
||||||
|
|
||||||
cat *.xml
|
cat *.xml
|
||||||
|
|
||||||
cp *.xml /tmp/tests/
|
cp *.xml /tmp/tests/
|
||||||
|
|
||||||
|
exit $ret
|
||||||
|
|||||||
@@ -13,5 +13,10 @@ else
|
|||||||
url="rtsp://$user:$passw@:$port/$route"
|
url="rtsp://$user:$passw@:$port/$route"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
./camera_emulation_server -u $2 -p $3 -r $4
|
if [ "$2" == "" && "$3" == "" ]; then
|
||||||
|
./camera_emulation_server -r $4
|
||||||
|
else
|
||||||
|
./camera_emulation_server -u $2 -p $3 -r $4
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Stream started on ${url}"
|
echo "Stream started on ${url}"
|
||||||
|
|||||||
Binary file not shown.
+1
-1
@@ -43,7 +43,7 @@ func (t *Tester) dropDB() bool {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
fmt.Println("------ Dropped CCTV Database -------")
|
fmt.Println("------ Dropped Cameradar Database -------")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"database/sql"
|
|
||||||
_ "github.com/go-sql-driver/mysql"
|
|
||||||
"fmt"
|
|
||||||
"strconv"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (m *manager) dropDB() bool {
|
|
||||||
dsn := m.DB.User + ":" + m.DB.Password + "@" + "tcp(" + m.DB.Host + ":" + strconv.Itoa(m.DB.Port) + ")/" + m.DB.Db_name + "?charset=utf8"
|
|
||||||
db, err := sql.Open("mysql", dsn)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
}
|
|
||||||
defer db.Close()
|
|
||||||
q := "DROP DATABASE cctv;"
|
|
||||||
_, err = db.Exec(q)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
}
|
|
||||||
fmt.Println("------ Dropped CCTV Database -------")
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Launch it via goroutine
|
|
||||||
// Start read log of service
|
|
||||||
func getResult(test *[]Result, resultPath string) bool {
|
|
||||||
// Load config
|
|
||||||
resultFile, err := os.Open(resultPath)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("\nCan't open result file: %s\n", err)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
dec := json.NewDecoder(resultFile)
|
|
||||||
if err = dec.Decode(&test); err != nil {
|
|
||||||
fmt.Printf("\nUnable to deserialize result file: %s\n", err)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
+3
-1
@@ -16,6 +16,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -38,7 +39,8 @@ func main() {
|
|||||||
fmt.Println("--- Writing results... ---")
|
fmt.Println("--- Writing results... ---")
|
||||||
if !Tester.WriteResults(*(Tester.Result), Tester.Output) {
|
if !Tester.WriteResults(*(Tester.Result), Tester.Output) {
|
||||||
fmt.Println("-> Write results FAILED")
|
fmt.Println("-> Write results FAILED")
|
||||||
return
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
fmt.Println("--- Writing results done ---")
|
fmt.Println("--- Writing results done ---")
|
||||||
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"sync"
|
|
||||||
)
|
|
||||||
|
|
||||||
type manager struct {
|
|
||||||
Config
|
|
||||||
|
|
||||||
Tests []Result
|
|
||||||
Result *TestCase
|
|
||||||
DB mysql_db
|
|
||||||
}
|
|
||||||
|
|
||||||
// Config needs refacto
|
|
||||||
type Config struct {
|
|
||||||
Cameradar Service `json:"Cameradar"`
|
|
||||||
|
|
||||||
Output string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *manager) Init() bool {
|
|
||||||
fmt.Println("- Parsing")
|
|
||||||
if !m.parseConfig() {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("- Cleaning content")
|
|
||||||
killService(&m.Config.Cameradar)
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *manager) Run() bool {
|
|
||||||
var wg sync.WaitGroup
|
|
||||||
|
|
||||||
fmt.Println("\n- Launching all tests")
|
|
||||||
var newTest = new(TestCase)
|
|
||||||
newTest.expected = m.Tests
|
|
||||||
if m.generateConfig(m.Tests, &m.DB) {
|
|
||||||
m.dropDB()
|
|
||||||
wg.Add(1)
|
|
||||||
go m.invokeTestCase(newTest, &wg)
|
|
||||||
m.Result = newTest
|
|
||||||
}
|
|
||||||
wg.Wait()
|
|
||||||
fmt.Printf("All tests completed\n")
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *manager) Stop() bool {
|
|
||||||
killService(&m.Config.Cameradar)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
+1
-1
@@ -55,7 +55,7 @@ func getResult(test *[]Result, resultPath string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func isValid(e Result, r Result) bool {
|
func isValid(e *Result, r Result) bool {
|
||||||
if e.Username != r.Username {
|
if e.Username != r.Username {
|
||||||
e.err = errors.New(e.Address + " had a different username than " + r.Username)
|
e.err = errors.New(e.Address + " had a different username than " + r.Username)
|
||||||
return false
|
return false
|
||||||
|
|||||||
+15
-8
@@ -28,6 +28,13 @@ type Test struct {
|
|||||||
time time.Duration
|
time time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func removeResult(expected []Result, index int) []Result {
|
||||||
|
if len(expected) > 1 {
|
||||||
|
return append(expected[:index], expected[index+1:]...)
|
||||||
|
}
|
||||||
|
return []Result{}
|
||||||
|
}
|
||||||
|
|
||||||
// Invoke the test
|
// Invoke the test
|
||||||
// Wrap results in a TestResult object
|
// Wrap results in a TestResult object
|
||||||
func (t *Tester) invokeTestCase(testCase *Test, wg *sync.WaitGroup) {
|
func (t *Tester) invokeTestCase(testCase *Test, wg *sync.WaitGroup) {
|
||||||
@@ -55,14 +62,12 @@ func (t *Tester) runTestCase(test *Test) {
|
|||||||
for _, r := range test.result {
|
for _, r := range test.result {
|
||||||
r.Valid = true
|
r.Valid = true
|
||||||
for index, e := range test.expected {
|
for index, e := range test.expected {
|
||||||
if e.Address == r.Address && isValid(e, r) {
|
if e.Address == r.Address && isValid(&e, r) {
|
||||||
// _, err := os.Stat(r.Thumb)
|
// _, err := os.Stat(r.Thumb)
|
||||||
// if err == nil) {
|
// if err == nil) {
|
||||||
fmt.Println("The result of ", r.Address, " is valid and the thumbnails were generated by Cameradar.")
|
fmt.Println("The result of ", r.Address, " is valid and the thumbnails were generated by Cameradar.")
|
||||||
validResults = Extend(validResults, r)
|
validResults = Extend(validResults, r)
|
||||||
if len(test.expected) > 1 {
|
test.expected = removeResult(test.expected, index)
|
||||||
test.expected = append(test.expected[:index], test.expected[index+1:]...)
|
|
||||||
}
|
|
||||||
break
|
break
|
||||||
// } else {
|
// } else {
|
||||||
// e.err = error{"The result of " + e.Address + " seemed valid, but the thumbnails could not be generated by Cameradar : " + err.Error()}
|
// e.err = error{"The result of " + e.Address + " seemed valid, but the thumbnails could not be generated by Cameradar : " + err.Error()}
|
||||||
@@ -70,15 +75,17 @@ func (t *Tester) runTestCase(test *Test) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for index, e := range test.expected {
|
// This is in order to avoid checking the same values twice
|
||||||
|
copy := test.expected
|
||||||
|
for index, e := range copy {
|
||||||
if !e.Valid {
|
if !e.Valid {
|
||||||
fmt.Println("The result of", e.Address, "successfully failed.")
|
fmt.Println("The result of", e.Address, "successfully failed.")
|
||||||
validResults = Extend(validResults, e)
|
validResults = Extend(validResults, e)
|
||||||
if len(test.expected) > 1 {
|
test.expected = removeResult(test.expected, index)
|
||||||
test.expected = append(test.expected[:index], test.expected[index+1:]...)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
e.err = errors.New("The camera with the address " + e.Address + " was not found by cameradar")
|
e.err = errors.New("The camera with the address " + e.Address + " was not found by cameradar")
|
||||||
|
test.expected = removeResult(test.expected, index)
|
||||||
|
test.expected = Extend(test.expected, e)
|
||||||
fmt.Println("Should have been valid but was not found : ", e.Address)
|
fmt.Println("Should have been valid but was not found : ", e.Address)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-20
@@ -17,6 +17,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@@ -60,9 +61,6 @@ type JUnitFailure struct {
|
|||||||
|
|
||||||
// WriteResults will output the results in the standard output as well as concatenate them in an XML JUnit report
|
// WriteResults will output the results in the standard output as well as concatenate them in an XML JUnit report
|
||||||
func (t *Tester) WriteResults(result Test, output string) bool {
|
func (t *Tester) WriteResults(result Test, output string) bool {
|
||||||
fmt.Printf("Displaying results...\n")
|
|
||||||
t.writeConsoleReport(result)
|
|
||||||
|
|
||||||
file, err := os.OpenFile(output, os.O_RDONLY|os.O_CREATE, 0644)
|
file, err := os.OpenFile(output, os.O_RDONLY|os.O_CREATE, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error opening XML: %s\n", err)
|
fmt.Printf("Error opening XML: %s\n", err)
|
||||||
@@ -72,7 +70,7 @@ func (t *Tester) WriteResults(result Test, output string) bool {
|
|||||||
|
|
||||||
err = t.writeJUnitReportXML(result, file, output)
|
err = t.writeJUnitReportXML(result, file, output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error writing XML: %s\n", err)
|
fmt.Printf("The tests were unsuccessful: %s\n", err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
fmt.Printf("-> JUnit XML report written: %s\n", output)
|
fmt.Printf("-> JUnit XML report written: %s\n", output)
|
||||||
@@ -93,7 +91,7 @@ func (t *Tester) writeJUnitReportXML(result Test, rw io.ReadWriter, output strin
|
|||||||
|
|
||||||
ts := JUnitTestSuite{
|
ts := JUnitTestSuite{
|
||||||
Tests: len(result.result) + len(result.expected),
|
Tests: len(result.result) + len(result.expected),
|
||||||
Failures: 0,
|
Failures: len(result.expected),
|
||||||
Time: fmt.Sprintf("%.6f", result.time.Seconds()),
|
Time: fmt.Sprintf("%.6f", result.time.Seconds()),
|
||||||
TestCases: []JUnitTestCase{},
|
TestCases: []JUnitTestCase{},
|
||||||
}
|
}
|
||||||
@@ -103,7 +101,7 @@ func (t *Tester) writeJUnitReportXML(result Test, rw io.ReadWriter, output strin
|
|||||||
Time: fmt.Sprintf("%.6f", result.time.Seconds()),
|
Time: fmt.Sprintf("%.6f", result.time.Seconds()),
|
||||||
Failure: nil,
|
Failure: nil,
|
||||||
}
|
}
|
||||||
testCase.Message = "The stream " + r.Address + " could be accessed and its thumbnail was properly generated"
|
testCase.Message = "The stream " + r.Address + " had the expected result"
|
||||||
ts.TestCases = append(ts.TestCases, testCase)
|
ts.TestCases = append(ts.TestCases, testCase)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,6 +116,24 @@ func (t *Tester) writeJUnitReportXML(result Test, rw io.ReadWriter, output strin
|
|||||||
Type: "",
|
Type: "",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ts.TestCases = append(ts.TestCases, testCase)
|
||||||
|
}
|
||||||
|
|
||||||
|
successCount := 0
|
||||||
|
failureCount := 0
|
||||||
|
for _, test := range ts.TestCases {
|
||||||
|
if test.Failure != nil {
|
||||||
|
failureCount++
|
||||||
|
} else {
|
||||||
|
successCount++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fmt.Println("--- Test summary ---")
|
||||||
|
if successCount > 0 {
|
||||||
|
fmt.Printf("Results: %d/%d (%d%%)\n", successCount, successCount+failureCount, successCount*100/(successCount+failureCount))
|
||||||
|
fmt.Printf("Time: %.6fs\n", result.time.Seconds())
|
||||||
|
} else {
|
||||||
|
fmt.Printf("No test in success\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
suites.TestSuites = append(suites.TestSuites, ts)
|
suites.TestSuites = append(suites.TestSuites, ts)
|
||||||
@@ -134,19 +150,8 @@ func (t *Tester) writeJUnitReportXML(result Test, rw io.ReadWriter, output strin
|
|||||||
}
|
}
|
||||||
writer := io.Writer(w)
|
writer := io.Writer(w)
|
||||||
writer.Write(bytes)
|
writer.Write(bytes)
|
||||||
|
if failureCount > 0 {
|
||||||
|
return errors.New("Some cameras were not successfully accessed.")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tester) writeConsoleReport(result Test) bool {
|
|
||||||
successCount := len(result.result)
|
|
||||||
failureCount := len(result.expected)
|
|
||||||
fmt.Println("--- Test summary ---")
|
|
||||||
if successCount > 0 {
|
|
||||||
fmt.Printf("Results: %d/%d (%d%%)\n", successCount, successCount+failureCount, successCount*100/(successCount+failureCount))
|
|
||||||
fmt.Printf("Time: %.6fs\n", result.time.Seconds())
|
|
||||||
} else {
|
|
||||||
fmt.Printf("No test in success\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -32,9 +32,11 @@ function make_docker_command {
|
|||||||
|
|
||||||
function start_test {
|
function start_test {
|
||||||
./docker/gen_cameras.sh start $1 ./docker/cameratest.conf.tmpl.json
|
./docker/gen_cameras.sh start $1 ./docker/cameratest.conf.tmpl.json
|
||||||
eval $cmd
|
|
||||||
make_docker_command $1
|
make_docker_command $1
|
||||||
|
eval $cmd
|
||||||
|
ret=$?
|
||||||
./docker/gen_cameras.sh stop
|
./docker/gen_cameras.sh stop
|
||||||
|
return $ret
|
||||||
}
|
}
|
||||||
|
|
||||||
# build images
|
# build images
|
||||||
@@ -50,9 +52,11 @@ echo "starting mysql"
|
|||||||
docker pull mysql:5.7
|
docker pull mysql:5.7
|
||||||
docker run --name cameradar-database -e MYSQL_DATABASE=cmrdr -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7
|
docker run --name cameradar-database -e MYSQL_DATABASE=cmrdr -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7
|
||||||
|
|
||||||
start_test 1
|
|
||||||
start_test 5
|
start_test 5
|
||||||
|
ret=$?
|
||||||
|
echo "Tests returned ${ret}"
|
||||||
|
|
||||||
# stop mysql
|
# stop mysql
|
||||||
echo "stopping mysql"
|
echo "stopping mysql"
|
||||||
docker rm -f cameradar-database
|
docker rm -f cameradar-database
|
||||||
|
exit $ret
|
||||||
Reference in New Issue
Block a user