Browse Source

Merge pull request #981 from hamiltont/duda-946

Finish adding duda framework
Hamilton Turner 11 years ago
parent
commit
9f152871c6

+ 1 - 0
.travis.yml

@@ -39,6 +39,7 @@ env:
     - TESTDIR=django
     - TESTDIR=django
     - TESTDIR=dropwizard
     - TESTDIR=dropwizard
     - TESTDIR=dropwizard-mongodb
     - TESTDIR=dropwizard-mongodb
+    - TESTDIR=duda
     - TESTDIR=elli
     - TESTDIR=elli
     - TESTDIR=evhttp-sharp
     - TESTDIR=evhttp-sharp
     - TESTDIR=express
     - TESTDIR=express

+ 3 - 0
duda/.gitignore

@@ -0,0 +1,3 @@
+*.o
+*~
+

+ 27 - 0
duda/README.md

@@ -0,0 +1,27 @@
+# Duda I/O Benchmarking Test
+
+This is the web service used to benchmark Duda I/O web services framework.
+
+http://duda.io
+
+## Requirements
+
+Just the GNU C Compiler and a Linux system running Kernel version >= 2.6.32
+
+## Tests available
+
+### 1. JSON
+
+URL: /json
+
+### 6. Plain text
+
+URL: /plaintext
+
+## About pending tests
+
+Most of tests that are related to database query are pending and will be available for the next Round.
+
+## Contact
+
+Eduardo Silva <[email protected]>

+ 0 - 0
duda/__init__.py


+ 5 - 0
duda/bash_profile.sh

@@ -0,0 +1,5 @@
+#!/bin/bash
+
+export DUDAPATH=${IROOT}/dudac-0.23
+
+export PATH="$DUDAPATH:$PATH"

+ 24 - 0
duda/benchmark_config

@@ -0,0 +1,24 @@
+{
+  "framework": "duda",
+  "tests": [{
+    "default": {
+      "setup_file": "setup",
+      "json_url": "/json",
+      "plaintext_url": "/plaintext",
+      "port": 2001,
+      "approach": "Realistic",
+      "classification": "Platform",
+      "database": "none",
+      "framework": "Duda",
+      "language": "C",
+      "orm": "Raw",
+      "platform": "Duda I/O",
+      "webserver": "Monkey",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "Duda I/O",
+      "notes": "",
+      "versus": ""
+    }
+  }]
+}

+ 3 - 0
duda/install.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+
+fw_depends duda

+ 17 - 0
duda/setup.py

@@ -0,0 +1,17 @@
+import subprocess
+import sys
+import os
+import setup_util 
+
+def start(args, logfile, errfile):
+  subprocess.Popen("dudac -w $TROOT/webservice -p 2001", shell=True, stderr=errfile, stdout=logfile);
+  return 0
+
+def stop(logfile, errfile):
+  p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
+  out, err = p.communicate()
+  for line in out.splitlines():
+    if 'monkey' in line:
+      pid = int(line.split(None, 2)[1])
+      os.kill(pid, 15)
+  return 0

+ 7 - 0
duda/webservice/Makefile.in

@@ -0,0 +1,7 @@
+NAME    = ws
+CC      = gcc
+CFLAGS  = -g -Wall -O2
+LDFLAGS =
+DEFS    =
+INCDIR  =
+OBJECTS = main.o

+ 78 - 0
duda/webservice/main.c

@@ -0,0 +1,78 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+/*
+ * Duda I/O Benchmark Tests
+ * ========================
+ * This web service is made for the performance contest made by
+ * TechEmpower, mode details here:
+ *
+ *     http://www.techempower.com/benchmarks
+ *
+ * At the moment only Tests 1 & 6 are implemented.
+ */
+
+#include "webservice.h"
+#include "packages/json/json.h"
+
+/* Test Macros (Tn) */
+#define JSON_CONTENT_TYPE    "Content-Type: application/json"
+#define PLAIN_CONTENT_TYPE   "Content-Type: text/plain"
+#define T6_BODY              "Hello, World!"
+
+DUDA_REGISTER("Duda I/O Benchmark Test", "WS Bench");
+
+/*
+ * Test type 1: JSON serialization
+ * ===============================
+ * This test use the JSON API object to compose the JSON response
+ */
+void cb_json(duda_request_t *dr)
+{
+    char *body;
+    int body_len;
+    json_t *j_root;
+
+    /* Instance the JSON object and compose the content */
+    j_root = json->create_object();
+    json->add_to_object(j_root,
+                        "message",
+                        json->create_string("Hello, World!"));
+
+    /* Format output to string */
+    body = json->print_unformatted_gc(dr, j_root);
+    body_len = strlen(body);
+
+    /* Compose the response */
+    response->http_status(dr, 200);
+    response->http_header_n(dr, JSON_CONTENT_TYPE, sizeof(JSON_CONTENT_TYPE) - 1);
+    response->print(dr, body, body_len);
+    response->end(dr, NULL);
+}
+
+
+/*
+ * Test type 6: Plaintext
+ * ======================
+ */
+void cb_plaintext(duda_request_t *dr)
+{
+    response->http_status(dr, 200);
+    response->http_header_n(dr, PLAIN_CONTENT_TYPE, sizeof(PLAIN_CONTENT_TYPE) - 1);
+    response->print(dr, T6_BODY, sizeof(T6_BODY) - 1);
+    response->end(dr, NULL);
+}
+
+int duda_main()
+{
+    /* load packages */
+    duda_load_package(json, "json");
+
+    /* let this web service own the virtual host */
+    conf->service_root();
+
+    /* set callbacks */
+    map->static_add("/json", "cb_json");            /* Test #1 */
+    map->static_add("/plaintext", "cb_plaintext");  /* Test #6 */
+
+    return 0;
+}

+ 5 - 1
toolset/run-ci.py

@@ -74,7 +74,11 @@ class CIRunnner:
       log.critical("Found no test that is possible to run in Travis-CI! Aborting!")
       log.critical("Found no test that is possible to run in Travis-CI! Aborting!")
       if len(osvalidtests) != 0:
       if len(osvalidtests) != 0:
         log.critical("Note: Found these tests that could run in Travis-CI if more databases were supported")
         log.critical("Note: Found these tests that could run in Travis-CI if more databases were supported")
-        log.criticat("Note: %s", osvalidtests)
+        log.critical("Note: %s", osvalidtests)
+        databases_needed = [t.database for t in osvalidtests]
+        databases_needed = list(set(databases_needed))
+        log.critical("Note: Here are the needed databases:")
+        log.critical("Note: %s", databases_needed)
       sys.exit(1)
       sys.exit(1)
     
     
     # Prefer database tests over 'none' if we have both
     # Prefer database tests over 'none' if we have both

+ 15 - 0
toolset/setup/linux/frameworks/duda.sh

@@ -0,0 +1,15 @@
+#!/bin/bash
+
+RETCODE=$(fw_exists duda-0.23.installed)
+[ ! "$RETCODE" == 0 ] || { return 0; }
+
+fw_get http://duda.io/releases/duda-client/dudac-0.23.tar.gz -O dudac-0.23.tar.gz
+fw_untar dudac-0.23.tar.gz
+
+cd dudac-0.23
+
+./dudac -r
+./dudac -s
+
+cd ..
+touch duda-0.23.installed