mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* First pass test harness Signed-off-by: Joe Elliott <[email protected]> * limits - passed Signed-off-by: Joe Elliott <[email protected]> * metrics generator - passed Signed-off-by: Joe Elliott <[email protected]> * harness cleanup/fix target info test Signed-off-by: Joe Elliott <[email protected]> * deployments - passed Signed-off-by: Joe Elliott <[email protected]> * receivers - passed Signed-off-by: Joe Elliott <[email protected]> * harness cleanup Signed-off-by: Joe Elliott <[email protected]> * storage - passed Signed-off-by: Joe Elliott <[email protected]> * api - passing Signed-off-by: Joe Elliott <[email protected]> * cleanup and CI Signed-off-by: Joe Elliott <[email protected]> * Additional tests Signed-off-by: Joe Elliott <[email protected]> * it's me and you linter. how many times are you going to do this to me? Signed-off-by: Joe Elliott <[email protected]> * lint and tests Signed-off-by: Joe Elliott <[email protected]> * restored live store partition tests Signed-off-by: Joe Elliott <[email protected]> * massive lint Signed-off-by: Joe Elliott <[email protected]> * cleanup Signed-off-by: Joe Elliott <[email protected]> * lint >.< Signed-off-by: Joe Elliott <[email protected]> * wups Signed-off-by: Joe Elliott <[email protected]> * cleanup and stabilizing Signed-off-by: Joe Elliott <[email protected]> * cleanup Signed-off-by: Joe Elliott <[email protected]> * omg Signed-off-by: Joe Elliott <[email protected]> * added config file. removed empty file. deleted some debug code Signed-off-by: Joe Elliott <[email protected]> * even more fixes Signed-off-by: Joe Elliott <[email protected]> * maybe this works? maybe it was all local networking issues Signed-off-by: Joe Elliott <[email protected]> * review Signed-off-by: Joe Elliott <[email protected]> * backed off huge write timeout. added missing config file Signed-off-by: Joe Elliott <[email protected]> * restore disable parallelism setting. restore beefy write timeout Signed-off-by: Joe Elliott <[email protected]> * apparently another test relied on the http receiver Signed-off-by: Joe Elliott <[email protected]> * livestore avail zone! Signed-off-by: Joe Elliott <[email protected]> * add support for v1 traces and tags endpoints Signed-off-by: Joe Elliott <[email protected]> * review Signed-off-by: Joe Elliott <[email protected]> * changed the location of the changelog entry to avoid conflicts Signed-off-by: Joe Elliott <[email protected]> --------- Signed-off-by: Joe Elliott <[email protected]>
120 lines
2.5 KiB
Go
120 lines
2.5 KiB
Go
package util
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
thrift "github.com/jaegertracing/jaeger-idl/thrift-gen/jaeger"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
const testSeed = 1632146180
|
|
|
|
func TestTraceInfo(t *testing.T) {
|
|
writeBackoff := 1 * time.Second
|
|
longWriteBackoff := 5 * time.Second
|
|
|
|
seed := time.Unix(0, testSeed)
|
|
info := NewTraceInfo(seed, "")
|
|
assert.False(t, info.Ready(seed, writeBackoff, longWriteBackoff))
|
|
assert.False(t, info.Ready(seed.Add(longWriteBackoff), writeBackoff, longWriteBackoff))
|
|
assert.False(t, info.Ready(seed.Add(longWriteBackoff).Add(1*time.Second), writeBackoff, longWriteBackoff))
|
|
assert.True(t, info.Ready(seed.Add(2*longWriteBackoff), writeBackoff, longWriteBackoff))
|
|
}
|
|
|
|
func TestGenerateRandomLogs(t *testing.T) {
|
|
now := time.Now()
|
|
info := NewTraceInfo(now, "")
|
|
result := info.generateRandomLogs()
|
|
|
|
for _, l := range result {
|
|
require.NotNil(t, l.Timestamp)
|
|
for _, f := range l.Fields {
|
|
assertStandardVultureKey(t, f)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestGenerateRandomTags(t *testing.T) {
|
|
now := time.Now()
|
|
info := NewTraceInfo(now, "")
|
|
|
|
result := info.generateRandomTags()
|
|
|
|
for _, k := range result {
|
|
assertStandardVultureKey(t, k)
|
|
}
|
|
}
|
|
|
|
func TestGenerateRandomString(t *testing.T) {
|
|
seed := time.Unix(0, testSeed)
|
|
info := NewTraceInfo(seed, "")
|
|
|
|
strings := []string{
|
|
"XqaIBSJMJVGkEg",
|
|
}
|
|
|
|
for _, s := range strings {
|
|
result := info.generateRandomString()
|
|
require.Equal(t, s, result)
|
|
}
|
|
}
|
|
|
|
func TestGenerateRandomInt(t *testing.T) {
|
|
seed := time.Unix(0, testSeed)
|
|
info := NewTraceInfo(seed, "")
|
|
|
|
cases := []struct {
|
|
min int64
|
|
max int64
|
|
result int64
|
|
}{
|
|
{
|
|
min: 1,
|
|
max: 5,
|
|
result: 3,
|
|
},
|
|
{
|
|
min: 10,
|
|
max: 50,
|
|
result: 17,
|
|
},
|
|
{
|
|
min: 1,
|
|
max: 3,
|
|
result: 2,
|
|
},
|
|
}
|
|
|
|
for _, tc := range cases {
|
|
result := info.generateRandomInt(tc.min, tc.max)
|
|
require.Equal(t, tc.result, result)
|
|
}
|
|
}
|
|
|
|
func TestConstructTraceFromEpoch(t *testing.T) {
|
|
seed := time.Unix(0, testSeed)
|
|
info := NewTraceInfo(seed, "")
|
|
|
|
result, err := info.ConstructTraceFromEpoch()
|
|
require.NoError(t, err)
|
|
assert.Equal(t, 7, len(result.ResourceSpans))
|
|
|
|
result2, err := info.ConstructTraceFromEpoch()
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, result, result2)
|
|
}
|
|
|
|
func assertStandardVultureKey(t *testing.T, tag *thrift.Tag) {
|
|
if !strings.HasPrefix(tag.Key, "vulture-") {
|
|
t.Errorf("prefix vulture- is wanted, have: %s", tag.Key)
|
|
}
|
|
|
|
require.NotNil(t, tag.VStr)
|
|
require.GreaterOrEqual(t, len(tag.VType.String()), 5)
|
|
require.LessOrEqual(t, len(tag.VType.String()), 20)
|
|
}
|