<commit_before>/*
Copyright 2013 Rackspace Hosting, Inc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

var test = require('tape');
var async = require('async');
var logmagic = require('logmagic');
var zkultra = require('./ultralight.js');

if (process.env.TRACE) {
  logmagic.route("__root__", logmagic.TRACE1, "console");
}

var URLS = ['127.0.0.1:2181'];
var BAD_URLS = ['127.0.0.1:666'];

if (process.env.ZOOKEEPER_PORT_2181_TCP_ADDR) {
  URLS = [process.env.ZOOKEEPER_PORT_2181_TCP_ADDR + ":" + process.env.ZOOKEEPER_PORT_2181_TCP_PORT];
}
else if (process.env.ZK) {
  URLS = [process.env.ZK];
}

test('lock and unlock', function(t) {
  var cxn = zkultra.getCxn(URLS);
  async.series([
    cxn.lock.bind(cxn, '/plumber/wrench', 'grrr'),
    cxn.unlock.bind(cxn, '/plumber/wrench')
  ], function(err, result) {
    t.ifError(err, "No error in lock and unlock");
    t.end();
  });
});
<commit_msg>add port check<commit_after>/*
Copyright 2013 Rackspace Hosting, Inc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

var test = require('tape');
var async = require('async');
var logmagic = require('logmagic');
var zkultra = require('./ultralight.js');

if (process.env.TRACE) {
  logmagic.route("__root__", logmagic.TRACE1, "console");
}

var URLS = ['127.0.0.1:2181'];
var BAD_URLS = ['127.0.0.1:666'];

if (process.env.ZOOKEEPER_PORT_2181_TCP_ADDR && process.env.ZOOKEEPER_PORT_2181_TCP_PORT) {
  URLS = [process.env.ZOOKEEPER_PORT_2181_TCP_ADDR + ":" + process.env.ZOOKEEPER_PORT_2181_TCP_PORT];
} else if (process.env.ZK) {
  URLS = [process.env.ZK];
}

test('lock and unlock', function(t) {
  var cxn = zkultra.getCxn(URLS);
  async.series([
    cxn.lock.bind(cxn, '/plumber/wrench', 'grrr'),
    cxn.unlock.bind(cxn, '/plumber/wrench')
  ], function(err, result) {
    t.ifError(err, "No error in lock and unlock");
    t.end();
  });
});

{'fraction_non_alphanumeric': 0.13466334164588528, 'fraction_numerical': 0.029925187032418952, 'mean_word_length': 4.4524271844660195, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6300176', 'n_tokens_mistral': 1027, 'n_tokens_neox': 959, 'n_words': 283}