Browse Source

Merge pull request #2090 from methane/go-std-integrate

go-std: integrate go-std-* tests
Nate 9 years ago
parent
commit
819cc9de6e

+ 1 - 3
.travis.yml

@@ -60,9 +60,7 @@ env:
     - "TESTDIR=Go/fasthttp-postgresql"
     - "TESTDIR=Go/gin"
     - "TESTDIR=Go/goji"
-    - "TESTDIR=Go/go-std-mongodb"
-    - "TESTDIR=Go/go-std-mysql"
-    - "TESTDIR=Go/go-std-postgresql"
+    - "TESTDIR=Go/go-std"
     - "TESTDIR=Go/revel"
     - "TESTDIR=Go/webgo"
     - "TESTDIR=Groovy/grails"

+ 0 - 3
frameworks/Go/go-std-mongodb/README.md

@@ -1,3 +0,0 @@
-# Go MongoDB Benchmarking Test
-
-This is the Go portion of a [benchmarking test suite](../), which uses MongoDB as its database.

+ 0 - 28
frameworks/Go/go-std-mongodb/benchmark_config.json

@@ -1,28 +0,0 @@
-{
-  "framework": "go-mongodb",
-  "tests": [{
-    "default": {
-      "setup_file": "setup",
-      "json_url": "/json",
-      "db_url": "/db",
-      "query_url": "/queries?queries=",
-      "fortune_url": "/fortune",
-      "update_url": "/update?queries=",
-      "plaintext_url": "/plaintext",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Platform",
-      "database": "MongoDB",
-      "framework": "go",
-      "language": "Go",
-      "orm": "Raw",
-      "platform": "Go",
-      "webserver": "None",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "go-std-mongodb",
-      "notes": "mongodb implementation for go net/http",
-      "versus": "go"
-    }
-  }]
-}

+ 0 - 6
frameworks/Go/go-std-mongodb/source_code

@@ -1,6 +0,0 @@
-./go/src/
-./go/src/hello
-./go/src/hello/hello.go
-./go/templates/
-./go/templates/fortune.html
-./go/templates/layout.html

+ 0 - 14
frameworks/Go/go-std-mongodb/templates/fortune.html

@@ -1,14 +0,0 @@
-{{define "content"}}
-<table>
-<tr>
-<th>id</th>
-<th>message</th>
-</tr>
-{{range .}}
-<tr>
-<td>{{.Id}}</td>
-<td>{{.Message}}</td>
-</tr>
-{{end}}
-</table>
-{{end}}

+ 0 - 9
frameworks/Go/go-std-mongodb/templates/layout.html

@@ -1,9 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<title>Fortunes</title>
-</head>
-<body>
-{{template "content" .}}
-</body>
-</html>

+ 0 - 2
frameworks/Go/go-std-mysql/setup.bat

@@ -1,2 +0,0 @@
-set GOPATH=C:\FrameworkBenchmarks\go
-go run src\hello\hello.go

+ 0 - 7
frameworks/Go/go-std-mysql/setup.sh

@@ -1,7 +0,0 @@
-#!/bin/bash
-
-fw_depends go
-
-go get ./...
-
-go run src/hello/hello.go &

+ 0 - 7
frameworks/Go/go-std-mysql/setup_prefork.sh

@@ -1,7 +0,0 @@
-#!/bin/bash
-
-fw_depends go
-
-go get ./...
-
-go run src/hello/hello.go -prefork &

+ 0 - 3
frameworks/Go/go-std-mysql/source_code

@@ -1,3 +0,0 @@
-./go/src/
-./go/src/hello
-./go/src/hello/hello.go

+ 0 - 26
frameworks/Go/go-std-postgresql/benchmark_config.json

@@ -1,26 +0,0 @@
-{
-  "framework": "go-std-postgresql",
-  "tests": [{
-    "default": {
-      "setup_file": "setup",
-      "db_url": "/db",
-      "query_url": "/queries?queries=",
-      "fortune_url": "/fortune",
-      "update_url": "/update?queries=",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Platform",
-      "database": "Postgres",
-      "framework": "go",
-      "language": "Go",
-      "orm": "Raw",
-      "platform": "Go",
-      "webserver": "None",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "go-std-postgresql",
-      "notes": "",
-      "versus": "go"
-    }
-  }]
-}

