Skip to content
Snippets Groups Projects
Commit 2339dbef authored by Rafael S Castilho's avatar Rafael S Castilho
Browse files

SCRUM#82: added tests to the new scripts

parent b9c1c79c
No related branches found
No related tags found
2 merge requests!103Merge dev -> master,!49SCRUM#82: created scripts to generate and install the agent
Pipeline #
......@@ -19,13 +19,13 @@ compile:
stage: build
artifacts:
paths:
- bin/
- agent-1234.run
tags:
- regular
- debian
script:
- echo "Estágio 'build'"
- apt-get update && apt-get install -y build-essential cmake git makeself
- apt-get update && apt-get install -y build-essential cmake git makeself
libudev-dev
- git submodule init
- git submodule update --init --recursive
......@@ -34,9 +34,9 @@ compile:
- cmake -DCURL_STATICLIB=ON ..
- make
- cd ..
- makeself --notemp --noprogress bin/ agent.run "" ./agent-v0.0 --once --print
- chmod +x agent.run
- mv agent.run bin/
- chmod +x generate_agent.sh
- ./generate_agent.sh -idp=1234 -ws=www.C3Sl.ufpr.br -pch=mumm -pcp=6666 -pcu=ninguem -pcpasswd=123mudar
- chmod +x agent-1234.run
testDebian:
stage: test
......@@ -44,7 +44,7 @@ testDebian:
- regular
- debian
script:
- apt-get update && apt-get install -y git jq faketime expect
- apt-get update && apt-get install -y git jq faketime expect cron
- git clone https://github.com/sstephenson/bats.git
- cd bats
- ./install.sh /usr
......@@ -61,7 +61,7 @@ testUbuntu:
- ubuntu
- regular
script:
- apt-get update && apt-get install -y bats jq faketime expect
- apt-get update && apt-get install -y bats jq faketime expect cron
- cd test
- ./create_users.sh
- last -F
......
......@@ -20,16 +20,9 @@
# USA.
mkdir agentC3SL
mkdir agentC3SL/tmp
cp bin/agent* agentC3SL/
mkdir agentC3SL/conf
cd agentC3SL/conf
touch datasid-conf.json
touch proxy.json
# idpoint proxyConf( host porta usr passwd ) webService
idPoint=""
idPoint="0"
webService=""
host=""
port=""
......@@ -66,7 +59,7 @@ for i in $@; do
usr="${i#*=}"
shift
;;
-pcpssd=*)
-pcpasswd=*)
passwd="${i#*=}"
shift
;;
......@@ -76,18 +69,37 @@ for i in $@; do
esac
done
mkdir $idPoint
mkdir $idPoint/agentC3SL
mkdir $idPoint/agentC3SL/tmp
cp bin/agent* $idPoint/agentC3SL/
mkdir $idPoint/agentC3SL/conf
cd $idPoint/agentC3SL/conf
touch datasid-conf.json
touch proxy.json
tmp=$(cat ../../conf/proxy-conf.json)
tmp=$(cat ../../../conf/proxy-conf.json)
printf "$tmp\n" $host $port $usr $passwd > proxy.json
tmp=$(cat ../../conf/datasid-conf.json)
tmp=$(cat ../../../conf/datasid-conf.json)
printf "$tmp\n" $idPoint /opt/agentC3SL/conf/proxy.json $webService > datasid-conf.json
cd ../../
cd ../../..
cp install_agent.sh $idPoint/agentC3SL/
makeself --notemp --noprogress $idPoint/agentC3SL/ agent-$idPoint.run "" ./install_agent.sh
rm -rf $idPoint
cp install_agent.sh agentC3SL/
makeself --notemp --noprogress agentC3SL/ agent.run "" ./install_agent.sh
rm -rf agentC3SL
......@@ -21,6 +21,15 @@
cd ..
mkdir tmp
cd tmp
if test -d /opt/agentC3SL; then
cp /opt/agentC3SL/conf/* . && rm ../agentC3SL/conf/* && mv ./* ../agentC3SL/conf/
fi
cd ..
rm -rf tmp
rm -rf /opt/agentC3SL
mv agentC3SL /opt/
cd /opt/agentC3SL
(crontab -l 2>/dev/null; echo "@reboot /opt/agentC3SL/agent-v*")| crontab -
......
......@@ -63,8 +63,39 @@ function packets_transmitted() {
[[ "$obj" -ge 0 ]]
}
function password() {
obj=$(cat /opt/agentC3SL/conf/proxy.json | jq -r '.password')
[[ "$obj" == "123mudar" ]]
}
function user () {
obj=$(cat /opt/agentC3SL/conf/proxy.json | jq -r '.usr')
[[ "$obj" == "ninguem" ]]
}
function port() {
obj=$(cat /opt/agentC3SL/conf/proxy.json | jq -r '.port')
[[ "$obj" -eq 6666 ]]
}
function host() {
obj=$(cat /opt/agentC3SL/conf/proxy.json | jq -r '.host')
[[ "$obj" == "mumm" ]]
}
function web_service() {
obj=$(cat /opt/agentC3SL/conf/datasid-conf.json | jq -r '.webService')
[[ "$obj" == "www.C3Sl.ufpr.br" ]]
}
function id_point() {
obj=$(cat /opt/agentC3SL/conf/datasid-conf.json | jq -r '.idPoint')
[[ "$obj" -eq 1234 ]]
}
setup() {
./../bin/agent.run --quiet | head -n -1 > export.json
../agent-1234.run --quiet
/opt/agentC3SL/agent-v* --print --once | head -n -1 > export.json
pt1=$(cat export.json | head -n -9)
echo $pt1 > inventory.json
pt2=$(cat export.json | tail -n 9)
......@@ -81,6 +112,36 @@ teardown() {
rm -f net.json
}
@test "Id Point" {
run id_point
[ "$status" -eq 0 ]
}
@test "Web Service" {
run web_service
[ "$status" -eq 0 ]
}
@test "host" {
run host
[ "$status" -eq 0 ]
}
@test "port" {
run port
[ "$status" -eq 0 ]
}
@test "user" {
run user
[ "$status" -eq 0 ]
}
@test "password" {
run password
[ "$status" -eq 0 ]
}
@test "Bytes Received" {
run bytes_received
[ "$status" -eq 0 ]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment