Пример #1
0
exports['test_check_connection_failure'] = function(test, assert) {
  var port = testUtil.getPort();
  var check = new tcpCheck.TCPCheck({'ip_address': '127.0.0.1', 'port': port, 'type': tcpCheck.config.types.CONNECTION_CHECK});

  check.run(function(result) {
    assert.equal(result.status, CheckStatus.ERROR);
    assert.match(result.details, /(connection refused|connection timed out|ETIMEDOUT)/i);
    test.finish();
  });
};
Пример #2
0
exports['test_check_connection_timeout'] = function(test, assert) {
  var port = testUtil.getPort();
  var check = new tcpCheck.TCPCheck({'ip_address': '74.125.39.104', 'port': port, 'type': tcpCheck.config.types.CONNECTION_CHECK,
                                      'connect_timeout': 2000});

  check.run(function(result) {
    assert.equal(result.status, CheckStatus.ERROR);
    assert.match(result.details, /connection timed out/i);
    test.finish();
  });
};
Пример #3
0
  testUtil.runTestTcpServer('127.0.0.1', port, responseDictionary, true, function() {
    var self = this;
    var check = new tcpCheck.TCPCheck({'ip_address': '127.0.0.1', 'port': port, 'type': tcpCheck.config.types.CONNECTION_CHECK});

    check.run(function(result) {
      assert.equal(result.status, CheckStatus.SUCCESS);
      assert.match(result.details, /established connection to /i);

      self.close();
      test.finish();
    });
  });
Пример #4
0
  var tcp_server = testUtil.runTestTcpServer('127.0.0.1', port, responseDictionary, true, function() {
    var self = this;
    var check = new tcpCheck.TCPCheck({'ip_address': '127.0.0.1', 'port': port, 'type': tcpCheck.config.types.RESPONSE_REGEX_MATCH,
                                        'match_value': /blah/i});

    check.run(function(result) {
      assert.equal(result.status, CheckStatus.ERROR);
      assert.match(result.details, /didn.?t match the regular/i);

      self.close();
      test.finish();
    });
  });
Пример #5
0
  testUtil.runTestTcpServer('127.0.0.1', port, responseDictionary, true, function() {
    var self = this;
    var check = new tcpCheck.TCPCheck({'ip_address': '127.0.0.1', 'port': port, 'type': tcpCheck.config.types.RESPONSE_REGEX_MATCH,
                                       'command': 'stats 12345', 'match_value': /.*keys 12345.*/i});

    check.run(function(result) {
      assert.equal(result.status, CheckStatus.SUCCESS);
      assert.match(result.details, /matched the regular/i);

      self.close();
      test.finish();
    });
  });
Пример #6
0
exports['test_invalid_ip_address'] = function(test, assert) {
  test.skip('Broken in node 0.4.9, ENOTFOUND is never thrown');

  var port = testUtil.getPort();
  var check = new tcpCheck.TCPCheck({'ip_address': '999.99.99.99', 'port': port, 'type': tcpCheck.config.types.CONNECTION_CHECK,
                                     'idle_timeout': 2000});

  check.run(function(result) {
    assert.equal(result.status, CheckStatus.ERROR);
    assert.match(result.details, /domain name not found/i);

    test.finish();
  });
};