+ 0 - 7
frameworks/Go/go-std-postgresql/setup.sh

@@ -1,7 +0,0 @@
-#!/bin/bash
-
-fw_depends go
-
-go get ./...
-
-go run src/hello/hello.go &

+ 0 - 3
frameworks/Go/go-std-postgresql/source_code

@@ -1,3 +0,0 @@
-./go/src/
-./go/src/hello
-./go/src/hello/hello.go

+ 2 - 2
frameworks/Go/go-std-mysql/README.md → frameworks/Go/go-std/README.md

@@ -1,13 +1,13 @@
 # Go Benchmarking Test
 
-This is the go portion of a [benchmarking test suite](../) comparing a variety of web development platforms.
+This is the Go portion of a [benchmarking test suite](../) comparing a variety of web development platforms.
 
 ### JSON Encoding Test
 * [JSON test source](src/hello/hello.go)
 
 ## Versions
 
-* [Go 1.2rc3](http://golang.org/)
+* [Go 1.6](http://golang.org/)
 
 ## Test URLs
 

+ 45 - 3
frameworks/Go/go-std-mysql/benchmark_config.json → frameworks/Go/go-std/benchmark_config.json

@@ -20,7 +20,7 @@
       "webserver": "None",
       "os": "Linux",
       "database_os": "Linux",
-      "display_name": "go-std-mysql",
+      "display_name": "go-mysql",
       "notes": "",
       "versus": "go"
     },
@@ -41,7 +41,7 @@
       "webserver": "None",
       "os": "Linux",
       "database_os": "Linux",
-      "display_name": "go-std-mysql-interpolate",
+      "display_name": "go-mysql-interpolate",
       "notes": "",
       "versus": "go"
     },
@@ -64,7 +64,49 @@
       "webserver": "None",
       "os": "Linux",
       "database_os": "Linux",
-      "display_name": "go-std-prefork-mysql",
+      "display_name": "go-mysql-prefork",
+      "notes": "",
+      "versus": "go"
+    },
+    "mongo": {
+      "setup_file": "setup_mongo",
+      "db_url": "/db",
+      "query_url": "/queries?queries=",
+      "fortune_url": "/fortune",
+      "update_url": "/update?queries=",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Platform",
+      "database": "MongoDB",
+      "framework": "go",
+      "language": "Go",
+      "orm": "Raw",
+      "platform": "Go",
+      "webserver": "None",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "go-mongodb",
+      "notes": "mongodb implementation for go net/http",
+      "versus": "go"
+    },
+    "postgres": {
+      "setup_file": "setup_postgres",
+      "db_url": "/db",
+      "query_url": "/queries?queries=",
+      "fortune_url": "/fortune",
+      "update_url": "/update?queries=",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Platform",
+      "database": "Postgres",
+      "framework": "go",
+      "language": "Go",
+      "orm": "Raw",
+      "platform": "Go",
+      "webserver": "None",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "go-postgresql",
       "notes": "",
       "versus": "go"
     }

+ 24 - 21
frameworks/Go/go-std-mongodb/src/hello/hello.go → frameworks/Go/go-std/hello_mongo.go

