Эх сурвалжийг харах

Cleanup Nim tests:

* Rename Nimrod to Nim
* Move framework setup from toolset/ into install.sh
* Link Mongrel2 and Nawak with ZeroMQ properly
* Add proper .gitignore files
* Run servers in the background in setup.sh
* Remove bash_profile.sh
Magnus Holm 10 жил өмнө
parent
commit
8392b4ce99
37 өөрчлөгдсөн 158 нэмэгдсэн , 214 устгасан
  1. 3 0
      .gitignore
  2. 3 3
      .travis.yml
  3. 1 0
      frameworks/Nim/jester/.gitignore
  4. 0 0
      frameworks/Nim/jester/README.md
  5. 2 2
      frameworks/Nim/jester/benchmark_config
  6. 0 0
      frameworks/Nim/jester/config/nginx.conf
  7. 1 1
      frameworks/Nim/jester/hello.nim
  8. 18 0
      frameworks/Nim/jester/install.sh
  9. 1 0
      frameworks/Nim/jester/jester
  10. 0 0
      frameworks/Nim/jester/public/.gitkeep
  11. 13 0
      frameworks/Nim/jester/setup.sh
  12. 6 0
      frameworks/Nim/nawak/.gitignore
  13. 0 0
      frameworks/Nim/nawak/app.nim
  14. 4 4
      frameworks/Nim/nawak/benchmark_config
  15. 0 0
      frameworks/Nim/nawak/conf/Makefile
  16. 0 0
      frameworks/Nim/nawak/conf/mongrel2.conf
  17. 0 0
      frameworks/Nim/nawak/fortunes_tmpl.nim
  18. 18 0
      frameworks/Nim/nawak/install.sh
  19. 0 0
      frameworks/Nim/nawak/model.nim
  20. 1 1
      frameworks/Nim/nawak/model_postgre.nim
  21. 1 1
      frameworks/Nim/nawak/model_redis.nim
  22. 24 0
      frameworks/Nim/nawak/setup.sh
  23. 24 0
      frameworks/Nim/nawak/setup_redis.sh
  24. 0 2
      frameworks/Nimrod/jester/.gitignore
  25. 0 3
      frameworks/Nimrod/jester/bash_profile.sh
  26. 0 3
      frameworks/Nimrod/jester/install.sh
  27. 0 11
      frameworks/Nimrod/jester/setup.sh
  28. 0 3
      frameworks/Nimrod/nawak/bash_profile.sh
  29. 0 3
      frameworks/Nimrod/nawak/install.sh
  30. 0 48
      frameworks/Nimrod/nawak/setup.py
  31. 0 20
      frameworks/Nimrod/nawak/setup.sh
  32. 0 49
      frameworks/Nimrod/nawak/setup_redis.py
  33. 0 9
      toolset/setup/linux/frameworks/jester.sh
  34. 0 16
      toolset/setup/linux/frameworks/nawak.sh
  35. 28 0
      toolset/setup/linux/languages/nim.sh
  36. 0 31
      toolset/setup/linux/languages/nimrod.sh
  37. 10 4
      toolset/setup/linux/webservers/mongrel2.sh

+ 3 - 0
.gitignore

