From c656f8e11dce4beed67640dee53e329b47374215 Mon Sep 17 00:00:00 2001 From: Naren Dasan Date: Fri, 6 Oct 2017 17:25:34 -0500 Subject: [PATCH 01/17] travis CI unit tests --- .travis.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index c073401..1d07462 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,14 +4,22 @@ go: - 1.8 - 1.8.x +jobs: + include: + - stage: build + script: + - go get -u github.com/golang/dep/... + - dep ensure + - go install github.com/acm-uiuc/arbor + - stage: test + script: + - cd tests + - go test -v + + matrix: allow_failures: - go: 1.8.x - -script: - - go get -u github.com/golang/dep/... - - dep ensure - - go install github.com/acm-uiuc/arbor notifications: email: false From dcd21433b632fdbde8ff5677b87f815bf3f14983 Mon Sep 17 00:00:00 2001 From: Naren Dasan Date: Fri, 6 Oct 2017 17:30:24 -0500 Subject: [PATCH 02/17] travis CI unit tests --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 1d07462..0137dfa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,9 @@ jobs: - cd tests - go test -v +stages: + - build + - test matrix: allow_failures: From 14190246d0db1969bc9e8dbb2fc765af8090641e Mon Sep 17 00:00:00 2001 From: Naren Dasan Date: Fri, 6 Oct 2017 17:37:30 -0500 Subject: [PATCH 03/17] trying sudo trick --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 0137dfa..763839f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,8 @@ go: - 1.8 - 1.8.x +sudo: false + jobs: include: - stage: build From 9110502a8cf431a8c59edb1ce825761a5ef3f707 Mon Sep 17 00:00:00 2001 From: Naren Dasan Date: Fri, 6 Oct 2017 17:50:02 -0500 Subject: [PATCH 04/17] truncated script --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 763839f..1214f2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,8 +15,7 @@ jobs: - go install github.com/acm-uiuc/arbor - stage: test script: - - cd tests - - go test -v + - go test -v github.com/acm-uiuc/arbor/tests stages: - build From 04f8fa4a5dcfd9c5a360728247352ceb553b2316 Mon Sep 17 00:00:00 2001 From: Naren Dasan Date: Fri, 6 Oct 2017 17:57:51 -0500 Subject: [PATCH 05/17] different URL --- tests/proxy_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/proxy_test.go b/tests/proxy_test.go index 205d7be..2ddc4dd 100644 --- a/tests/proxy_test.go +++ b/tests/proxy_test.go @@ -17,7 +17,7 @@ import ( "github.com/acm-uiuc/arbor/server" ) -const url string = "http://localhost:8000" +const url string = "http://127.0.0.1:8000" type product struct { ID int `json:"id"` From 6e7c06c487c9f3490e99acdd9edf1c4068cf23c2 Mon Sep 17 00:00:00 2001 From: Naren Dasan Date: Fri, 6 Oct 2017 18:00:06 -0500 Subject: [PATCH 06/17] dep update --- Gopkg.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gopkg.toml b/Gopkg.toml index 3033869..7e05d60 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -1,12 +1,12 @@ -[[dependencies]] +[[constraint]] branch = "master" name = "github.com/gorilla/mux" -[[dependencies]] +[[constraint]] branch = "master" name = "github.com/kennygrant/sanitize" -[[dependencies]] +[[constraint]] branch = "master" name = "github.com/syndtr/goleveldb" From 155f54eae8dd83d10e18d12bf63b9ea36c518a90 Mon Sep 17 00:00:00 2001 From: Naren Dasan Date: Fri, 6 Oct 2017 18:00:58 -0500 Subject: [PATCH 07/17] change url again --- tests/proxy_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/proxy_test.go b/tests/proxy_test.go index 2ddc4dd..f8d6ddd 100644 --- a/tests/proxy_test.go +++ b/tests/proxy_test.go @@ -17,7 +17,7 @@ import ( "github.com/acm-uiuc/arbor/server" ) -const url string = "http://127.0.0.1:8000" +const url string = "http://0.0.0.0:8000" type product struct { ID int `json:"id"` From 0a1a3b485a3dcd33bbfb72016d598187658f8658 Mon Sep 17 00:00:00 2001 From: Naren Dasan Date: Thu, 2 Nov 2017 13:06:24 -0500 Subject: [PATCH 08/17] urls to 127.0.0.1 --- tests/proxy_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/proxy_test.go b/tests/proxy_test.go index f8d6ddd..2ddc4dd 100644 --- a/tests/proxy_test.go +++ b/tests/proxy_test.go @@ -17,7 +17,7 @@ import ( "github.com/acm-uiuc/arbor/server" ) -const url string = "http://0.0.0.0:8000" +const url string = "http://127.0.0.1:8000" type product struct { ID int `json:"id"` From 3159bad14aef4e35003b49d60b8b1ddb747c5cfb Mon Sep 17 00:00:00 2001 From: Naren Dasan Date: Thu, 2 Nov 2017 13:08:38 -0500 Subject: [PATCH 09/17] new go version --- .travis.yml | 7 +++++-- examples/gateway/product_service.go | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1214f2d..e36effc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,9 @@ language: go go: - 1.8 - - 1.8.x + - 1.8.x + - 1.9 + - 1.9.x sudo: false @@ -23,7 +25,8 @@ stages: matrix: allow_failures: - - go: 1.8.x + - go: 1.8.x + - go: 1.9.x notifications: email: false diff --git a/examples/gateway/product_service.go b/examples/gateway/product_service.go index 02b4443..c2e65db 100644 --- a/examples/gateway/product_service.go +++ b/examples/gateway/product_service.go @@ -7,7 +7,7 @@ import ( ) //URL of the Product Service API -const productServiceURL string = "http://localhost:5000" +const productServiceURL string = "http://127.0.0.1:5000" //Data format of the API const productServiceFormat string = "JSON" From ac8fea41e42e24808190513247542f6e38eb53c5 Mon Sep 17 00:00:00 2001 From: Naren Dasan Date: Thu, 2 Nov 2017 13:11:50 -0500 Subject: [PATCH 10/17] new go version --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index e36effc..6a28f11 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,6 @@ language: go go: - 1.8 - 1.8.x - - 1.9 - - 1.9.x sudo: false @@ -26,7 +24,6 @@ stages: matrix: allow_failures: - go: 1.8.x - - go: 1.9.x - + notifications: email: false From 4ee84312730794c3bc5dd89355c60db7d49f233d Mon Sep 17 00:00:00 2001 From: Naren Dasan Date: Thu, 2 Nov 2017 13:15:40 -0500 Subject: [PATCH 11/17] new go version --- .travis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6a28f11..b313c7d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,9 @@ language: go go: - 1.8 - - 1.8.x + - 1.8.x + - 1.9 + - 1.9.x sudo: false @@ -23,7 +25,8 @@ stages: matrix: allow_failures: - - go: 1.8.x + - go: 1.8.x + - go: 1.9.x notifications: email: false From c6e4606e897e375f1915f2ce7987ae5db96ada54 Mon Sep 17 00:00:00 2001 From: Benjamin Congdon Date: Mon, 20 Nov 2017 07:58:09 -0800 Subject: [PATCH 12/17] Add customizable bind address --- examples/gateway/arbor-example-gateway/main.go | 2 +- server.go | 6 +++--- server/server.go | 14 +++++++------- tests/proxy_test.go | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/gateway/arbor-example-gateway/main.go b/examples/gateway/arbor-example-gateway/main.go index 709e585..75cbbdc 100644 --- a/examples/gateway/arbor-example-gateway/main.go +++ b/examples/gateway/arbor-example-gateway/main.go @@ -9,5 +9,5 @@ func main() { //Configure Arbor gateway.ConfigArbor() //Register the Routes in a Collection and Boot Arbor - arbor.Boot(gateway.RegisterRoutes(), 8000) + arbor.Boot(gateway.RegisterRoutes(), "127.0.0.1", 8000) } diff --git a/server.go b/server.go index 6e6fe00..d4cde2b 100644 --- a/server.go +++ b/server.go @@ -44,7 +44,7 @@ const help = `Usage: executable [-r | --register-client client_name] [-c | --che // runs arbor with the security layer // // It will start the arbor instance, parsing the command arguments and execute the behavior. -func Boot(routes RouteCollection, port uint16) *server.ArborServer { +func Boot(routes RouteCollection, addr string, port uint16) *server.ArborServer { var srv *server.ArborServer if len(os.Args) == 3 && (os.Args[1] == "--register-client" || os.Args[1] == "-r") { RegisterClient(os.Args[2]) @@ -52,14 +52,14 @@ func Boot(routes RouteCollection, port uint16) *server.ArborServer { CheckRegistration(os.Args[2]) } else if len(os.Args) == 2 && (os.Args[1] == "--unsecured" || os.Args[1] == "-u") { logger.Log(logger.WARN, "Starting Arbor in unsecured mode") - srv = server.StartUnsecuredServer(routes.toServiceRoutes(), port) + srv = server.StartUnsecuredServer(routes.toServiceRoutes(), addr, port) } else if len(os.Args) == 2 && (os.Args[1] == "--help" || os.Args[1] == "-h") { fmt.Println(help) } else if len(os.Args) > 1 { logger.Log(logger.ERR, "Unknown Command") fmt.Println(help) } else { - srv = server.StartSecuredServer(routes.toServiceRoutes(), port) + srv = server.StartSecuredServer(routes.toServiceRoutes(), addr, port) } return srv } diff --git a/server/server.go b/server/server.go index d42592b..f1526ec 100644 --- a/server/server.go +++ b/server/server.go @@ -18,9 +18,9 @@ type ArborServer struct { } //NewServer creates a new ArborSever -func NewServer(routes services.RouteCollection, port uint16) *ArborServer { +func NewServer(routes services.RouteCollection, addr string, port uint16) *ArborServer { a := new(ArborServer) - a.addr = fmt.Sprintf(":%d", port) + a.addr = fmt.Sprintf("%s:%d", addr, port) a.router = NewRouter(routes) a.server = &http.Server{Addr: a.addr, Handler: a.router} return a @@ -28,7 +28,7 @@ func NewServer(routes services.RouteCollection, port uint16) *ArborServer { //StartServer starts the http server in a goroutine to start listening func (a *ArborServer) StartServer() { - logger.Log(logger.SPEC, "Roots being planted [Server is listening on localhost"+a.addr+"]") + logger.Log(logger.SPEC, "Roots being planted [Server is listening on "+a.addr+"]") go func() { err := a.server.ListenAndServe() @@ -54,8 +54,8 @@ func (a *ArborServer) KillServer() { // StartSecuredServer starts a secured arbor server (Token required for access) // // Provide a set of routes to serve and a port to serve on. -func StartSecuredServer(routes services.RouteCollection, port uint16) *ArborServer { - srv := NewServer(routes, port) +func StartSecuredServer(routes services.RouteCollection, addr string, port uint16) *ArborServer { + srv := NewServer(routes, addr, port) security.Init() srv.StartServer() return srv @@ -64,8 +64,8 @@ func StartSecuredServer(routes services.RouteCollection, port uint16) *ArborServ // StartUnsecuredServer starts an unsecured arbor server (Token required for access) // // Provide a set of routes to server and a port to serve on/ -func StartUnsecuredServer(routes services.RouteCollection, port uint16) *ArborServer { - srv := NewServer(routes, port) +func StartUnsecuredServer(routes services.RouteCollection, addr string, port uint16) *ArborServer { + srv := NewServer(routes, addr, port) srv.StartServer() return srv } diff --git a/tests/proxy_test.go b/tests/proxy_test.go index 2ddc4dd..2f24c63 100644 --- a/tests/proxy_test.go +++ b/tests/proxy_test.go @@ -35,7 +35,7 @@ func newTestingServices() *testingServices { t.testService = products.NewApp() t.testService.Run() gateway.ConfigArbor() - t.testGateway = arbor.Boot(gateway.RegisterRoutes(), 8000) + t.testGateway = arbor.Boot(gateway.RegisterRoutes(), "127.0.0.1", 8000) return t } From cf6f916f409ba34fd284290679e64eec067e783b Mon Sep 17 00:00:00 2001 From: Benjamin Congdon Date: Mon, 20 Nov 2017 08:02:41 -0800 Subject: [PATCH 13/17] Update test localhost address --- examples/gateway/arbor-example-gateway/main.go | 2 +- examples/products/service.go | 2 +- tests/proxy_test.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/gateway/arbor-example-gateway/main.go b/examples/gateway/arbor-example-gateway/main.go index 75cbbdc..a04ff90 100644 --- a/examples/gateway/arbor-example-gateway/main.go +++ b/examples/gateway/arbor-example-gateway/main.go @@ -9,5 +9,5 @@ func main() { //Configure Arbor gateway.ConfigArbor() //Register the Routes in a Collection and Boot Arbor - arbor.Boot(gateway.RegisterRoutes(), "127.0.0.1", 8000) + arbor.Boot(gateway.RegisterRoutes(), "0.0.0.0", 8000) } diff --git a/examples/products/service.go b/examples/products/service.go index b099d18..b213896 100644 --- a/examples/products/service.go +++ b/examples/products/service.go @@ -21,7 +21,7 @@ func NewApp() *App { a.Router = mux.NewRouter() a.Model = newProductModel() a.initializeRoutes() - a.Srv = &http.Server{Addr: ":5000", Handler: a.Router} + a.Srv = &http.Server{Addr: "0.0.0.0:5000", Handler: a.Router} return a } diff --git a/tests/proxy_test.go b/tests/proxy_test.go index 2f24c63..4a6acd6 100644 --- a/tests/proxy_test.go +++ b/tests/proxy_test.go @@ -17,7 +17,7 @@ import ( "github.com/acm-uiuc/arbor/server" ) -const url string = "http://127.0.0.1:8000" +const url string = "http://0.0.0.0:8000" type product struct { ID int `json:"id"` @@ -35,7 +35,7 @@ func newTestingServices() *testingServices { t.testService = products.NewApp() t.testService.Run() gateway.ConfigArbor() - t.testGateway = arbor.Boot(gateway.RegisterRoutes(), "127.0.0.1", 8000) + t.testGateway = arbor.Boot(gateway.RegisterRoutes(), "0.0.0.0", 8000) return t } From f2f7f237d17c442a2cbdcea291021a3a1ec02cf3 Mon Sep 17 00:00:00 2001 From: Benjamin Congdon Date: Mon, 20 Nov 2017 08:38:59 -0800 Subject: [PATCH 14/17] Add delay in tests --- tests/proxy_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/proxy_test.go b/tests/proxy_test.go index 4a6acd6..5342b99 100644 --- a/tests/proxy_test.go +++ b/tests/proxy_test.go @@ -36,6 +36,7 @@ func newTestingServices() *testingServices { t.testService.Run() gateway.ConfigArbor() t.testGateway = arbor.Boot(gateway.RegisterRoutes(), "0.0.0.0", 8000) + time.Sleep(250 * time.Millisecond) return t } From aded97e73475db2dee910d272257cad2407ecb10 Mon Sep 17 00:00:00 2001 From: Benjamin Congdon Date: Mon, 20 Nov 2017 08:45:51 -0800 Subject: [PATCH 15/17] Add more test delay --- tests/proxy_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/proxy_test.go b/tests/proxy_test.go index 5342b99..0a3db2f 100644 --- a/tests/proxy_test.go +++ b/tests/proxy_test.go @@ -43,6 +43,7 @@ func newTestingServices() *testingServices { func (t *testingServices) killTestingServices() { t.testGateway.KillServer() t.testService.Kill() + time.Sleep(250 * time.Millisecond) } func TestProxyGETEmpty(t *testing.T) { From a18546aa5e63450bc14b06efd3614abb9a1357b5 Mon Sep 17 00:00:00 2001 From: Benjamin Congdon Date: Mon, 20 Nov 2017 08:50:06 -0800 Subject: [PATCH 16/17] Bind examples to 0.0.0.0 --- examples/gateway/product_service.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gateway/product_service.go b/examples/gateway/product_service.go index c2e65db..3008944 100644 --- a/examples/gateway/product_service.go +++ b/examples/gateway/product_service.go @@ -7,7 +7,7 @@ import ( ) //URL of the Product Service API -const productServiceURL string = "http://127.0.0.1:5000" +const productServiceURL string = "http://0.0.0.0:5000" //Data format of the API const productServiceFormat string = "JSON" From 4f5d3b477b3270f67dbcc2bc763f0354ded18fec Mon Sep 17 00:00:00 2001 From: Benjamin Congdon Date: Mon, 20 Nov 2017 09:00:28 -0800 Subject: [PATCH 17/17] Fix Shutdown context --- examples/products/service.go | 3 ++- server/server.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/products/service.go b/examples/products/service.go index b213896..14aa07f 100644 --- a/examples/products/service.go +++ b/examples/products/service.go @@ -1,6 +1,7 @@ package products import ( + "context" "encoding/json" "fmt" "log" @@ -41,7 +42,7 @@ func (a *App) Run() { func (a *App) Kill() { fmt.Println("Killing example service") - a.Srv.Shutdown(nil) + a.Srv.Shutdown(context.Background()) } func (a *App) initializeRoutes() { diff --git a/server/server.go b/server/server.go index f1526ec..f9a2d4b 100644 --- a/server/server.go +++ b/server/server.go @@ -3,6 +3,7 @@ package server import ( "fmt" "net/http" + "context" "github.com/acm-uiuc/arbor/logger" "github.com/acm-uiuc/arbor/security" @@ -45,7 +46,7 @@ func (a *ArborServer) StartServer() { //KillServer ends the http server func (a *ArborServer) KillServer() { logger.Log(logger.SPEC, "Pulling up the roots [Shutting down the server...]") - a.server.Shutdown(nil) + a.server.Shutdown(context.Background()) if security.IsEnabled() { security.Shutdown() }