Skip to content

Commit

Permalink
Feature: Generic discovery and poller tests (librenms#7873)
Browse files Browse the repository at this point in the history
* Processor Tests!

* Capture data from live devices easily.

* fix up some stuff, remove powerconnect things as they seem to be just broken.

* formatting, fix missing assignment
add netonix processor data

* fix multi-line, always add sysDescr and sysObjectID
ios cpm test file

* revert composer change and fix whitespace issues

* add help text

* missed help text

* tighter debug output

* handle empty strings properly and mibs with numbers

* use keys for sorting as intended

* fix type with empty data

* oops :)

* whitespace fix

* try installing fping

* Fix TestCase collision + cleanup

* mark TestCase as abstract
don't run two instances of snmpsim

* better database dumps, improved capture

* style fixes

* fix quotes add a few more tables

* add --prefer-new, properly merge data

* Support separate discovery and poller data. But don't waste space if they aren't needed.

* refactor to use class
collects all code in one place for reusability

* reorganize

* Print out when not saving.

* Support for running multiple (or all) modules at once.

* tidy

* Change unit test to a generic name and test all modules we have data for.

* Add documentation and a few more tidies

* whitespace fixes

* Fix tests, add a couple more modules, more docs

* More docs updates

* Fix scrutinizer issues

* add bgp-peers
  • Loading branch information
murrant authored Dec 20, 2017
1 parent 56561aa commit fff66d3
Show file tree
Hide file tree
Showing 50 changed files with 1,950 additions and 84 deletions.
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ cache:

before_install:
- sudo apt-get -qq update
- sudo apt-get install -y snmp
- sudo apt-get install -y snmp fping
- mysql -e 'CREATE DATABASE librenms_phpunit_78hunjuybybh;'

install:
Expand All @@ -43,9 +43,6 @@ install:
- pip install --user pylint
- pip install --user mysql-python

before_script:
- python2 $HOME/.local/bin/snmpsimd.py --data-dir=$TRAVIS_BUILD_DIR/tests/snmpsim --agent-udpv4-endpoint=127.0.0.1:11161 --logging-method=file:/tmp/snmpsimd.log --daemon --pid-file=/tmp/snmpsimd.pid

after_success:
- test $TRAVIS_PULL_REQUEST == "false" && test $TRAVIS_BRANCH == "master" && test $EXECUTE_BUILD_SCHEMA == "true" && bash scripts/deploy-schema.sh
- test $TRAVIS_PULL_REQUEST == "false" && test $TRAVIS_BRANCH == "master" && test $EXECUTE_BUILD_DOCS == "true" && bash scripts/deploy-docs.sh
Expand Down
17 changes: 15 additions & 2 deletions LibreNMS/Proc.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,22 +189,35 @@ public function close($command = null)
* Please attempt to run close() instead of this
* This will be called when this object is destroyed if the process is still running
*
* @param int $timeout how many microseconds to wait before terminating (SIGKILL)
* @param int $signal the signal to send
* @throws Exception
*/
public function terminate($signal = 15)
public function terminate($timeout = 3000, $signal = 15)
{
$status = $this->getStatus();

$this->closePipes();

$closed = proc_terminate($this->_process, $signal);

$time = 0;
while ($time < $timeout) {
$closed = !$this->isRunning();
if ($closed) {
break;
}

usleep(100);
$time += 100;
}

if (!$closed) {
// try harder
$killed = false;
if (function_exists('posix_kill')) {
$killed = posix_kill($status['pid'], 9); //9 is the SIGKILL signal
} else {
$killed = proc_terminate($this->_process, 9);
}
proc_close($this->_process);

Expand Down
Loading

0 comments on commit fff66d3

Please sign in to comment.