@@ -2,25 +2,44 @@ package main
 
 import (
 	"encoding/json"
-	"gopkg.in/mgo.v2"
-	"gopkg.in/mgo.v2/bson"
 	"html/template"
 	"log"
 	"math/rand"
 	"net/http"
 	"sort"
 	"strconv"
+
+	"gopkg.in/mgo.v2"
+	"gopkg.in/mgo.v2/bson"
 )
 
 const (
 	connectionString = "localhost"
-	helloWorldString = "Hello, world!"
 	worldRowCount    = 10000
+	fortuneHTML      = `<!DOCTYPE html>
+<html>
+<head>
+<title>Fortunes</title>
+</head>
+<body>
+<table>
+<tr>
+<th>id</th>
+<th>message</th>
+</tr>
+{{range .}}
+<tr>
+<td>{{.Id}}</td>
+<td>{{.Message}}</td>
+</tr>
+{{end}}
+</table>
+</body>
+</html>`
 )
 
 var (
-	tmpl            = template.Must(template.ParseFiles("templates/layout.html", "templates/fortune.html"))
-	helloWorldBytes = []byte(helloWorldString)
+	tmpl = template.Must(template.New("fortune.html").Parse(fortuneHTML))
 
 	database *mgo.Database
 	fortunes *mgo.Collection
@@ -66,22 +85,13 @@ func main() {
 	database = session.DB("hello_world")
 	worlds = database.C("world")
 	fortunes = database.C("fortune")
-	http.HandleFunc("/json", jsonHandler)
 	http.HandleFunc("/db", dbHandler)
 	http.HandleFunc("/fortune", fortuneHandler)
 	http.HandleFunc("/queries", queriesHandler)
 	http.HandleFunc("/update", updateHandler)
-	http.HandleFunc("/plaintext", plaintextHandler)
 	http.ListenAndServe(":8080", nil)
 }
 
-// Test 1: JSON serialization
-func jsonHandler(w http.ResponseWriter, r *http.Request) {
-	w.Header().Set("Content-Type", "application/json")
-	w.Header().Set("Server", "go-mongodb")
-	json.NewEncoder(w).Encode(&Message{helloWorldString})
-}
-
 // Helper for random numbers
 func getRandomNumber() uint16 {
 	return uint16(rand.Intn(worldRowCount) + 1)
@@ -169,10 +179,3 @@ func updateHandler(w http.ResponseWriter, r *http.Request) {
 	w.Header().Set("Server", "Go")
 	json.NewEncoder(w).Encode(&world)
 }
-
-// Test 6: Plaintext
-func plaintextHandler(w http.ResponseWriter, r *http.Request) {
-	w.Header().Set("Content-Type", "text/plain")
-	w.Header().Set("Server", "go-mongodb")
-	w.Write(helloWorldBytes)
-}

+ 0 - 0
frameworks/Go/go-std-mysql/src/hello/hello.go → frameworks/Go/go-std/hello_mysql.go


+ 0 - 0
frameworks/Go/go-std-postgresql/src/hello/hello.go → frameworks/Go/go-std/hello_postgres.go


+ 0 - 0
frameworks/Go/go-std-mongodb/setup.bat → frameworks/Go/go-std/setup.bat


+ 7 - 0
frameworks/Go/go-std/setup.sh

@@ -0,0 +1,7 @@
+#!/bin/bash
+
+fw_depends go
+
+go get github.com/go-sql-driver/mysql
+
+go run hello_mysql.go &

+ 2 - 3
frameworks/Go/go-std-mongodb/setup.sh → frameworks/Go/go-std/setup_mongo.sh

@@ -1,10 +1,9 @@
 #!/bin/bash
 
-sed -i 's|connectionString = "localhost"|connectionString = "'"${DBHOST}"'"|g' src/hello/hello.go
+sed -i 's|connectionString = "localhost"|connectionString = "'"${DBHOST}"'"|g' hello_mongo.go
 
 fw_depends go
 
 go get gopkg.in/mgo.v2
-go get ./...
 
-go run src/hello/hello.go &
+go run hello_mongo.go &

+ 7 - 0
frameworks/Go/go-std/setup_postgres.sh

@@ -0,0 +1,7 @@
+#!/bin/bash
+
+fw_depends go
+
+go get github.com/lib/pq
+
+go run hello_postgres.go &

+ 7 - 0
frameworks/Go/go-std/setup_prefork.sh

@@ -0,0 +1,7 @@
+#!/bin/bash
+
+fw_depends go
+
+go get github.com/go-sql-driver/mysql
+
+go run hello_mysql.go -prefork &

+ 3 - 0
frameworks/Go/go-std/source_code

@@ -0,0 +1,3 @@
+./hello_mysql.go
+./hello_mongo.go
+./hello_postgres.go