You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/02/06 23:12:15 UTC
[01/12] couchdb commit: updated refs/heads/1843-feature-bigcouch to
152a21a
Updated Branches:
refs/heads/1843-feature-bigcouch 3069c0134 -> 152a21ad2
Add interim dev/run script
This script assists in booting a basic cluster for development purposes. Further
refinement of the commandline interface will follow.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/811eadf4
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/811eadf4
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/811eadf4
Branch: refs/heads/1843-feature-bigcouch
Commit: 811eadf4a7b60e2049e6ced5dadb11b41424e647
Parents: 3069c01
Author: Brian Mitchell <br...@cloudant.com>
Authored: Wed Feb 5 16:37:35 2014 -0500
Committer: Brian Mitchell <br...@cloudant.com>
Committed: Wed Feb 5 17:28:07 2014 -0500
----------------------------------------------------------------------
dev/boot_node.erl | 125 ++++++++++++++++++++++++++++
dev/run | 219 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 344 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/811eadf4/dev/boot_node.erl
----------------------------------------------------------------------
diff --git a/dev/boot_node.erl b/dev/boot_node.erl
new file mode 100644
index 0000000..cf49b7e
--- /dev/null
+++ b/dev/boot_node.erl
@@ -0,0 +1,125 @@
+-module(boot_node).
+
+-export([start/0]).
+
+
+start() ->
+ monitor_parent(),
+ Apps = load_apps(),
+ Deps = load_deps(Apps),
+ start_all_apps(Deps).
+
+
+monitor_parent() ->
+ {ok, [[PPid]]} = init:get_argument(parent_pid),
+ spawn(fun() -> monitor_parent(PPid) end).
+
+
+monitor_parent(PPid) ->
+ timer:sleep(1000),
+ case os:cmd("kill -0 " ++ PPid) of
+ "" ->
+ monitor_parent(PPid);
+ _Else ->
+ % Assume _Else is a no such process error
+ init:stop()
+ end.
+
+
+load_apps() ->
+ {ok, [[Config]]} = init:get_argument(reltool_config),
+ {ok, Terms} = file:consult(Config),
+ load_apps(Terms).
+
+
+load_apps([]) ->
+ erlang:error(failed_to_load_apps);
+load_apps([{sys, Terms} | _]) ->
+ load_apps(Terms);
+load_apps([{rel, "couchdb", _Vsn, Apps} | _]) ->
+ Apps;
+load_apps([_ | Rest]) ->
+ load_apps(Rest).
+
+
+load_deps(Apps) ->
+ load_deps(Apps, dict:new()).
+
+
+load_deps([], Deps) ->
+ Deps;
+load_deps([App | Rest], Deps) ->
+ load_app(App),
+ case application:get_key(App, applications) of
+ {ok, AppDeps0} ->
+ NewDeps = dict:store(App, AppDeps0, Deps),
+ Filter = fun(A) -> not dict:is_key(A, Deps) end,
+ AppDeps = lists:filter(Filter, AppDeps0),
+ load_deps(AppDeps ++ Rest, NewDeps);
+ _ ->
+ NewDeps = dict:store(App, [], Deps),
+ load_deps(Rest, NewDeps)
+ end.
+
+
+load_app(App) ->
+ case application:load(App) of
+ ok ->
+ case application:get_key(App, modules) of
+ {ok, Modules} ->
+ lists:foreach(fun(Mod) ->
+ OK = load_app_module(Mod),
+ case load_app_module(Mod) of
+ ok -> ok;
+ E -> io:format("~p = load_app_module(~p)~n", [E, Mod])
+ end
+ end, Modules);
+ undefined ->
+ ok
+ end;
+ {error, {already_loaded, App}} ->
+ ok;
+ Error ->
+ Error
+ end.
+
+
+load_app_module(Mod) ->
+ case code:is_loaded(Mod) of
+ {file, _} ->
+ ok;
+ _ ->
+ case code:load_file(Mod) of
+ {module, Mod} ->
+ ok;
+ Error ->
+ Error
+ end
+ end.
+
+
+start_all_apps(Deps) ->
+ lists:foldl(fun(App, Started) ->
+ start_app(App, Deps, Started)
+ end, [], dict:fetch_keys(Deps)).
+
+
+start_app(App, Deps, Started) ->
+ case lists:member(App, Started) of
+ true ->
+ Started;
+ false ->
+ AppDeps = dict:fetch(App, Deps),
+ NowStarted = lists:foldl(fun(Dep, Acc) ->
+ start_app(Dep, Deps, Acc)
+ end, Started, AppDeps),
+ case application:start(App) of
+ ok ->
+ [App | NowStarted];
+ {error, {already_started,App}} ->
+ % Kernel causes this
+ [App | NowStarted];
+ Else ->
+ erlang:error(Else)
+ end
+ end.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/811eadf4/dev/run
----------------------------------------------------------------------
diff --git a/dev/run b/dev/run
new file mode 100755
index 0000000..e49040f
--- /dev/null
+++ b/dev/run
@@ -0,0 +1,219 @@
+#!/usr/bin/env python
+
+
+import atexit
+import contextlib as ctx
+import glob
+import optparse as op
+import os
+import re
+import select
+import subprocess as sp
+import sys
+import time
+import urllib
+
+
+USAGE = "%prog [options] [command to run...]"
+DEV_PATH = os.path.dirname(os.path.abspath(__file__))
+COUCHDB = os.path.dirname(DEV_PATH)
+N = 3
+
+
+def init_log_dir():
+ logdir = os.path.join(DEV_PATH, "logs")
+ if not os.path.exists(logdir):
+ os.makedirs(logdir)
+
+
+def init_beams():
+ # Including this for people that forget to run
+ # make dev.
+ for fname in glob.glob(os.path.join(DEV_PATH, "*.erl")):
+ cmd = [
+ "erlc",
+ "-o", DEV_PATH + os.sep,
+ fname
+ ]
+ sp.check_call(cmd)
+
+
+def hack_default_ini(opts, node, args, contents):
+ # Replace log file
+ logfile = os.path.join(DEV_PATH, "logs", "%s.log" % node)
+ repl = "file = %s" % logfile
+ contents = re.sub("(?m)^file.*$", repl, contents)
+
+ # Replace couchjs command
+ couchjs = os.path.join(COUCHDB, "couchjs", "build", "couchjs")
+ mainjs = os.path.join(COUCHDB, "couchjs", "build", "main.js")
+ repl = "javascript = %s %s" % (couchjs, mainjs)
+ contents = re.sub("(?m)^javascript.*$", repl, contents)
+
+ return contents
+
+
+def hack_local_ini(opts, node, args, contents):
+ if opts.admin is None:
+ return contents
+ usr, pwd = opts.admin.split(":", 1)
+ return contents + "\n[admins]\n%s = %s" % (usr, pwd)
+
+
+def write_config(opts, node, args):
+ etc_src = os.path.join(COUCHDB, "rel", "overlay", "etc")
+ etc_tgt = os.path.join(DEV_PATH, "lib", node, "etc")
+ if not os.path.exists(etc_tgt):
+ os.makedirs(etc_tgt)
+
+ etc_files = glob.glob(os.path.join(etc_src, "*"))
+ for fname in etc_files:
+ base = os.path.basename(fname)
+ tgt = os.path.join(etc_tgt, base)
+ with open(fname) as handle:
+ contents = handle.read()
+ for key in args:
+ contents = re.sub("{{%s}}" % key, args[key], contents)
+ if base == "default.ini":
+ contents = hack_default_ini(opts, node, args, contents)
+ elif base == "local.ini":
+ contents = hack_local_ini(opts, node, args, contents)
+ with open(tgt, "w") as handle:
+ handle.write(contents)
+
+
+def write_configs(opts):
+ datadir = os.path.join(DEV_PATH, "data")
+ if not os.path.exists(datadir):
+ os.makedirs(datadir)
+ for i in range(1,4):
+ node = "node%d" % i
+ args = {
+ "prefix": os.path.join(COUCHDB, "rel", "overlay"),
+ "data_dir": os.path.join(DEV_PATH, "lib", node, "data"),
+ "view_dir": os.path.join(DEV_PATH, "lib", node, "data"),
+ "node_name": "-name %s@127.0.0.1" % node,
+ "clouseau_name": "clouseau%d@127.0.0.1" % i,
+ "cluster_port": str((10000 * i) + 5984),
+ "backend_port" : str((10000 * i) + 5986)
+ }
+ if not os.path.exists(args["data_dir"]):
+ os.makedirs(args["data_dir"])
+ write_config(opts, node, args)
+
+
+def all_nodes_alive(n):
+ for i in range(1, n+1):
+ url = "http://127.0.0.1:{0}/".format(local_port(i))
+ while True:
+ try:
+ with ctx.closing(urllib.urlopen(url)) as resp:
+ print(resp.read())
+ except IOError:
+ time.sleep(0.25)
+ continue
+ break
+ return True
+
+
+def local_port(n):
+ return 10000 * n + 5986
+
+
+def node_port(n):
+ return 10000 * n + 5984
+
+
+def boot_node(node):
+ apps = os.path.join(COUCHDB, "src")
+ env = os.environ.copy()
+ env["ERL_LIBS"] = os.pathsep.join([apps])
+ cmd = [
+ "erl",
+ "-args_file", os.path.join(DEV_PATH, "lib", node, "etc", "vm.args"),
+ "-couch_ini",
+ os.path.join(DEV_PATH, "lib", node, "etc", "default.ini"),
+ os.path.join(DEV_PATH, "lib", node, "etc", "local.ini"),
+ "-reltool_config", os.path.join(COUCHDB, "rel", "reltool.config"),
+ "-parent_pid", str(os.getpid()),
+ "-pa", DEV_PATH,
+ "-pa", os.path.join(COUCHDB, "src", "*"),
+ "-s", "boot_node"
+ ]
+ logfname = os.path.join(DEV_PATH, "logs", "%s.log" % node)
+ log = open(logfname, "w")
+ print ' '.join(cmd)
+ return sp.Popen(
+ cmd,
+ stdin=sp.PIPE,
+ stdout=log,
+ stderr=sp.STDOUT,
+ env=env)
+
+
+def connect_nodes(backdoor):
+ for i in range(1,4):
+ cmd = "curl -s %snodes/node%s@127.0.0.1 -X PUT -d '{}'"
+ cmd = cmd % (backdoor, i)
+ sp.check_call(cmd, shell=True)
+
+
+def run_command(cmd):
+ p = sp.Popen(cmd, shell=True)
+ p.wait()
+ exit(p.returncode)
+
+
+def wait_for_procs(procs):
+ while True:
+ for p in procs:
+ if p.returncode is not None:
+ exit(1)
+ time.sleep(2)
+
+
+def options():
+ return [
+ op.make_option("-a", "--admin", metavar="USER:PASS", default=None,
+ help="Add an admin account to the development cluster")
+ ]
+
+
+def main():
+ parser = op.OptionParser(usage=USAGE, option_list=options())
+ opts, args = parser.parse_args()
+
+ init_log_dir()
+ init_beams()
+ write_configs(opts)
+
+ procs = []
+
+ def kill_procs():
+ for p in procs:
+ if p.returncode is None:
+ p.terminate()
+ atexit.register(kill_procs)
+
+ for i in range(1, 4):
+ p = boot_node("node%d" % i)
+ procs.append(p)
+
+ for i in range(30):
+ if all_nodes_alive(N):
+ break
+ time.sleep(1)
+
+ connect_nodes("http://127.0.0.1:15986/")
+
+ if len(args):
+ run_command(" ".join(args))
+ else:
+ wait_for_procs(procs)
+
+
+if __name__ == "__main__":
+ try:
+ main()
+ except KeyboardInterrupt:
+ pass
[06/12] couchdb commit: updated refs/heads/1843-feature-bigcouch to
152a21a
Posted by da...@apache.org.
Update couchjs and main.js paths in dev/run
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/dc75c75e
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/dc75c75e
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/dc75c75e
Branch: refs/heads/1843-feature-bigcouch
Commit: dc75c75eb2ed5c46c4b76cc1bbd945c3aaa68578
Parents: f6759d7
Author: Paul J. Davis <pa...@gmail.com>
Authored: Thu Feb 6 16:03:15 2014 -0600
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Thu Feb 6 16:03:15 2014 -0600
----------------------------------------------------------------------
dev/run | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/dc75c75e/dev/run
----------------------------------------------------------------------
diff --git a/dev/run b/dev/run
index 29b2a31..c4c68af 100755
--- a/dev/run
+++ b/dev/run
@@ -56,8 +56,8 @@ def hack_default_ini(opts, node, args, contents):
contents = re.sub("(?m)^file.*$", repl, contents)
# Replace couchjs command
- couchjs = os.path.join(COUCHDB, "couchjs", "build", "couchjs")
- mainjs = os.path.join(COUCHDB, "couchjs", "build", "main.js")
+ couchjs = os.path.join(COUCHDB, "src", "couch", "priv", "couchjs")
+ mainjs = os.path.join(COUCHDB, "share", "server", "main.js")
repl = "javascript = %s %s" % (couchjs, mainjs)
contents = re.sub("(?m)^javascript.*$", repl, contents)
[03/12] couchdb commit: updated refs/heads/1843-feature-bigcouch to
152a21a
Posted by da...@apache.org.
Ignore files generated by dev/run
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d9913057
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d9913057
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d9913057
Branch: refs/heads/1843-feature-bigcouch
Commit: d9913057bc13e3937c3b0b6b9f8c37a9a5b316f6
Parents: 4dff473
Author: Paul J. Davis <pa...@gmail.com>
Authored: Thu Feb 6 14:23:35 2014 -0600
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Thu Feb 6 14:23:35 2014 -0600
----------------------------------------------------------------------
.gitignore | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/d9913057/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 8ea2016..17fa92b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,10 @@ src/
*.so
ebin/
+dev/boot_node.beam
+dev/lib/
+dev/logs/
+
share/server/main-coffee.js
share/server/main.js
[10/12] couchdb commit: updated refs/heads/1843-feature-bigcouch to
152a21a
Posted by da...@apache.org.
Update the _temp_view handler.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/b69f33f2
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/b69f33f2
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/b69f33f2
Branch: refs/heads/1843-feature-bigcouch
Commit: b69f33f20baf74187d75d347b4b33c2240474147
Parents: 9c9c4ff
Author: Paul J. Davis <pa...@gmail.com>
Authored: Thu Feb 6 16:09:32 2014 -0600
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Thu Feb 6 16:09:32 2014 -0600
----------------------------------------------------------------------
rel/overlay/etc/default.ini | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b69f33f2/rel/overlay/etc/default.ini
----------------------------------------------------------------------
diff --git a/rel/overlay/etc/default.ini b/rel/overlay/etc/default.ini
index ff7dda4..8a07a1d 100644
--- a/rel/overlay/etc/default.ini
+++ b/rel/overlay/etc/default.ini
@@ -78,7 +78,7 @@ _all_docs = {couch_mrview_http, handle_all_docs_req}
_view_cleanup = {couch_httpd_db, handle_view_cleanup_req}
_compact = {couch_httpd_db, handle_compact_req}
_design = {couch_httpd_db, handle_design_req}
-_temp_view = {couch_httpd_view, handle_temp_view_req}
+_temp_view = {couch_mrview_http, handle_temp_view_req}
_changes = {couch_httpd_db, handle_changes_req}
[httpd_design_handlers]
[02/12] couchdb commit: updated refs/heads/1843-feature-bigcouch to
152a21a
Posted by da...@apache.org.
Remove old debug line
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/4dff4735
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/4dff4735
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/4dff4735
Branch: refs/heads/1843-feature-bigcouch
Commit: 4dff473520d5c865367b856dc172d015338c76ae
Parents: 811eadf
Author: Paul J. Davis <pa...@gmail.com>
Authored: Thu Feb 6 14:22:53 2014 -0600
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Thu Feb 6 14:22:53 2014 -0600
----------------------------------------------------------------------
dev/boot_node.erl | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/4dff4735/dev/boot_node.erl
----------------------------------------------------------------------
diff --git a/dev/boot_node.erl b/dev/boot_node.erl
index cf49b7e..cc5cabb 100644
--- a/dev/boot_node.erl
+++ b/dev/boot_node.erl
@@ -68,7 +68,6 @@ load_app(App) ->
case application:get_key(App, modules) of
{ok, Modules} ->
lists:foreach(fun(Mod) ->
- OK = load_app_module(Mod),
case load_app_module(Mod) of
ok -> ok;
E -> io:format("~p = load_app_module(~p)~n", [E, Mod])
[09/12] couchdb commit: updated refs/heads/1843-feature-bigcouch to
152a21a
Posted by da...@apache.org.
Allow dev/run subcommands to execute commands
This is for things like allowing tests to reboot nodes. This is
extremely rudimentary currently.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/9c9c4ff1
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/9c9c4ff1
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/9c9c4ff1
Branch: refs/heads/1843-feature-bigcouch
Commit: 9c9c4ff1488d96eee6eeea7583ddd424ed195b1a
Parents: 089f3ad
Author: Paul J. Davis <pa...@gmail.com>
Authored: Thu Feb 6 16:08:21 2014 -0600
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Thu Feb 6 16:08:21 2014 -0600
----------------------------------------------------------------------
dev/run | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/9c9c4ff1/dev/run
----------------------------------------------------------------------
diff --git a/dev/run b/dev/run
index deb2c3a..e59a08b 100755
--- a/dev/run
+++ b/dev/run
@@ -201,7 +201,13 @@ def reboot_nodes():
def run_command(cmd):
- p = sp.Popen(cmd, shell=True)
+ p = sp.Popen(cmd, shell=True, stdout=sp.PIPE, stderr=sys.stderr)
+ for line in p.stdout:
+ try:
+ eval(line)
+ except:
+ traceback.print_exc()
+ exit(1)
p.wait()
exit(p.returncode)
[12/12] couchdb commit: updated refs/heads/1843-feature-bigcouch to
152a21a
Posted by da...@apache.org.
Add a dev/remsh command for connecting to nodes
This allows users to connect to development nodes started using the
dev/run command.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/152a21ad
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/152a21ad
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/152a21ad
Branch: refs/heads/1843-feature-bigcouch
Commit: 152a21ad2ef4f6e1a5d644f1918d1f6253d0335d
Parents: 3e09a9a
Author: Paul J. Davis <pa...@gmail.com>
Authored: Thu Feb 6 16:11:37 2014 -0600
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Thu Feb 6 16:11:37 2014 -0600
----------------------------------------------------------------------
dev/remsh | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/152a21ad/dev/remsh
----------------------------------------------------------------------
diff --git a/dev/remsh b/dev/remsh
new file mode 100755
index 0000000..428fa6f
--- /dev/null
+++ b/dev/remsh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+if [ -z $NODE ]; then
+ if [ -z $1 ]; then
+ NODE=1
+ else
+ NODE=$1
+ fi
+fi
+
+if [ -z $HOST ]; then
+ HOST="127.0.0.1"
+fi
+
+NAME="remsh$$@$HOST"
+NODE="node$NODE@$HOST"
+COOKIE=monster
+erl -name $NAME -remsh $NODE -setcookie $COOKIE -hidden
[07/12] couchdb commit: updated refs/heads/1843-feature-bigcouch to
152a21a
Posted by da...@apache.org.
Make the process list a global in dev/run
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/49cb5517
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/49cb5517
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/49cb5517
Branch: refs/heads/1843-feature-bigcouch
Commit: 49cb55177b0177c61f7eacff0e65b2be3b9082c1
Parents: dc75c75
Author: Paul J. Davis <pa...@gmail.com>
Authored: Thu Feb 6 16:05:47 2014 -0600
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Thu Feb 6 16:06:59 2014 -0600
----------------------------------------------------------------------
dev/run | 51 ++++++++++++++++++++++++++++++++-------------------
1 file changed, 32 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/49cb5517/dev/run
----------------------------------------------------------------------
diff --git a/dev/run b/dev/run
index c4c68af..aa3d313 100755
--- a/dev/run
+++ b/dev/run
@@ -28,7 +28,9 @@ import urllib
USAGE = "%prog [options] [command to run...]"
DEV_PATH = os.path.dirname(os.path.abspath(__file__))
COUCHDB = os.path.dirname(DEV_PATH)
+
N = 3
+PROCESSES = []
def init_log_dir():
@@ -168,15 +170,40 @@ def connect_nodes(backdoor):
sp.check_call(cmd, shell=True)
+def kill_processes():
+ global PROCESSES
+ for p in PROCESSES:
+ if p.returncode is None:
+ p.kill()
+
+
+def boot_nodes():
+ global N, PROCESSES
+ for i in range(1, N+1):
+ p = boot_node("node%d" % i)
+ PROCESSES.append(p)
+
+ for i in range(30):
+ if all_nodes_alive(N):
+ break
+ time.sleep(1)
+
+
+def reboot_nodes():
+ kill_processes()
+ boot_nodes()
+
+
def run_command(cmd):
p = sp.Popen(cmd, shell=True)
p.wait()
exit(p.returncode)
-def wait_for_procs(procs):
+def wait_for_procs():
+ global PROCESSES
while True:
- for p in procs:
+ for p in PROCESSES:
if p.returncode is not None:
exit(1)
time.sleep(2)
@@ -197,29 +224,15 @@ def main():
init_beams()
write_configs(opts)
- procs = []
-
- def kill_procs():
- for p in procs:
- if p.returncode is None:
- p.terminate()
- atexit.register(kill_procs)
-
- for i in range(1, 4):
- p = boot_node("node%d" % i)
- procs.append(p)
-
- for i in range(30):
- if all_nodes_alive(N):
- break
- time.sleep(1)
+ atexit.register(kill_processes)
+ boot_nodes()
connect_nodes("http://127.0.0.1:15986/")
if len(args):
run_command(" ".join(args))
else:
- wait_for_procs(procs)
+ wait_for_procs()
if __name__ == "__main__":
[08/12] couchdb commit: updated refs/heads/1843-feature-bigcouch to
152a21a
Posted by da...@apache.org.
Remove reliance on the curl command in dev/run
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/089f3adc
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/089f3adc
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/089f3adc
Branch: refs/heads/1843-feature-bigcouch
Commit: 089f3adc62d1a68eb10e6dfd26c707fe264bae71
Parents: 49cb551
Author: Paul J. Davis <pa...@gmail.com>
Authored: Thu Feb 6 16:08:05 2014 -0600
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Thu Feb 6 16:08:05 2014 -0600
----------------------------------------------------------------------
dev/run | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/089f3adc/dev/run
----------------------------------------------------------------------
diff --git a/dev/run b/dev/run
index aa3d313..deb2c3a 100755
--- a/dev/run
+++ b/dev/run
@@ -15,6 +15,7 @@
import atexit
import contextlib as ctx
import glob
+import httplib
import optparse as op
import os
import re
@@ -163,11 +164,16 @@ def boot_node(node):
env=env)
-def connect_nodes(backdoor):
- for i in range(1,4):
- cmd = "curl -s %snodes/node%s@127.0.0.1 -X PUT -d '{}'"
- cmd = cmd % (backdoor, i)
- sp.check_call(cmd, shell=True)
+def connect_nodes(host, port):
+ global N
+ for i in range(1, N+1):
+ body = "{}"
+ conn = httplib.HTTPConnection(host, port)
+ conn.request("PUT", "/nodes/node%d@127.0.0.1" % i, body)
+ resp = conn.getresponse()
+ if resp.status not in (200, 201, 202, 409):
+ print resp.reason
+ exit(1)
def kill_processes():
@@ -227,7 +233,7 @@ def main():
atexit.register(kill_processes)
boot_nodes()
- connect_nodes("http://127.0.0.1:15986/")
+ connect_nodes("127.0.0.1", 15986)
if len(args):
run_command(" ".join(args))
[04/12] couchdb commit: updated refs/heads/1843-feature-bigcouch to
152a21a
Posted by da...@apache.org.
Add license headers to dev scripts
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/da332b3d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/da332b3d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/da332b3d
Branch: refs/heads/1843-feature-bigcouch
Commit: da332b3d7e74eb3f6b88ab171c25e1de2f87b3b4
Parents: d991305
Author: Paul J. Davis <pa...@gmail.com>
Authored: Thu Feb 6 14:26:58 2014 -0600
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Thu Feb 6 14:26:58 2014 -0600
----------------------------------------------------------------------
dev/boot_node.erl | 12 ++++++++++++
dev/run | 13 ++++++++++++-
2 files changed, 24 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/da332b3d/dev/boot_node.erl
----------------------------------------------------------------------
diff --git a/dev/boot_node.erl b/dev/boot_node.erl
index cc5cabb..dd55b1b 100644
--- a/dev/boot_node.erl
+++ b/dev/boot_node.erl
@@ -1,3 +1,15 @@
+% 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.
+
-module(boot_node).
-export([start/0]).
http://git-wip-us.apache.org/repos/asf/couchdb/blob/da332b3d/dev/run
----------------------------------------------------------------------
diff --git a/dev/run b/dev/run
index e49040f..91f4e65 100755
--- a/dev/run
+++ b/dev/run
@@ -1,5 +1,16 @@
#!/usr/bin/env python
-
+#
+# 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.
import atexit
import contextlib as ctx
[05/12] couchdb commit: updated refs/heads/1843-feature-bigcouch to
152a21a
Posted by da...@apache.org.
Remove debug logging from dev/run
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/f6759d76
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/f6759d76
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/f6759d76
Branch: refs/heads/1843-feature-bigcouch
Commit: f6759d7627e62577e8af0f0394ff5435b49a8653
Parents: da332b3
Author: Paul J. Davis <pa...@gmail.com>
Authored: Thu Feb 6 16:02:44 2014 -0600
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Thu Feb 6 16:02:44 2014 -0600
----------------------------------------------------------------------
dev/run | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/f6759d76/dev/run
----------------------------------------------------------------------
diff --git a/dev/run b/dev/run
index 91f4e65..29b2a31 100755
--- a/dev/run
+++ b/dev/run
@@ -119,7 +119,7 @@ def all_nodes_alive(n):
while True:
try:
with ctx.closing(urllib.urlopen(url)) as resp:
- print(resp.read())
+ pass
except IOError:
time.sleep(0.25)
continue
@@ -153,7 +153,6 @@ def boot_node(node):
]
logfname = os.path.join(DEV_PATH, "logs", "%s.log" % node)
log = open(logfname, "w")
- print ' '.join(cmd)
return sp.Popen(
cmd,
stdin=sp.PIPE,
[11/12] couchdb commit: updated refs/heads/1843-feature-bigcouch to
152a21a
Posted by da...@apache.org.
Initial implementation of a new JS test runner
This fits into the dev/run format for allowing tests to run with an
available cluster. For now the JS tests only run against the backdoor
port.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/3e09a9ac
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/3e09a9ac
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/3e09a9ac
Branch: refs/heads/1843-feature-bigcouch
Commit: 3e09a9acb8cee93378c7241fd0d3fadcf99258a5
Parents: b69f33f
Author: Paul J. Davis <pa...@gmail.com>
Authored: Thu Feb 6 16:10:32 2014 -0600
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Thu Feb 6 16:10:32 2014 -0600
----------------------------------------------------------------------
.gitignore | 1 -
test/javascript/cli_runner.js | 5 +-
test/javascript/run | 103 +++++++++++++++++++++++++++++++++++++
test/javascript/run.tpl | 80 ----------------------------
test/javascript/test_setup.js | 3 +-
5 files changed, 107 insertions(+), 85 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3e09a9ac/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 17fa92b..29b3732 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,4 +20,3 @@ src/couch/priv/couch_js/config.h
src/couch/priv/couchjs
src/couch/priv/couchspawnkillable
-test/javascript/run
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3e09a9ac/test/javascript/cli_runner.js
----------------------------------------------------------------------
diff --git a/test/javascript/cli_runner.js b/test/javascript/cli_runner.js
index da2eed0..6688bae 100644
--- a/test/javascript/cli_runner.js
+++ b/test/javascript/cli_runner.js
@@ -34,10 +34,11 @@ function runTest() {
// Add artificial wait for each test of 1 sec
while (new Date().getTime() < start + 1200);
couchTests[name]();
- print('OK');
+ quit(0);
} catch(e) {
- console.log("FAIL\nReason: " + e.message);
+ console.log("Error: " + e.message);
fmtStack(e.stack);
+ quit(1)
}
}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3e09a9ac/test/javascript/run
----------------------------------------------------------------------
diff --git a/test/javascript/run b/test/javascript/run
new file mode 100755
index 0000000..8b754fb
--- /dev/null
+++ b/test/javascript/run
@@ -0,0 +1,103 @@
+#!/usr/bin/env python
+#
+# 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.
+
+import atexit
+import contextlib as ctx
+import glob
+import optparse as op
+import os
+import re
+import select
+import subprocess as sp
+import sys
+import time
+import urllib
+
+
+USAGE = "%prog [options] [command to run...]"
+TEST_PATH = os.path.dirname(os.path.abspath(__file__))
+ROOT_PATH = os.path.dirname(os.path.dirname(TEST_PATH))
+N = 3
+
+COUCHJS = "src/couch/priv/couchjs"
+
+SCRIPTS = """
+ share/www/script/json2.js
+ share/www/script/sha1.js
+ share/www/script/oauth.js
+ share/www/script/couch.js
+ share/www/script/couch_test_runner.js
+ test/javascript/couch_http.js
+ test/javascript/test_setup.js
+""".split()
+
+RUNNER = "test/javascript/cli_runner.js"
+
+
+def run_couchjs(test):
+ sys.stderr.write(test + " ... ")
+ sys.stderr.flush()
+ cmd = [COUCHJS, "-H"] + SCRIPTS + [test, RUNNER]
+ p = sp.Popen(
+ cmd,
+ stdin = sp.PIPE,
+ stdout = sp.PIPE,
+ stderr = sys.stderr
+ )
+ for line in p.stdout:
+ if line.strip() == "restart":
+ print "restart_nodes()"
+ else:
+ sys.stderr.write(line)
+ p.wait()
+ if p.returncode == 0:
+ sys.stderr.write("OK" + os.linesep)
+ else:
+ sys.stderr.write("FAIL" + os.linesep)
+ sys.stderr.flush()
+
+
+def options():
+ return []
+
+
+def main():
+ parser = op.OptionParser(usage=USAGE, option_list=options())
+ opts, args = parser.parse_args()
+
+ tests = []
+ if not len(args):
+ args = ["share/www/script/test"]
+ for name in args:
+ if os.path.isdir(name):
+ tests.extend(glob.glob(os.path.join(name, "*.js")))
+ elif os.path.isfile(name):
+ tests.append(name)
+ else:
+ name = os.path.join("share/www/script/test", name)
+ if os.path.isfile(name):
+ tests.append(name)
+ elif os.path.isfile(name + ".js"):
+ tests.append(name + ".js")
+
+ for test in tests:
+ run_couchjs(test)
+
+
+
+if __name__ == "__main__":
+ try:
+ main()
+ except KeyboardInterrupt:
+ pass
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3e09a9ac/test/javascript/run.tpl
----------------------------------------------------------------------
diff --git a/test/javascript/run.tpl b/test/javascript/run.tpl
deleted file mode 100644
index c0fd693..0000000
--- a/test/javascript/run.tpl
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/bin/sh -e
-
-# 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.
-
-SRC_DIR=%rootdir%
-BUILD_DIR=%rootdir%
-SCRIPT_DIR=$SRC_DIR/share/www/script
-JS_TEST_DIR=$SRC_DIR/test/javascript
-COUCHJS=%rootdir%/src/couch/priv/couchjs
-
-
-run() {
- # start the tests
- /bin/echo -n "$1 ... "
- $COUCHJS -H \
- $SCRIPT_DIR/json2.js \
- $SCRIPT_DIR/sha1.js \
- $SCRIPT_DIR/oauth.js \
- $SCRIPT_DIR/couch.js \
- $SCRIPT_DIR/couch_test_runner.js \
- $JS_TEST_DIR/couch_http.js \
- $JS_TEST_DIR/test_setup.js \
- $1 \
- $JS_TEST_DIR/cli_runner.js
-
- if [ -z $RESULT ]; then
- RESULT=$?
- elif [ "$?" -eq 1 ]; then
- RESULT=$?
- fi
-
-}
-
-run_files() {
- COUNTER=1
- FILE_COUNT=$(ls -l $1 | wc -l)
- FILE_COUNT=$(expr $FILE_COUNT + 0)
- for TEST_SRC in $1
- do
- /bin/echo -n "$COUNTER/$FILE_COUNT "
- COUNTER=$(expr $COUNTER + 1)
- run $TEST_SRC
- done
-}
-
-echo "Running javascript tests ..."
-
-if [ "$#" -eq 0 ];
-then
- run_files "$SCRIPT_DIR/test/*.js"
-else
- if [ -d $1 ]; then
- run_files "$1/*.js"
- else
- TEST_SRC="$1"
- if [ ! -f $TEST_SRC ]; then
- TEST_SRC="$SCRIPT_DIR/test/$1"
- if [ ! -f $TEST_SRC ]; then
- TEST_SRC="$SCRIPT_DIR/test/$1.js"
- if [ ! -f $TEST_SRC ]; then
- echo "file $1 does not exist"
- exit 1
- fi
- fi
- fi
- fi
- run $TEST_SRC
-fi
-
-exit $RESULT
http://git-wip-us.apache.org/repos/asf/couchdb/blob/3e09a9ac/test/javascript/test_setup.js
----------------------------------------------------------------------
diff --git a/test/javascript/test_setup.js b/test/javascript/test_setup.js
index 9347455..aaf0562 100644
--- a/test/javascript/test_setup.js
+++ b/test/javascript/test_setup.js
@@ -61,8 +61,7 @@ function waitForSuccess(fun, tag) {
var now = new Date().getTime();
if (now > start + 5000) {
complete = true;
- print('FAIL');
- print(tag);
+ print('FAIL ' + tag);
quit(1);
}
try {