Commit 5a986e6c authored by Nigel Kukard's avatar Nigel Kukard

Improved CI

parent d7614da0
......@@ -3,6 +3,8 @@ stages:
- tests
- install
code-quality:
stage: quality
script:
......@@ -14,6 +16,8 @@ code-quality:
- apt-get install -y libperl-critic-perl
- perlcritic --gentle "$CI_PROJECT_DIR"
make-test:
stage: tests
script:
......@@ -22,17 +26,43 @@ make-test:
- apt-get dist-upgrade -y
- apt-get install -y git make
- apt-get install -y libdevel-cover-perl libpod-coverage-perl
- apt-get install -y libnet-server-perl libconfig-inifiles-perl libdatetime-perl libcache-fastmmap-perl
- apt-get install -y libnet-server-perl libconfig-inifiles-perl libdatetime-perl libcache-fastmmap-perl libtimedate-perl
libcrypt-des-perl libcrypt-rc4-perl libdigest-sha-perl libdigest-md4-perl
- apt-get install -y mysql-server
# Start services and create dirs we need
- service mysql start
- mkdir /var/run/smradius
# Update our dependencies
- cd "$CI_PROJECT_DIR"
- ./update-git-modules
- perl -MCPAN -e 'install Math::Expression' < /dev/null
# Convert DB into MySQL
- 3rdparty/awitpt/bin/convert-tsql mysql database/core.tsql > database/core.mysql
- 3rdparty/awitpt/bin/convert-tsql mysql database/users-accounting-summary.tsql > database/users-accounting-summary.mysql
- 3rdparty/awitpt/bin/convert-tsql mysql database/wisp.tsql > database/wisp.mysql
# Load SQL into DB
- echo "CREATE DATABASE smradiustest;" | mysql -u root
- mysql -u root smradiustest < database/core.mysql
- mysql -u root smradiustest < database/users-accounting-summary.mysql
- mysql -u root smradiustest < database/wisp.mysql
# Sort out config file
- cp smradiusd.conf smradiusd.conf.test
- perl -pi -e 's/database=smradius/database=smradiustest/' smradiusd.conf.test
# Run tests
- perl Makefile.PL
- make test
- perl Makefile.PL DIR=
- cover -test | tee devel-coverage.txt
- grep "^Total" devel-coverage.txt | awk '{ print "(" $8 "%) covered" }'
make-install:
stage: install
script:
......
......@@ -179,7 +179,7 @@ CREATE TABLE @PREFIX@topups_summary (
TopupID @SERIAL_REF_TYPE@ NOT NULL,
PeriodKey VARCHAR(255) NOT NULL,
PeriodKey VARCHAR(255) NOT NULL,
Balance @INT_UNSIGNED@,
......
use strict;
use warnings;
use Test::More;
use Data::Dumper;
use POSIX ();
#$SIG{CHLD} = sub {
# while () {
# my $child = waitpid -1, POSIX::WNOHANG;
# last if $child <= 0;
# my $localtime = localtime;
# warn "Parent: Child $child was reaped - $localtime.\n";
# }
#};
require_ok("smradius::daemon");
require_ok("smradius::client");
if (my $child = fork()) {
warn "\n\nPARENT: I AM PARENT $$, my child is $child\n\n";
warn "\n\nPARENT: RUNNING CLIENT IN 5s\n\n";
sleep 5;
my $res = smradius::client->run(
"--raddb","dicts",
"127.0.0.1",
"auth",
"unittests",
'User-Name=unit@test',
'User-Password=test123',
);
warn "\n\nCLIENT RESULT:\n". Dumper($res) ."\n\n";
# is($res, 0, "User authentication test");
warn "\n\nPARENT: WAITING 10s\n\n";
sleep 10;
warn "\n\nPARENT: KILLING CHILD $child\n\n";
kill('TERM',$child);
warn "\n\nPARENT: WAITING...\n\n";
waitpid($child,0);
warn "\n\nPARENT: WAIT DONE\n\n";
} else {
warn "\n\nCHILD: STARTED $$\n\n";
smradius::daemon->run(
"--fg",
"--debug",
"--config", "smradiusd.conf.test",
);
warn "\n\nCHILD: SLEEP START\n\n";
sleep 4;
warn "\n\nCHILD: SLEEP DONE\n\n";
exit 0;
}
warn "\n\nPARENT: I WAS $$\n\n";
can_ok("smradius::daemon","displayHelp");
# pass("First test");
# subtest 'An example subtest' => sub {
# plan tests => 2;
# pass("This is a subtest");
# pass("So is this");
# };
# pass("Third test");
done_testing();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment