Skip to content

Commit

Permalink
fix(tests): remove jaeger
Browse files Browse the repository at this point in the history
Signed-off-by: Valery Piashchynski <piashchynski.valery@gmail.com>
  • Loading branch information
rustatian committed Jul 8, 2024
1 parent bcc9176 commit e93a050
Showing 1 changed file with 1 addition and 96 deletions.
97 changes: 1 addition & 96 deletions tests/http_otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/roadrunner-server/otel/v5"
"github.com/roadrunner-server/server/v5"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -221,98 +220,4 @@ func TestHTTPOTLP_WithPHP(t *testing.T) {
assert.Equal(t, 1, oLogger.FilterMessageSnippet("trace_id").Len())
assert.Equal(t, 1, oLogger.FilterMessageSnippet("span_id").Len())
assert.Equal(t, 1, oLogger.FilterMessageSnippet("trace_state").Len())
}

// should not be error on connecting
func TestHTTPOTLP_JaegerAgent(t *testing.T) {
cont := endure.New(slog.LevelDebug)

cfg := &config.Plugin{
Version: "2023.3.0",
Path: "configs/.rr-http-jaeger-agent.yaml",
}

err := cont.RegisterAll(
cfg,
&logger.Plugin{},
&server.Plugin{},
&gzip.Plugin{},
&httpPlugin.Plugin{},
&otel.Plugin{},
)
assert.NoError(t, err)

err = cont.Init()
if err != nil {
t.Fatal(err)
}

ch, err := cont.Serve()
assert.NoError(t, err)

sig := make(chan os.Signal, 1)
signal.Notify(sig, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)

wg := &sync.WaitGroup{}
wg.Add(1)

stopCh := make(chan struct{}, 1)

go func() {
defer wg.Done()
for {
select {
case e := <-ch:
assert.Fail(t, "error", e.Error.Error())
err = cont.Stop()
if err != nil {
assert.FailNow(t, "error", err.Error())
}
case <-sig:
err = cont.Stop()
if err != nil {
assert.FailNow(t, "error", err.Error())
}
return
case <-stopCh:
// timeout
err = cont.Stop()
if err != nil {
assert.FailNow(t, "error", err.Error())
}
return
}
}
}()

time.Sleep(time.Second * 2)

req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:43244", nil)
assert.NoError(t, err)

r, err := http.DefaultClient.Do(req)
assert.NoError(t, err)
assert.NotNil(t, r)
_, err = io.ReadAll(r.Body)
assert.NoError(t, err)
assert.Equal(t, 200, r.StatusCode)

err = r.Body.Close()
assert.NoError(t, err)

stopCh <- struct{}{}
wg.Wait()

req2, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:16686/api/traces?service=rr_test&lookback=20m", nil)
require.NoError(t, err)
require.NotNil(t, req2)
resp, err := http.DefaultClient.Do(req2)
require.NoError(t, err)
require.NotNil(t, resp)
require.NotNil(t, resp.Body)
require.Equal(t, http.StatusOK, resp.StatusCode)

bd, err := io.ReadAll(resp.Body)
assert.Contains(t, string(bd), "rr_test")
_ = resp.Body.Close()
}
}

0 comments on commit e93a050

Please sign in to comment.