@@ -72,3 +72,6 @@ beego/pkg/*
 
 
 # urweb
 # urweb
 frameworks/Ur/urweb/*.exe
 frameworks/Ur/urweb/*.exe
+
+# nim
+nimcache

+ 3 - 3
.travis.yml

@@ -82,8 +82,8 @@ env:
     - "TESTDIR=JavaScript/ringojs-convenient"
     - "TESTDIR=JavaScript/ringojs-convenient"
     - "TESTDIR=Lua/lapis"
     - "TESTDIR=Lua/lapis"
     - "TESTDIR=Lua/openresty"
     - "TESTDIR=Lua/openresty"
-    - "TESTDIR=Nimrod/jester"
-    - "TESTDIR=Nimrod/nawak"
+    - "TESTDIR=Nim/jester"
+    - "TESTDIR=Nim/nawak"
     - "TESTDIR=Perl/dancer"
     - "TESTDIR=Perl/dancer"
     - "TESTDIR=Perl/kelp"
     - "TESTDIR=Perl/kelp"
     - "TESTDIR=Perl/mojolicious"
     - "TESTDIR=Perl/mojolicious"
@@ -163,4 +163,4 @@ install:
 script: 
 script: 
   # Pick one test in this directory and verify
   # Pick one test in this directory and verify
   - time ./toolset/run-ci.py verify "$TESTDIR"
   - time ./toolset/run-ci.py verify "$TESTDIR"
-  
+  

+ 1 - 0
frameworks/Nim/jester/.gitignore

@@ -0,0 +1 @@
+/hello

+ 0 - 0
frameworks/Nimrod/jester/README.md → frameworks/Nim/jester/README.md


+ 2 - 2
frameworks/Nimrod/jester/benchmark_config → frameworks/Nim/jester/benchmark_config

@@ -9,9 +9,9 @@
       "classification": "Micro",
       "classification": "Micro",
       "database": "MySQL",
       "database": "MySQL",
       "framework": "jester",
       "framework": "jester",
-      "language": "Nimrod",
+      "language": "Nim",
       "orm": "Raw",
       "orm": "Raw",
-      "platform": "Nimrod",
+      "platform": "Nim",
       "webserver": "nginx",
       "webserver": "nginx",
       "os": "Linux",
       "os": "Linux",
       "database_os": "Linux",
       "database_os": "Linux",

+ 0 - 0
frameworks/Nimrod/jester/config/nginx.conf → frameworks/Nim/jester/config/nginx.conf


+ 1 - 1
frameworks/Nimrod/jester/hello.nim → frameworks/Nim/jester/hello.nim

@@ -1,7 +1,7 @@
 import jester, strtabs, json, asyncdispatch, os, strutils
 import jester, strtabs, json, asyncdispatch, os, strutils
 
 
 let port = Port(paramStr(1).parseInt)
 let port = Port(paramStr(1).parseInt)
-let settings = newSettings(port=port, http=true)
+let settings = newSettings(port=port)
 
 
 routes:
 routes:
   get "/json":
   get "/json":

+ 18 - 0
frameworks/Nim/jester/install.sh

@@ -0,0 +1,18 @@
+#!/bin/bash
+
+fw_depends nim nginx
+
+export PATH="$IROOT/nim/bin:$PATH"
+
+if ! nimble path jester > /dev/null 2>&1; then
+  pushd $IROOT
+  if [ ! -d jester ]; then
+    git clone https://github.com/dom96/jester.git
+  fi
+  cd jester
+  git fetch origin
+  git checkout da9e3a73ecac51494430dce2a8387e5f0e32f968
+  nimble update
+  nimble install
+  popd
+fi

+ 1 - 0
frameworks/Nim/jester/jester

@@ -0,0 +1 @@
+Subproject commit da9e3a73ecac51494430dce2a8387e5f0e32f968

+ 0 - 0
frameworks/Nimrod/jester/public/.gitkeep → frameworks/Nim/jester/public/.gitkeep


+ 13 - 0
frameworks/Nim/jester/setup.sh

@@ -0,0 +1,13 @@
+#!/bin/bash
+
+export PATH="$IROOT/nim/bin:$IROOT/nginx/sbin:$PATH"
+
+nim c -d:release hello.nim
+nginx -c $TROOT/config/nginx.conf
+
+current=9000
+end=9008
+while [ $current -lt $end ]; do
+  ./hello $current &
+  let current=current+1
+done

+ 6 - 0
frameworks/Nim/nawak/.gitignore

@@ -0,0 +1,6 @@
+/nawak_postgres
+/nawak_redis
+/conf/logs
+/conf/run
+/conf/tmp
+/conf/config.sqlite

+ 0 - 0
frameworks/Nimrod/nawak/app.nim → frameworks/Nim/nawak/app.nim


+ 4 - 4
frameworks/Nimrod/nawak/benchmark_config → frameworks/Nim/nawak/benchmark_config

@@ -14,9 +14,9 @@
       "classification": "Micro",
       "classification": "Micro",
       "database": "Postgres",
       "database": "Postgres",
       "framework": "nawak",
       "framework": "nawak",
-      "language": "Nimrod",
+      "language": "Nim",
       "orm": "Raw",
       "orm": "Raw",
-      "platform": "Nimrod",
+      "platform": "Nim",
       "webserver": "mongrel2",
       "webserver": "mongrel2",
       "os": "Linux",
       "os": "Linux",
       "database_os": "Linux",
       "database_os": "Linux",
@@ -35,9 +35,9 @@
       "classification": "Micro",
       "classification": "Micro",
       "database": "Redis",
       "database": "Redis",
       "framework": "nawak",
       "framework": "nawak",
-      "language": "Nimrod",
+      "language": "Nim",
       "orm": "Raw",
       "orm": "Raw",
-      "platform": "Nimrod",
+      "platform": "Nim",
       "webserver": "mongrel2",
       "webserver": "mongrel2",
       "os": "Linux",
       "os": "Linux",
       "database_os": "Linux",
       "database_os": "Linux",

+ 0 - 0
frameworks/Nimrod/nawak/conf/Makefile → frameworks/Nim/nawak/conf/Makefile


+ 0 - 0
frameworks/Nimrod/nawak/conf/mongrel2.conf → frameworks/Nim/nawak/conf/mongrel2.conf


+ 0 - 0
frameworks/Nimrod/nawak/fortunes_tmpl.nim → frameworks/Nim/nawak/fortunes_tmpl.nim


+ 18 - 0
frameworks/Nim/nawak/install.sh

@@ -0,0 +1,18 @@
+#!/bin/bash
+
+fw_depends nim zeromq mongrel2
+
+export PATH="$IROOT/nim/bin:$PATH"
+
+if ! nimble path nawak > /dev/null 2>&1; then
+  pushd $IROOT
+  if [ ! -d nawak ]; then
+    git clone https://github.com/idlewan/nawak.git
+  fi
+  cd nawak
+  git fetch
+  git checkout b34b0b5077541ae9671957452a70e2578894d3a8
+  nimble update
+  nimble install
+  popd
+fi

+ 0 - 0
frameworks/Nimrod/nawak/model.nim → frameworks/Nim/nawak/model.nim


+ 1 - 1
frameworks/Nimrod/nawak/model_postgre.nim → frameworks/Nim/nawak/model_postgre.nim

@@ -12,7 +12,7 @@ var qupdates_prepared {.threadvar.}: TSqlPrepared
 
 
 proc init_db*() {.procvar.} =
 proc init_db*() {.procvar.} =
     db = open("", "benchmarkdbuser", "benchmarkdbpass",
     db = open("", "benchmarkdbuser", "benchmarkdbpass",
-              "host=localhost port=5432 dbname=hello_world")
+              "host=127.0.0.1 port=5432 dbname=hello_world")
     # prepare queries
     # prepare queries
     qworld_prepared = db.prepare("world", qworld, 1)
     qworld_prepared = db.prepare("world", qworld, 1)
     qfortunes_prepared = db.prepare("fortunes", qfortunes, 0)
     qfortunes_prepared = db.prepare("fortunes", qfortunes, 0)

+ 1 - 1
frameworks/Nimrod/nawak/model_redis.nim → frameworks/Nim/nawak/model_redis.nim

@@ -4,7 +4,7 @@ import model
 var db {.threadvar.}: TRedis
 var db {.threadvar.}: TRedis
 
 
 proc init_db*() {.procvar.} =
 proc init_db*() {.procvar.} =
-    db = open(host="localhost")
+    db = open(host="foobar")
 
 
 proc getWorld*(id: int): TWorld =
 proc getWorld*(id: int): TWorld =
     let s = redis.get(db, "world:" & $id)
     let s = redis.get(db, "world:" & $id)

+ 24 - 0
frameworks/Nim/nawak/setup.sh

@@ -0,0 +1,24 @@
+#!/bin/bash
+
+export PATH="$IROOT/nim/bin:$IROOT/mongrel2/bin:$PATH"
+
+sed -i 's|host=.* port=5432|host='"${DBHOST}"' port=5432|g' model_postgre.nim
+
+echo "** Compiling app"
+nim c --threads:on -d:release -d:postgre_model -l:-Wl,-rpath,$IROOT/zeromq-4.0.3/lib -o:nawak_postgre app.nim
+
+echo "** Starting mongrel2"
+cd conf
+mkdir -p run logs tmp
+m2sh load -config mongrel2.conf
+m2sh start -name test &
+
+cd ..
+nb_workers=256
+if [ "$TRAVIS" == "1" ]; then
+  nb_workers=32
+fi
+
+echo "** Starting app"
+
+./nawak_postgre $nb_workers &

+ 24 - 0
frameworks/Nim/nawak/setup_redis.sh

@@ -0,0 +1,24 @@
+#!/bin/bash
+
+export PATH="$IROOT/nim/bin:$IROOT/mongrel2/bin:$PATH"
+
+sed -i 's|host=.*)|host="'$DBHOST'")|g' model_redis.nim
+
+echo "** Compiling app"
+nim c --threads:on -d:release -d:redis_model -l:-Wl,-rpath,$IROOT/zeromq-4.0.3/lib -o:nawak_redis app.nim
+
+echo "** Starting mongrel2"
+cd conf
+mkdir -p run logs tmp
+m2sh load -config mongrel2.conf
+m2sh start -name test &
+
+cd ..
+nb_workers=256
+if [ "$TRAVIS" == "1" ]; then
+  nb_workers=32
+fi
+
+echo "** Starting app"
+
+./nawak_redis $nb_workers &

+ 0 - 2
frameworks/Nimrod/jester/.gitignore

@@ -1,2 +0,0 @@
-nimcache
-hello

+ 0 - 3
frameworks/Nimrod/jester/bash_profile.sh

@@ -1,3 +0,0 @@
-export JESTER_PATH=${IROOT}/jester
-export NIMROD_HOME=${IROOT}/nimrod
-export NGINX_HOME=${IROOT}/nginx

+ 0 - 3
frameworks/Nimrod/jester/install.sh

@@ -1,3 +0,0 @@
-#!/bin/bash
-
-fw_depends nimrod nginx jester

+ 0 - 11
frameworks/Nimrod/jester/setup.sh

@@ -1,11 +0,0 @@
-#!/bin/bash
-
-${NIMROD_HOME}/bin/nim c -d:release --path:$JESTER_PATH hello.nim
-${NGINX_HOME}/sbin/nginx -c $TROOT/config/nginx.conf
-
-current=9000
-end=9008
-while [ $current -lt $end ]; do
-  ./hello $current &
-  let current=current+1
-done

+ 0 - 3
frameworks/Nimrod/nawak/bash_profile.sh

@@ -1,3 +0,0 @@
-export NAWAK_PATH=${IROOT}/nawak
-export NIMROD_HOME=${IROOT}/nimrod
-export ZEROMQ_HOME=${IROOT}/zeromq-4.0.3

+ 0 - 3
frameworks/Nimrod/nawak/install.sh

@@ -1,3 +0,0 @@
-#!/bin/bash
-
-fw_depends nimrod zeromq mongrel2 nawak

+ 0 - 48
frameworks/Nimrod/nawak/setup.py

@@ -1,48 +0,0 @@
-import subprocess
-import sys
-import setup_util
-import os
-from os.path import expanduser
-
-home = expanduser("~")
-
-def start(args, logfile, errfile):
-  setup_util.replace_text("nawak/model_postgre.nim", "host=.* port=5432",
-                          "host=" + args.database_host + " port=5432")
-  # compile the app
-  subprocess.check_call(
-      "nim c --threads:on -d:release -d:postgre_model --path:$NAWAK_PATH -o:nawak_postgre app.nim",
-      shell=True, cwd="nawak", stderr=errfile, stdout=logfile)
-  # launch mongrel2
-  subprocess.check_call("mkdir -p run logs tmp", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
-  subprocess.check_call("sudo m2sh load -config mongrel2.conf", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
-  subprocess.check_call("sudo m2sh start -name test", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
-  
-  # launch workers
-  if os.environ.get("TRAVIS"):
-    nb_workers = 32
-  else:
-    nb_workers = 256
-  subprocess.Popen("./nawak_postgre " + str(nb_workers),
-                   shell=True, cwd="nawak", stderr=errfile, stdout=logfile)
-  return 0
-
-def stop(logfile, errfile):
-  ret = 0
-
-  try:
-    subprocess.check_call("sudo m2sh stop -every", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
-  except Exception:
-    ret = 1
-
-  p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
-  out, err = p.communicate()
-  for line in out.splitlines():
-    if 'nawak_postgre' in line:
-      try:
-        pid = int(line.split(None, 2)[1])
-        os.kill(pid, 15)
-      except OSError:
-        ret = 1
-
-  return ret

+ 0 - 20
frameworks/Nimrod/nawak/setup.sh

@@ -1,20 +0,0 @@
-#!/bin/bash
-
-sed -i 's|host=.* port=5432|host='"${DBHOST}"' port=5432|g' model_postgre.nim
-
-export PATH=$NIMROD_HOME/bin:$NAWAK_HOME/bin:$ZEROMQ_HOME/include:$NAWAK_PATH:$PATH
-
-nim c --threads:on -d:release -d:postgre_model --path:$NAWAK_PATH -o:nawak_postgre app.nim
-
-cd conf
-mkdir -p run logs tmp
-m2sh load -config mongrel2.conf
-m2sh start -name test
-
-cd ..
-nb_workers=256
-if [ "$TRAVIS" == "1" ]; then
-  nb_workers=32
-if
-
-./nawak_postgre &

+ 0 - 49
frameworks/Nimrod/nawak/setup_redis.py

@@ -1,49 +0,0 @@
-import subprocess
-import sys
-import setup_util
-import os
-from os.path import expanduser
-
-home = expanduser("~")
-
-def start(args, logfile, errfile):
-  setup_util.replace_text("nawak/model_redis.nim",
-                          'open\(host=.*\)',
-                          'open(host="' + args.database_host + '")')
-  # compile the app
-  subprocess.check_call(
-      "nim c --threads:on -d:release -d:redis_model --path:$NAWAK_PATH -o:nawak_redis app.nim",
-      shell=True, cwd="nawak", stderr=errfile, stdout=logfile)
-  # launch mongrel2
-  subprocess.check_call("mkdir -p run logs tmp", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
-  subprocess.check_call("sudo m2sh load -config mongrel2.conf", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
-  subprocess.check_call("sudo m2sh start -name test", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
-  
-  # launch workers
-  if os.environ.get("TRAVIS"):
-    nb_workers = 32
-  else:
-    nb_workers = 256
-  subprocess.Popen("./nawak_redis " + str(nb_workers),
-                   shell=True, cwd="nawak", stderr=errfile, stdout=logfile)
-  return 0
-
-def stop(logfile, errfile):
-  ret = 0
-
-  try:
-    subprocess.check_call("sudo m2sh stop -every", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
-  except Exception:
-    ret = 1
-
-  p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
-  out, err = p.communicate()
-  for line in out.splitlines():
-    if 'nawak_redis' in line:
-      try:
-        pid = int(line.split(None, 2)[1])
-        os.kill(pid, 15)
-      except OSError:
-        ret = 1
-
-  return ret

+ 0 - 9
toolset/setup/linux/frameworks/jester.sh

@@ -1,9 +0,0 @@
-#!/bin/bash
-
-RETCODE=$(fw_exists jester)
-[ ! "$RETCODE" == 0 ] || { return 0; }
-
-git clone git://github.com/dom96/jester.git jester
-cd jester
-# most recent commit in branch new-async as of 2014-10-31
-git checkout 3e77ce753293b523004dfdaebd2fb195217f30f0

+ 0 - 16
toolset/setup/linux/frameworks/nawak.sh

@@ -1,16 +0,0 @@
-#!/bin/bash
-
-RETCODE=$(fw_exists ${IROOT}/nawak.installed)
-[ ! "$RETCODE" == 0 ] || { return 0; }
-
-fw_depends nimrod
-
-git clone git://github.com/idlewan/nawak.git nawak
-cd nawak
-# version 0.3.0 (2014-11-02)
-git checkout b34b0b5077541ae9671957452a70e2578894d3a8
-
-${IROOT}/nimrod/bin/nimble update
-${IROOT}/nimrod/bin/nimble install
-
-touch ${IROOT}/nawak.installed

+ 28 - 0
toolset/setup/linux/languages/nim.sh

@@ -0,0 +1,28 @@
+#!/bin/bash
+
+RETCODE=$(fw_exists $IROOT/nim.installed)
+[ ! "$RETCODE" == 0 ] || { return 0; }
+
+test -d nim || git clone git://github.com/Araq/Nim.git nim
+cd nim
+# post version 0.10.2 - most recent as of 2014-12-
+git checkout v0.10.2
+
+test -d csources || git clone git://github.com/nim-lang/csources.git
+cd csources
+sh build.sh
+cd ..
+
+bin/nim c koch
+
+# bootstrapping nim's compiler
+./koch boot -d:release
+
+# nim's package manager
+test -d nimble || git clone git://github.com/nim-lang/nimble.git
+cd nimble
+git checkout v0.6
+../bin/nim c src/nimble
+mv src/nimble ../bin/
+
+touch $IROOT/nim.installed

+ 0 - 31
toolset/setup/linux/languages/nimrod.sh

@@ -1,31 +0,0 @@
-#!/bin/bash
-
-RETCODE=$(fw_exists $IROOT/nim.installed)
-[ ! "$RETCODE" == 0 ] || { return 0; }
-
-test -d nimrod || git clone git://github.com/Araq/Nimrod.git nimrod
-cd nimrod 
-# post version 0.9.6 - most recent as of 2014-10-31
-git checkout bbb16713c1bbc266cb8d69f262cc302641e361c4
-
-test -d csources || git clone git://github.com/nimrod-code/csources.git
-cd csources
-# post version 0.9.6 - most recent as of 2014-10-31
-git checkout b0bcf88e26730b23d22e2663adf1babb05bd5a71
-sh build.sh
-cd ..
-
-bin/nimrod c koch
-
-# bootstrapping nim's compiler
-./koch boot -d:release
-
-# nim's package manager
-test -d nimble || git clone git://github.com/nimrod-code/nimble.git
-cd nimble
-# post version 0.4.0 - most recent as of 2014-10-31
-git checkout ecd78e0e0300a8178db320d83014d3eb47a89b4c
-../bin/nim c src/nimble
-mv src/nimble ../bin/
-
-touch $IROOT/nim.installed

+ 10 - 4
toolset/setup/linux/webservers/mongrel2.sh

@@ -13,7 +13,6 @@ sudo ldconfig -v
 
 
 fw_get https://github.com/zedshaw/mongrel2/tarball/v1.8.1 -O mongrel2.tar.gz
 fw_get https://github.com/zedshaw/mongrel2/tarball/v1.8.1 -O mongrel2.tar.gz
 fw_untar mongrel2.tar.gz
 fw_untar mongrel2.tar.gz
-mv mongrel2 mongrel2-install
 
 
 # mongrel2 untars into this folder 
 # mongrel2 untars into this folder 
 mv zedshaw-mongrel2-aa2ecf8 mongrel2-install
 mv zedshaw-mongrel2-aa2ecf8 mongrel2-install
@@ -23,7 +22,14 @@ fw_get https://raw.github.com/zedshaw/mongrel2/9b565eeea003783c47502c2d350b99c96
 mv -f zmq_compat.h mongrel2-install/src/
 mv -f zmq_compat.h mongrel2-install/src/
 
 
 cd mongrel2-install
 cd mongrel2-install
-PREFIX=${IROOT}/mongrel2 make clean all
-PREFIX=${IROOT}/mongrel2 make install
 
 
-touch ${IROOT}/mongrel2.installed
+# Do this in a subshell to avoid leaking env variables
+(
+  export PREFIX=${IROOT}/mongrel2
+  export OPTFLAGS="-I$IROOT/zeromq-4.0.3/include"
+  export OPTLIBS="-Wl,-rpath,$IROOT/zeromq-4.0.3/lib -L$IROOT/zeromq-4.0.3/lib"
+  make clean all
+  make install
+)
+
+touch ${IROOT}/mongrel2.installed