Skip to content

Commit

Permalink
Update testing suite (#157)
Browse files Browse the repository at this point in the history
Test Interoperability

- Generate new go server listening on 9999 port satisfying api schema
defined in tests/schema/api.ridl

- Generate go client and server during build step since it's required by
webrpc-server binary

- Clean test cache before each run

- Test interoperability -> getting data from server, sending back and
testing if everything stay the same

- Implement shutdown http method on server to give client possibility of
closing down the server
  • Loading branch information
Lukas Jenicek committed Dec 17, 2022
1 parent 3ea8210 commit fdd8f05
Show file tree
Hide file tree
Showing 10 changed files with 1,635 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
go-version: ${{ matrix.go-version }}
- name: Test
run: go test -v ./...
run: make test

examples:
runs-on: ubuntu-latest
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@ all:

build:
go build -o ./bin/webrpc-gen ./cmd/webrpc-gen
./bin/webrpc-gen -schema=./tests/schema/api.ridl -target=golang -pkg=client -client -out=./tests/client/client.go
./bin/webrpc-gen -schema=./tests/schema/api.ridl -target=golang -pkg=server -server -out=./tests/server/server.gen.go
go build -o ./bin/webrpc-server ./cmd/webrpc-server

clean:
rm -rf ./bin

install: build
go install ./cmd/webrpc-gen

test: generate
test: build
go clean -testcache
./bin/webrpc-server &
go test -v ./...

generate:
Expand Down
23 changes: 23 additions & 0 deletions cmd/webrpc-server/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package main

import (
"net/http"
"github.com/webrpc/webrpc/tests/server"
"os"
)

func main() {
mux := http.NewServeMux()
mux.Handle("/complex/rpc/ComplexApi/GetComplex", http.StripPrefix("/complex", server.NewComplexApiServer(&server.ComplexServer{})))
mux.Handle("/complex/rpc/ComplexApi/SendComplex", http.StripPrefix("/complex", server.NewComplexApiServer(&server.ComplexServer{})))

// shutdown process through http call
mux.Handle("/shutdown", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
os.Exit(0)
}))

err := http.ListenAndServe(":9999", mux)
if err != nil {
panic(err)
}
}
Loading

0 comments on commit fdd8f05

Please sign in to comment.