From a09b4d33818f1b3fd3836a99cbb742fa84caecb4 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Wed, 13 Apr 2016 21:17:28 +0200 Subject: Working test! It's amazing! Never been so happy to see a single switch in the nms. Missing: Varnish and collectors and better deplist. Also: this is mainly _test_ stuff, not meant for development OR production. --- README.rst | 25 +++++++++++++++++++++++++ build/test/db-test.Dockerfile | 1 + build/test/playbook-test.yml | 16 +++++++++++++++- extras/misc/apache2.conf | 4 ++-- include/config.pm | 43 +++++++++++++++++++++++++++++++++++++++++++ include/config.pm.dist | 43 ------------------------------------------- 6 files changed, 86 insertions(+), 46 deletions(-) create mode 100755 include/config.pm delete mode 100755 include/config.pm.dist diff --git a/README.rst b/README.rst index c626fa9..7d2f817 100644 --- a/README.rst +++ b/README.rst @@ -50,6 +50,31 @@ This is NOT complete and thoroughly lacking. 6. Start the clients in ``clients/``. 7. Read the first line in this chapter. +Testing +------- + +There is basic test infrastructure set up in ``build/test``. It uses Docker and +ansible against the host in ``build/test/inventory`` which happens to be +localhost by default. + +To use it, first set up ssh to localhost (or change host in inventory) and +install docker, then run:: + + $ cd build/ + $ ansible-playbook -i test/inventory test/playbook-test.yml + +This will build the relevant docker images and start them. It assumes a +check out on the target machine (e.g.: localhost) on ``~/src/tgnms``. It +does not use sudo or make any attempt to configure the local host beyond +docker building. + +PS: This is currently NOT complete, but will eventually run actual test +cases and possibly provide a development environment. It is very likely to +"move" to the top level, mainly to avoid having to check out the git repo, +which creates cache issues with docker. + +It currently DOES work to actual set up a working NMS, save collectors. + Architecture ------------ diff --git a/build/test/db-test.Dockerfile b/build/test/db-test.Dockerfile index cd6161e..a182040 100644 --- a/build/test/db-test.Dockerfile +++ b/build/test/db-test.Dockerfile @@ -5,5 +5,6 @@ RUN cat /pg_hba.tail >> /etc/postgresql/9.4/main/pg_hba.conf RUN service postgresql start && su postgres -c "psql --command=\"CREATE ROLE nms PASSWORD 'risbrod' NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;\"" && su postgres -c "createdb -O nms nms" && service postgresql stop ADD schema.sql /schema.sql RUN service postgresql start && su postgres -c "cat /schema.sql | psql nms" && service postgresql stop +RUN echo "listen_addresses = '*'" >> /etc/postgresql/9.4/main/postgresql.conf CMD pg_ctlcluster --foreground 9.4 main start EXPOSE 5432 diff --git a/build/test/playbook-test.yml b/build/test/playbook-test.yml index 2794b21..4a04328 100644 --- a/build/test/playbook-test.yml +++ b/build/test/playbook-test.yml @@ -4,6 +4,7 @@ tasks: - name: make db-test docker_image: + nocache: true state: build name: nms-db-test docker_api_version: 1.18 @@ -11,6 +12,7 @@ path: "src/tgnms/build/" - name: make front-test docker_image: + nocache: true state: build name: nms-front-test docker_api_version: 1.18 @@ -23,6 +25,18 @@ docker_api_version: 1.18 dockerfile: test/collector-test.Dockerfile path: "src/tgnms/build/" + - name: stop db + docker: + name: nms-db + state: stopped + image: nms-db-test + docker_api_version: 1.18 + - name: stop front + docker: + name: nms-front + state: stopped + image: nms-front-test + docker_api_version: 1.18 - name: start db docker: name: nms-db @@ -36,7 +50,7 @@ name: nms-front image: nms-front-test docker_api_version: 1.18 - state: reloaded + state: started net: bridge links: - "nms-db:db" diff --git a/extras/misc/apache2.conf b/extras/misc/apache2.conf index a2b1e83..e5311a0 100644 --- a/extras/misc/apache2.conf +++ b/extras/misc/apache2.conf @@ -12,7 +12,7 @@ Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch AuthUserFile /opt/nms/etc/htpasswd-write - AuthName "Demo/test of nms write" + AuthName "Demo/test of nms" AuthType Basic Require valid-user @@ -22,7 +22,7 @@ Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch AuthUserFile /opt/nms/etc/htpasswd-read - AuthName "Demo/test of nms read" + AuthName "Demo/test of nms" AuthType Basic Require valid-user diff --git a/include/config.pm b/include/config.pm new file mode 100755 index 0000000..9987d05 --- /dev/null +++ b/include/config.pm @@ -0,0 +1,43 @@ +#! /usr/bin/perl +use strict; +use warnings; +package nms::config; + +# DB +our $db_name = "nms"; +our $db_host = "db"; +our $db_username = "nms"; +our $db_password = "risbrod"; + +# Max SNMP polls to fire off at the same time. +our $snmp_max = 20; + +# What SNMP objects to fetch. +our @snmp_objects = [ + ['ifIndex'], + ['sysName'], + ['sysDescr'], + ['ifHighSpeed'], + ['ifType'], + ['ifName'], + ['ifDescr'], + ['ifAlias'], + ['ifOperStatus'], + ['ifAdminStatus'], + ['ifLastChange'], + ['ifHCInOctets'], + ['ifHCOutOctets'], + ['ifInDiscards'], + ['ifOutDiscards'], + ['ifInErrors'], + ['ifOutErrors'], + ['ifInUnknownProtos'], + ['ifOutQLen'], + ['sysUpTime'], + ['jnxOperatingTemp'], + ['jnxOperatingCPU'], + ['jnxOperatingDescr'], + ['jnxBoxSerialNo'] +]; + +1; diff --git a/include/config.pm.dist b/include/config.pm.dist deleted file mode 100755 index 9987d05..0000000 --- a/include/config.pm.dist +++ /dev/null @@ -1,43 +0,0 @@ -#! /usr/bin/perl -use strict; -use warnings; -package nms::config; - -# DB -our $db_name = "nms"; -our $db_host = "db"; -our $db_username = "nms"; -our $db_password = "risbrod"; - -# Max SNMP polls to fire off at the same time. -our $snmp_max = 20; - -# What SNMP objects to fetch. -our @snmp_objects = [ - ['ifIndex'], - ['sysName'], - ['sysDescr'], - ['ifHighSpeed'], - ['ifType'], - ['ifName'], - ['ifDescr'], - ['ifAlias'], - ['ifOperStatus'], - ['ifAdminStatus'], - ['ifLastChange'], - ['ifHCInOctets'], - ['ifHCOutOctets'], - ['ifInDiscards'], - ['ifOutDiscards'], - ['ifInErrors'], - ['ifOutErrors'], - ['ifInUnknownProtos'], - ['ifOutQLen'], - ['sysUpTime'], - ['jnxOperatingTemp'], - ['jnxOperatingCPU'], - ['jnxOperatingDescr'], - ['jnxBoxSerialNo'] -]; - -1; -- cgit v1.2.3