Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
Signed-off-by: stefan vassilev <[email protected]>
  • Loading branch information
stefanvassilev committed Apr 26, 2019
1 parent e35d901 commit 381a2c8
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions cmd/query/app/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,48 @@
// limitations under the License.

package app

import (
"testing"
"time"

"github.com/gorilla/mux"
"github.com/opentracing/opentracing-go"
"github.com/stretchr/testify/assert"
"go.uber.org/zap"

"github.com/jaegertracing/jaeger/cmd/flags"
"github.com/jaegertracing/jaeger/cmd/query/app/querysvc"
"github.com/jaegertracing/jaeger/pkg/healthcheck"
"github.com/jaegertracing/jaeger/ports"
)

func TestServer(t *testing.T) {
const testPort = ports.QueryAdminHTTP

flagsSvc := flags.NewService(ports.AgentAdminHTTP)
flagsSvc.HC().Ready()
err := flagsSvc.Admin.Serve()
assert.NoError(t, err)
flagsSvc.Logger = zap.NewNop()
go flagsSvc.RunAndThen(func() {
// no op
})

router := mux.NewRouter()
querySvc := querysvc.QueryService{}
tracker := opentracing.NoopTracer{}

server, err := NewServer(flagsSvc, router,querySvc, tracker, testPort)
assert.NoError(t, err)

server.Start()

err = server.httpServer.Close()
assert.NoError(t, err)
// wait before server is closed
time.Sleep(1 * time.Second)

// after shutdown is called, status gets changed to Broken
assert.Equal(t, healthcheck.Broken, server.svc.HC().Get())
}

0 comments on commit 381a2c8

Please sign in to comment.