mirror of
https://github.com/foomo/contentserver.git
synced 2025-10-16 12:25:44 +00:00
added targets for testing
This commit is contained in:
parent
97633dc9d9
commit
a4097c05f4
15
Makefile
15
Makefile
@ -27,6 +27,12 @@ build-docker: clean build-arch
|
|||||||
echo "# tagged container `cat .image_id` as $(IMAGE):$(TAG)"
|
echo "# tagged container `cat .image_id` as $(IMAGE):$(TAG)"
|
||||||
rm -vf .image_id .cacert.pem
|
rm -vf .image_id .cacert.pem
|
||||||
|
|
||||||
|
build-testclient:
|
||||||
|
go build -o bin/testclient -i github.com/foomo/contentserver/testing/client
|
||||||
|
|
||||||
|
build-testserver:
|
||||||
|
go build -o bin/testserver -i github.com/foomo/contentserver/testing/server
|
||||||
|
|
||||||
package: build
|
package: build
|
||||||
pkg/build.sh
|
pkg/build.sh
|
||||||
|
|
||||||
@ -46,6 +52,15 @@ test:
|
|||||||
bench:
|
bench:
|
||||||
go test -run=none -bench=. ./...
|
go test -run=none -bench=. ./...
|
||||||
|
|
||||||
|
run-testserver:
|
||||||
|
bin/testserver -json-file var/cse-globus-stage-b-with-main-section.json
|
||||||
|
|
||||||
|
run-contentserver:
|
||||||
|
contentserver -var-dir var -webserver-address :9191 -address :9999 -log-level debug http://127.0.0.1:1234
|
||||||
|
|
||||||
|
clean-var:
|
||||||
|
rm var/contentserver-repo-2019*
|
||||||
|
|
||||||
# Profiling
|
# Profiling
|
||||||
|
|
||||||
test-cpu-profile:
|
test-cpu-profile:
|
||||||
|
|||||||
BIN
contentserver.graffle
Normal file
BIN
contentserver.graffle
Normal file
Binary file not shown.
32
testing/client/client.go
Normal file
32
testing/client/client.go
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
"github.com/foomo/contentserver/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
serverAdr := "http://127.0.0.1:9191/contentserver"
|
||||||
|
c, errClient := client.NewHTTPClient(serverAdr)
|
||||||
|
if errClient != nil {
|
||||||
|
log.Fatal(errClient)
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 1; i <= 50; i++ {
|
||||||
|
go func() {
|
||||||
|
log.Println("start update")
|
||||||
|
resp, errUpdate := c.Update()
|
||||||
|
if errUpdate != nil {
|
||||||
|
spew.Dump(resp)
|
||||||
|
log.Fatal(errUpdate)
|
||||||
|
}
|
||||||
|
log.Println(i, "update done", resp)
|
||||||
|
}()
|
||||||
|
time.Sleep(5 * time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Println("done")
|
||||||
|
}
|
||||||
35
testing/server/server.go
Normal file
35
testing/server/server.go
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
type testServer struct {
|
||||||
|
file string
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
var (
|
||||||
|
flagJSONFile = flag.String("json-file", "", "provide a json source file")
|
||||||
|
flagAddress = flag.String("addr", ":1234", "set the webserver address")
|
||||||
|
)
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
if *flagJSONFile == "" {
|
||||||
|
log.Fatal("js source file must be provided")
|
||||||
|
}
|
||||||
|
|
||||||
|
ts := &testServer{
|
||||||
|
file: *flagJSONFile,
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Println("start test server at", *flagAddress, "serving file:", ts.file)
|
||||||
|
log.Fatal(http.ListenAndServe(*flagAddress, ts))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ts *testServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
http.ServeFile(w, r, ts.file)
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user