mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
Functional test with OpenACS
This commit is contained in:
parent
2e4b2b5b99
commit
71bbe223cb
14 changed files with 349 additions and 26 deletions
|
|
@ -6,7 +6,7 @@ stages:
|
|||
- static_code_analysis
|
||||
- unit_test
|
||||
- api_test
|
||||
- functional_test
|
||||
- functional_test_genieacs
|
||||
|
||||
variables:
|
||||
DEBUG: 'TRUE'
|
||||
|
|
@ -46,14 +46,14 @@ run_api_test:
|
|||
- api-test-memory-report.xml
|
||||
- api-test-result.log
|
||||
|
||||
run_functional_test:
|
||||
stage: functional_test
|
||||
run_functional_test_genieacs:
|
||||
stage: functional_test_genieacs
|
||||
image: iopsys/code-analysis:latest
|
||||
allow_failure: false
|
||||
script:
|
||||
- "./gitlab-ci/install-dependencies.sh"
|
||||
- "./gitlab-ci/setup.sh"
|
||||
- "./gitlab-ci/functional-test.sh"
|
||||
- "./gitlab-ci/functional-test-genieacs.sh"
|
||||
|
||||
artifacts:
|
||||
when: always
|
||||
|
|
|
|||
89
gitlab-ci/functional-test-genieacs.sh
Executable file
89
gitlab-ci/functional-test-genieacs.sh
Executable file
|
|
@ -0,0 +1,89 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "preparation script"
|
||||
pwd
|
||||
source ./gitlab-ci/shared.sh
|
||||
|
||||
trap cleanup EXIT
|
||||
trap cleanup SIGINT
|
||||
|
||||
# install required packages for functional test GenieACS
|
||||
exec_cmd apt install -y mongodb jq
|
||||
|
||||
# install genieacs
|
||||
exec_cmd npm install -g genieacs@1.2.5
|
||||
ln -sf /root/.nvm/versions/node/v14.16.1/bin/genieacs-cwmp /usr/sbin/genieacs-cwmp
|
||||
ln -sf /root/.nvm/versions/node/v14.16.1/bin/genieacs-fs /usr/sbin/genieacs-fs
|
||||
ln -sf /root/.nvm/versions/node/v14.16.1/bin/genieacs-ui /usr/sbin/genieacs-ui
|
||||
ln -sf /root/.nvm/versions/node/v14.16.1/bin/genieacs-nbi /usr/sbin/genieacs-nbi
|
||||
mkdir -p /data/db
|
||||
|
||||
date +%s > timestamp.log
|
||||
echo "Compiling icmwp"
|
||||
build_icwmp
|
||||
|
||||
echo "Starting dependent services"
|
||||
supervisorctl status all
|
||||
supervisorctl update
|
||||
supervisorctl restart all
|
||||
supervisorctl stop icwmpd
|
||||
supervisorctl status all
|
||||
|
||||
echo "Configuring genieacs"
|
||||
configure_genieacs
|
||||
|
||||
echo "Configuring GenieACS URL"
|
||||
configure_genieacs_url
|
||||
|
||||
echo "Starting icwmpd deamon"
|
||||
supervisorctl start icwmpd
|
||||
sleep 5
|
||||
|
||||
echo "Checking cwmp status"
|
||||
check_cwmp_status
|
||||
|
||||
[ -f funl-test-result.log ] && rm -f funl-test-result.log
|
||||
|
||||
echo "## Running script verification of functionalities ##"
|
||||
echo > ./funl-test-result.log
|
||||
echo > ./funl-test-debug.log
|
||||
test_num=0
|
||||
for test in `ls test/script/genieacs/`; do
|
||||
test_num=$(( test_num + 1 ))
|
||||
./test/script/genieacs/${test}
|
||||
if [ "$?" -eq 0 ]; then
|
||||
echo "ok ${test_num} - ${test}" >> ./funl-test-result.log
|
||||
else
|
||||
echo "not ok ${test_num} - ${test}" >> ./funl-test-result.log
|
||||
fi
|
||||
done
|
||||
|
||||
echo "1..${test_num}" >> ./funl-test-result.log
|
||||
|
||||
echo "Stop all services"
|
||||
supervisorctl stop icwmpd
|
||||
|
||||
# Artefact
|
||||
gcovr -r . 2> /dev/null --xml -o ./funl-test-coverage.xml
|
||||
#GitLab-CI output
|
||||
gcovr -r . 2> /dev/null
|
||||
|
||||
cp ./memory-report.xml ./funl-test-memory-report.xml
|
||||
|
||||
#report part
|
||||
exec_cmd tap-junit --input ./funl-test-result.log --output report
|
||||
|
||||
echo "Checking memory leaks..."
|
||||
grep -q "<kind>UninitCondition</kind>" memory-report.xml
|
||||
error_on_zero $?
|
||||
|
||||
grep -q "<kind>Leak_PossiblyLost</kind>" memory-report.xml
|
||||
error_on_zero $?
|
||||
|
||||
grep -q "<kind>Leak_DefinitelyLost</kind>" memory-report.xml
|
||||
error_on_zero $?
|
||||
|
||||
grep -q "<kind>Leak_StillReachable</kind>" memory-report.xml
|
||||
error_on_zero $?
|
||||
|
||||
echo "Functional test :: PASS"
|
||||
|
|
@ -7,6 +7,9 @@ source ./gitlab-ci/shared.sh
|
|||
trap cleanup EXIT
|
||||
trap cleanup SIGINT
|
||||
|
||||
# install required packages for functional test OpenACS
|
||||
exec_cmd apt install -y perl -MCPAN -e 'install WWW::Mechanize'
|
||||
|
||||
date +%s > timestamp.log
|
||||
echo "Compiling icmwp"
|
||||
build_icwmp
|
||||
|
|
@ -18,11 +21,8 @@ supervisorctl restart all
|
|||
supervisorctl stop icwmpd
|
||||
supervisorctl status all
|
||||
|
||||
echo "Configuring genieacs"
|
||||
configure_genieacs
|
||||
|
||||
echo "Configuring ACS URL"
|
||||
configure_acs_url
|
||||
echo "Configuring OpenACS URL"
|
||||
configure_openacs_url
|
||||
|
||||
echo "Starting icwmpd deamon"
|
||||
supervisorctl start icwmpd
|
||||
|
|
@ -37,9 +37,9 @@ echo "## Running script verification of functionalities ##"
|
|||
echo > ./funl-test-result.log
|
||||
echo > ./funl-test-debug.log
|
||||
test_num=0
|
||||
for test in `ls -I "common.sh" test/script/`; do
|
||||
for test in `ls test/script/openacs/`; do
|
||||
test_num=$(( test_num + 1 ))
|
||||
./test/script/${test}
|
||||
./test/script/openacs/${test}
|
||||
if [ "$?" -eq 0 ]; then
|
||||
echo "ok ${test_num} - ${test}" >> ./funl-test-result.log
|
||||
else
|
||||
|
|
@ -5,18 +5,6 @@ pwd
|
|||
|
||||
source ./gitlab-ci/shared.sh
|
||||
|
||||
# install required packages
|
||||
exec_cmd apt update
|
||||
exec_cmd apt install -y mongodb jq
|
||||
|
||||
# install genieacs
|
||||
exec_cmd npm install -g genieacs@1.2.5
|
||||
ln -sf /root/.nvm/versions/node/v14.16.1/bin/genieacs-cwmp /usr/sbin/genieacs-cwmp
|
||||
ln -sf /root/.nvm/versions/node/v14.16.1/bin/genieacs-fs /usr/sbin/genieacs-fs
|
||||
ln -sf /root/.nvm/versions/node/v14.16.1/bin/genieacs-ui /usr/sbin/genieacs-ui
|
||||
ln -sf /root/.nvm/versions/node/v14.16.1/bin/genieacs-nbi /usr/sbin/genieacs-nbi
|
||||
mkdir -p /data/db
|
||||
|
||||
# install uspd
|
||||
cd /opt/dev
|
||||
rm -rf uspd
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ function configure_genieacs()
|
|||
check_ret $?
|
||||
|
||||
echo "add a new provision inform"
|
||||
curl -X PUT 'http://localhost:7557/provisions/inform' --data-binary '@/builds/iopsys/icwmp/test/acs/connection_request_auth' >/dev/null 2>&1
|
||||
curl -X PUT 'http://localhost:7557/provisions/inform' --data-binary '@/builds/iopsys/icwmp/test/genieacs/connection_request_auth' >/dev/null 2>&1
|
||||
check_ret $?
|
||||
|
||||
#echo "get the supported provisions"
|
||||
|
|
@ -61,7 +61,7 @@ function configure_genieacs()
|
|||
check_ret $?
|
||||
}
|
||||
|
||||
function configure_acs_url()
|
||||
function configure_genieacs_url()
|
||||
{
|
||||
url="http://`hostname -i`:7547"
|
||||
uci set cwmp.acs.url=$url
|
||||
|
|
@ -69,6 +69,14 @@ function configure_acs_url()
|
|||
echo "Current ACS URL=$url"
|
||||
}
|
||||
|
||||
function configure_openacs_url()
|
||||
{
|
||||
url="http://`hostname -i`:8080/openacs/acs"
|
||||
uci set cwmp.acs.url=$url
|
||||
uci commit cwmp
|
||||
echo "Current ACS URL=$url"
|
||||
}
|
||||
|
||||
function check_cwmp_status()
|
||||
{
|
||||
status=`ubus call tr069 status | jq -r ".cwmp.status"`
|
||||
|
|
|
|||
217
test/openacs/openacs_script.pl
Executable file
217
test/openacs/openacs_script.pl
Executable file
|
|
@ -0,0 +1,217 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use WWW::Mechanize;
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Globals variables
|
||||
#-----------------------------------------------------------------------------
|
||||
my $acs_script_url = "http://localhost:8080/openacs/scripts.jsf";
|
||||
my $msg_to_sent = "";
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Fonctions
|
||||
#-----------------------------------------------------------------------------
|
||||
sub getRPCMethods {
|
||||
my ($function, $repeat) = @_;
|
||||
return ("cpe.GetRPCMethods();\n");
|
||||
}
|
||||
|
||||
sub getParameterNames {
|
||||
my ($function, $param, $bool, $repeat) = @_;
|
||||
return ("cpe.GetParameterNames('$param', $bool);\n");
|
||||
}
|
||||
|
||||
sub get_param_value {
|
||||
my ($function, $param_name, $req_num, $last) = @_;
|
||||
my $m = "";
|
||||
if ($req_num == 0) {
|
||||
$m = "$m"."var parameters = new Array();\n";
|
||||
}
|
||||
$m = "$m"."parameters[$req_num] = '$param_name';\n";
|
||||
if ($last == 1) {
|
||||
$m = "$m"."var response = cpe.GetParameterValues(parameters);\n";
|
||||
}
|
||||
return ($m);
|
||||
}
|
||||
|
||||
sub set_param_value {
|
||||
my ($function, $param_name, $param_value, $req_num, $last) = @_;
|
||||
my $m = "";
|
||||
if ($req_num == 0) {
|
||||
$m = "$m"."var parameters = new Array();\n";
|
||||
}
|
||||
$m = "$m"."parameters[$req_num] = {name: '$param_name', value:'$param_value'};\n";
|
||||
if ($last == 1) {
|
||||
$m = "$m"."cpe.SetParameterValues(parameters, 'commandKey');\n";
|
||||
}
|
||||
return ($m);
|
||||
}
|
||||
|
||||
sub get_param_attribute {
|
||||
my ($function, $param_name, $req_num, $last) = @_;
|
||||
my $m = "";
|
||||
if ($req_num == 0) {
|
||||
$m = "$m"."var p = new Array();\n";
|
||||
}
|
||||
$m = "$m"."p[$req_num]='$param_name';\n";
|
||||
if ($last == 1) {
|
||||
$m = "$m"."var r = cpe.GetParameterAttributes(p);\n";
|
||||
}
|
||||
return ($m);
|
||||
}
|
||||
|
||||
sub set_param_attribute {
|
||||
my ($function, $param_name, $param_notification_value, $req_num, $last) = @_;
|
||||
my $m = "";
|
||||
if ($req_num == 0) {
|
||||
$m = "$m"."var parameters = new Array();\n";
|
||||
}
|
||||
$m = "$m"."parameters[$req_num]=new Object;\n";
|
||||
$m = "$m"."parameters[$req_num].Name='$param_name';\n";
|
||||
$m = "$m"."parameters[$req_num].Notification=$param_notification_value;\n";
|
||||
$m = "$m"."parameters[$req_num].NotificationChange=true;\n";
|
||||
$m = "$m"."parameters[$req_num].AccessListChange=true;\n";
|
||||
$m = "$m"."parameters[$req_num].AccessListChange=true;\n";
|
||||
$m = "$m"."parameters[$req_num].AccessList= new Array ();\n";
|
||||
$m = "$m"."parameters[$req_num].AccessList[0]='subscriber';\n";
|
||||
if ($last == 1) {
|
||||
$m = "$m"."cpe.SetParameterAttributes(parameters);\n";
|
||||
}
|
||||
return ($m);
|
||||
}
|
||||
|
||||
sub addobject {
|
||||
my ($function,$param,$commandkey) = @_;
|
||||
return ("cpe.AddObject('$param', '$commandkey');\n");
|
||||
}
|
||||
|
||||
sub deleteobject {
|
||||
my ($function,$param,$commandkey) = @_;
|
||||
return ("cpe.DeleteObject('$param', '$commandkey');\n");
|
||||
}
|
||||
|
||||
sub scheduleInform {
|
||||
my ($function, $commandkey, $delay) = @_;
|
||||
return ("cpe.ScheduleInform($delay, '$commandkey');\n");
|
||||
}
|
||||
|
||||
sub factoryReset {
|
||||
my ($function) = @_;
|
||||
return ("cpe.FactoryReset();\n");
|
||||
}
|
||||
|
||||
sub download {
|
||||
my ($function, $commandnum, $username, $password, $file_size, $file_name, $delay, $repeat, $num_incr) = @_;
|
||||
my $m = "";
|
||||
my $url = "http://";
|
||||
for (my $i = 0; $i < $repeat; $i += 1) {
|
||||
if ($num_incr == 1) {
|
||||
$commandnum = $i;
|
||||
}
|
||||
$m = "$m"."cpe.Download('$commandKey$commandnum', '$what_to_download','$url$file_name', $username, $password, $file_size, '', $delay, '', '');\n";
|
||||
}
|
||||
return ($m);
|
||||
}
|
||||
|
||||
sub reboot {
|
||||
my ($function, $commandkey) = @_;
|
||||
return ("cpe.Reboot('$commandkey');\n");
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------
|
||||
if ( $#ARGV == -1) {
|
||||
$msg_to_sent = "";
|
||||
} else {
|
||||
my $str2 = join(" ",@ARGV);
|
||||
$str2=~ s/\{\}//gs;
|
||||
my @value = split (/,/, $str2);
|
||||
for (@value) {
|
||||
s/\{\}//;
|
||||
}
|
||||
foreach my $req (@value) {
|
||||
my @uni = split (/\\/, $req);
|
||||
my $j=0;
|
||||
my $last=0;
|
||||
foreach my $req1 (@uni) {
|
||||
my @tab = split(/\s/, $req1);
|
||||
if (($#uni == ($j)) || ($#uni == 0)) {
|
||||
$last=1;
|
||||
}
|
||||
|
||||
if ( $tab[0] eq "GetRPCMethods") {
|
||||
$msg_to_sent = "$msg_to_sent".getRPCMethods(@tab);
|
||||
} elsif ( $tab[0] eq "GetParameterNames") {
|
||||
if ($tab[1] eq "") {
|
||||
push(@tab, "");
|
||||
}
|
||||
$msg_to_sent = "$msg_to_sent".getParameterNames(@tab);
|
||||
} elsif ($tab[0] eq "GetParameterValue") {
|
||||
if ($#tab == 2) {
|
||||
my $repeat_num = $tab[2];
|
||||
pop(@tab);
|
||||
for (my $k = 0; $k < $repeat_num - 1; $k += 1) {
|
||||
push(@tab, "$k", 0);
|
||||
$msg_to_sent = "$msg_to_sent".get_param_value(@tab);
|
||||
$j = $k+1;
|
||||
pop(@tab);
|
||||
pop(@tab);
|
||||
}
|
||||
}
|
||||
if ($#tab == 0) {
|
||||
push(@tab, "", "$j", "$last");
|
||||
}
|
||||
push(@tab, "$j", "$last");
|
||||
$msg_to_sent = "$msg_to_sent".get_param_value(@tab);
|
||||
} elsif ($tab[0] eq "SetParameterValue") {
|
||||
push(@tab, "$j", "$last");
|
||||
$msg_to_sent ="$msg_to_sent".set_param_value(@tab);
|
||||
} elsif ($tab[0] eq "GetParamAttribute") {
|
||||
if ($tab[1] eq "") {
|
||||
push(@tab, "", "$j", "$last");
|
||||
} else {
|
||||
push(@tab, "$j", "$last");
|
||||
}
|
||||
$msg_to_sent ="$msg_to_sent".get_param_attribute(@tab);
|
||||
} elsif ($tab[0] eq "SetParamAttribute") {
|
||||
if ($tab[1] eq "") {
|
||||
push(@tab, "");
|
||||
}
|
||||
push(@tab,"$j","$last");
|
||||
$msg_to_sent ="$msg_to_sent".set_param_attribute(@tab);
|
||||
} elsif ($tab[0] eq "AddObject") {
|
||||
if ($tab[1] eq "") {
|
||||
push(@tab, "", $tab[2], "$j","$last");
|
||||
} else {
|
||||
push(@tab, "$j", "$last");
|
||||
}
|
||||
$msg_to_sent = "$msg_to_sent".addobject(@tab);
|
||||
} elsif ($tab[0] eq "DeleteObject") {
|
||||
if ($tab[1] eq "") {
|
||||
push(@tab, "", $tab[2], "$j", "$last");
|
||||
} else {
|
||||
push(@tab, "$j", "$last");
|
||||
}
|
||||
$msg_to_sent = "$msg_to_sent".deleteobject(@tab);
|
||||
} elsif ( $tab[0] eq "ScheduleInform") {
|
||||
$msg_to_sent = "$msg_to_sent".scheduleInform(@tab);
|
||||
} elsif ( $tab[0] eq "FactoryReset") {
|
||||
$msg_to_sent = "$msg_to_sent".factoryReset(@tab);
|
||||
} elsif ( $tab[0] eq "Download") {
|
||||
$msg_to_sent = "$msg_to_sent".download(@tab);
|
||||
} elsif ( $tab[0] eq "Reboot") {
|
||||
$msg_to_sent = "$msg_to_sent".reboot(@tab);
|
||||
}
|
||||
$j += 1
|
||||
}
|
||||
$j = 0;
|
||||
}
|
||||
}
|
||||
|
||||
my $mech = WWW::Mechanize->new();
|
||||
$mech->get($acs_script_url);
|
||||
$mech->submit_form(form_number => 2, fields => {"scriptform:j_id60" => 'Default'}, button => 'scriptform:j_id69');
|
||||
$mech->submit_form(form_number => 2, fields => {"scriptform:j_id62" => 'CWMP_Test', "scriptform:j_id64" => $msg_to_sent}, button => 'scriptform:j_id66');
|
||||
print "message sent: $msg_to_sent";
|
||||
|
||||
21
test/script/openacs/verify_get_method.sh
Executable file
21
test/script/openacs/verify_get_method.sh
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
source ./test/script/common.sh
|
||||
source ./gitlab-ci/shared.sh
|
||||
|
||||
TEST_NAME="GET RPC Method"
|
||||
|
||||
echo "Running: $TEST_NAME"
|
||||
|
||||
remove_icwmp_log
|
||||
curl $connection_request_path -X POST --data '{"name": "getParameterValues", "parameterNames": ["Device.Users.User.1.Username"] }' >/dev/null 2>&1
|
||||
check_ret $?
|
||||
sleep 2
|
||||
check_session "GetParameterValues"
|
||||
param_value=$(print_tag_value "cwmp:GetParameterValuesResponse" "Value xsi:type=\"xsd:string\"")
|
||||
if [ "$param_value" != "user" ]; then
|
||||
echo "Error: Default value of 'Device.Users.User.1.Username' is wrong, current_value($param_value) expected_value(user)" >> ./funl-test-debug.log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "PASS: $TEST_NAME"
|
||||
Loading…
Add table
Reference in a new issue