Skip to content

Commit

Permalink
Tidy up tests and testdata
Browse files Browse the repository at this point in the history
Use more consistent naming and remove redundant (similar) testdata.
  • Loading branch information
tigrannajaryan committed Feb 11, 2025
1 parent 75a4533 commit 61ba411
Show file tree
Hide file tree
Showing 19 changed files with 49 additions and 108 deletions.
26 changes: 13 additions & 13 deletions benchmarks/benchmarks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/require"

"github.com/splunk/stef/benchmarks/encodings"
"github.com/splunk/stef/benchmarks/encodings/otelarrow"
"github.com/splunk/stef/benchmarks/encodings/otlp"
parquetenc "github.com/splunk/stef/benchmarks/encodings/parquet"
"github.com/splunk/stef/benchmarks/encodings/stef"
Expand All @@ -23,11 +24,8 @@ import (
var testEncodings = []encodings.MetricEncoding{
&otlp.OTLPEncoding{},
&stef.STEFEncoding{Opts: pkg.WriterOptions{Compression: pkg.CompressionNone}},
//&stef.STEFSEncoding{},
//&stef.STEFUEncoding{},
//&otelarrow.OtelArrowEncoding{},
&otelarrow.OtelArrowEncoding{},
&parquetenc.Encoding{},
//&parquetenc.EncodingZ{},
}

var benchmarkDataVariations = []struct {
Expand All @@ -40,7 +38,7 @@ var benchmarkDataVariations = []struct {
//},
{
generator: &generators.File{
FilePath: "testdata/hipstershop.pb.zst",
FilePath: "testdata/hipstershop-otelmetrics.zst",
},
},
}
Expand All @@ -64,7 +62,7 @@ func BenchmarkSerializeNative(b *testing.B) {
for _, dataVariation := range benchmarkDataVariations {
for _, encoding := range testEncodings {
for _, compression := range compressions {
if dataVariation.generator.GetName() == "hostandcollectormetrics.pb.zst" &&
if dataVariation.generator.GetName() == "hostandcollector-otelmetrics.zst" &&
encoding.Name() == "ARROW" {
// Skip due to bug in Arrow encoding
continue
Expand All @@ -88,6 +86,7 @@ func BenchmarkSerializeNative(b *testing.B) {
b,
encoding.LongName(),
float64(b.Elapsed().Nanoseconds())/float64(b.N*batch.DataPointCount()),
"ns/point",
)
},
)
Expand All @@ -105,7 +104,7 @@ func BenchmarkDeserializeNative(b *testing.B) {
for _, dataVariation := range benchmarkDataVariations {
for _, encoding := range testEncodings {
for _, compression := range compressions {
if dataVariation.generator.GetName() == "hostandcollectormetrics.pb.zst" &&
if dataVariation.generator.GetName() == "hostandcollector-otelmetrics.zst" &&
encoding.Name() == "ARROW" {
// Skip due to bug in Arrow encoding
continue
Expand Down Expand Up @@ -140,6 +139,7 @@ func BenchmarkDeserializeNative(b *testing.B) {
b,
encoding.LongName(),
float64(b.Elapsed().Nanoseconds())/float64(b.N*batch.DataPointCount()),
"ns/point",
)
},
)
Expand All @@ -154,7 +154,7 @@ func BenchmarkSerializeFromPdata(b *testing.B) {
for _, dataVariation := range benchmarkDataVariations {
for _, encoding := range testEncodings {
for _, compression := range compressions {
if dataVariation.generator.GetName() == "hostandcollectormetrics.pb.zst" &&
if dataVariation.generator.GetName() == "hostandcollector-otelmetrics.zst" &&
encoding.Name() == "ARROW" {
// Skip due to bug in Arrow encoding
continue
Expand Down Expand Up @@ -191,7 +191,7 @@ func BenchmarkDeserializeToPdata(b *testing.B) {
for _, dataVariation := range benchmarkDataVariations {
for _, encoding := range testEncodings {
for _, compression := range compressions {
if dataVariation.generator.GetName() == "hostandcollectormetrics.pb.zst" &&
if dataVariation.generator.GetName() == "hostandcollector-otelmetrics.zst" &&
encoding.Name() == "ARROW" {
// Skip due to bug in Arrow encoding
continue
Expand Down Expand Up @@ -237,7 +237,7 @@ func BenchmarkDeserializeToPdata(b *testing.B) {
/* Need to rewrite this to use TEF.ReadMany() API when it becomes available.
func BenchmarkReaderReadMany(b *testing.B) {
generator := &generators.File{
FilePath: "testdata/hipstershop.pb.zst",
FilePath: "testdata/hipstershop-otelmetrics.zst",
}
encoding := stef.STEFEncoding{}
Expand Down Expand Up @@ -273,7 +273,7 @@ func BenchmarkReaderReadMany(b *testing.B) {

func BenchmarkSTEFReaderRead(b *testing.B) {
generator := &generators.File{
FilePath: "testdata/hipstershop.pb.zst",
FilePath: "testdata/hipstershop-otelmetrics.zst",
}

encoding := stef.STEFEncoding{}
Expand All @@ -300,7 +300,7 @@ func BenchmarkSTEFReaderRead(b *testing.B) {
break
}
if readRecord == nil {
panic("nil Record")
panic("nil record")
}
if err != nil {
log.Fatal(err)
Expand All @@ -313,7 +313,7 @@ func BenchmarkSTEFReaderRead(b *testing.B) {
)
}

var multipartFiles = []string{"oteldemo-with-histogram.otlp", "astronomyshop.pb"}
var multipartFiles = []string{"astronomy-otelmetrics"}

func BenchmarkSTEFSerializeMultipart(b *testing.B) {
for _, file := range multipartFiles {
Expand Down
13 changes: 4 additions & 9 deletions benchmarks/correctness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,10 @@ func TestConvertTEFFromToOTLP(t *testing.T) {
withSizePrefix bool
}{
{
file: "testdata/oteldemo-with-histogram.otlp.zst",
withSizePrefix: true,
},
{
file: "testdata/hipstershop.pb.zst",
file: "testdata/hipstershop-otelmetrics.zst",
},
{
file: "testdata/astronomyshop.pb.zst",
file: "testdata/astronomy-otelmetrics.zst",
withSizePrefix: true,
},
}
Expand Down Expand Up @@ -96,9 +92,8 @@ func toBytes(t *testing.T, data pmetric.Metrics) []byte {

func TestTEFMultiPart(t *testing.T) {
var testInputOtlpFiles = []string{
"testdata/oteldemo-with-histogram.otlp.zst",
"testdata/astronomyshop.pb.zst",
"testdata/hostandcollectormetrics.pb.zst",
"testdata/astronomy-otelmetrics.zst",
"testdata/hostandcollector-otelmetrics.zst",
}

//stefEncoding := stef.STEFEncoding{}
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/otlp2sortedtree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
/*
func TestTreeConverter(t *testing.T) {
source := generators.File{
FilePath: "testdata/hipstershop.pb.zst",
FilePath: "testdata/hipstershop-otelmetrics.zst",
}
otlpData := source.Generate()
Expand Down Expand Up @@ -106,7 +106,7 @@ func mapContains[K any](searchFor, inTree *b.Tree[K, bool]) bool {
}

func TestConvertFromOTLP(t *testing.T) {
otlpData, err := testutils.ReadOTLPFile("testdata/oteldemo-with-histogram.otlp.zst", true)
otlpData, err := testutils.ReadOTLPFile("testdata/hipstershop-otelmetrics.zst", false)
require.NoError(t, err)

converter := otlpconvert.NewOtlpToSortedTree()
Expand Down
13 changes: 6 additions & 7 deletions benchmarks/readwrite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ import (

func TestCopy(t *testing.T) {
files := []string{
"oteldemo-with-histogram.stefz",
"hipstershop.stefz",
"hostandcollectormetrics.stefz",
"astronomyshop.stefz",
"hipstershop-otelmetrics.stefz",
"hostandcollector-otelmetrics.stefz",
"astronomy-otelmetrics.stefz",
}

fmt.Printf(
Expand Down Expand Up @@ -78,7 +77,7 @@ func TestCopy(t *testing.T) {
}

func BenchmarkReadSTEF(b *testing.B) {
tefBytes, err := os.ReadFile("testdata/hipstershop.stefz")
tefBytes, err := os.ReadFile("testdata/hipstershop-otelmetrics.stefz")
require.NoError(b, err)

tefSrc, err := oteltef.NewMetricsReader(bytes.NewBuffer(tefBytes))
Expand Down Expand Up @@ -136,7 +135,7 @@ func BenchmarkReadSTEF(b *testing.B) {
}

func BenchmarkReadSTEFZ(b *testing.B) {
tefBytes, err := os.ReadFile("testdata/hipstershop.stefz")
tefBytes, err := os.ReadFile("testdata/hipstershop-otelmetrics.stefz")
require.NoError(b, err)

recCount := 0
Expand Down Expand Up @@ -164,7 +163,7 @@ func BenchmarkReadSTEFZ(b *testing.B) {
}

func BenchmarkReadSTEFZWriteSTEF(b *testing.B) {
tefBytes, err := os.ReadFile("testdata/hipstershop.stefz")
tefBytes, err := os.ReadFile("testdata/hipstershop-otelmetrics.stefz")
require.NoError(b, err)

recCount := 0
Expand Down
Loading

0 comments on commit 61ba411

Please sign in to comment.