Skip to content

Commit

Permalink
[chore] Migrate golden files from JSON to YAML (open-telemetry#20438)
Browse files Browse the repository at this point in the history
This change updates coreinternal/golden helpers to use YAML format for writing/reading pdata structs and migrate all existing files from json to yaml. This improves human readability of the golden data files
  • Loading branch information
dmitryax committed Mar 28, 2023
1 parent 7da4a5b commit f2ece40
Show file tree
Hide file tree
Showing 811 changed files with 72,358 additions and 129,900 deletions.
18 changes: 9 additions & 9 deletions connector/countconnector/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,15 @@ func TestTracesToMetrics(t *testing.T) {
assert.NoError(t, conn.Shutdown(context.Background()))
}()

testSpans, err := golden.ReadTraces(filepath.Join("testdata", "traces", "input.json"))
testSpans, err := golden.ReadTraces(filepath.Join("testdata", "traces", "input.yaml"))
assert.NoError(t, err)
assert.NoError(t, conn.ConsumeTraces(context.Background(), testSpans))

allMetrics := sink.AllMetrics()
assert.Equal(t, 1, len(allMetrics))

// golden.WriteMetrics(t, filepath.Join("testdata", "traces", tc.name+".json"), allMetrics[0])
expected, err := golden.ReadMetrics(filepath.Join("testdata", "traces", tc.name+".json"))
// golden.WriteMetrics(t, filepath.Join("testdata", "traces", tc.name+".yaml"), allMetrics[0])
expected, err := golden.ReadMetrics(filepath.Join("testdata", "traces", tc.name+".yaml"))
assert.NoError(t, err)
assert.NoError(t, pmetrictest.CompareMetrics(expected, allMetrics[0],
pmetrictest.IgnoreTimestamp(),
Expand Down Expand Up @@ -479,15 +479,15 @@ func TestMetricsToMetrics(t *testing.T) {
assert.NoError(t, conn.Shutdown(context.Background()))
}()

testMetrics, err := golden.ReadMetrics(filepath.Join("testdata", "metrics", "input.json"))
testMetrics, err := golden.ReadMetrics(filepath.Join("testdata", "metrics", "input.yaml"))
assert.NoError(t, err)
assert.NoError(t, conn.ConsumeMetrics(context.Background(), testMetrics))

allMetrics := sink.AllMetrics()
assert.Equal(t, 1, len(allMetrics))

// golden.WriteMetrics(t, filepath.Join("testdata", "metrics", tc.name+".json"), allMetrics[0])
expected, err := golden.ReadMetrics(filepath.Join("testdata", "metrics", tc.name+".json"))
// golden.WriteMetrics(t, filepath.Join("testdata", "metrics", tc.name+".yaml"), allMetrics[0])
expected, err := golden.ReadMetrics(filepath.Join("testdata", "metrics", tc.name+".yaml"))
assert.NoError(t, err)
assert.NoError(t, pmetrictest.CompareMetrics(expected, allMetrics[0],
pmetrictest.IgnoreTimestamp(),
Expand Down Expand Up @@ -651,15 +651,15 @@ func TestLogsToMetrics(t *testing.T) {
assert.NoError(t, conn.Shutdown(context.Background()))
}()

testLogs, err := golden.ReadLogs(filepath.Join("testdata", "logs", "input.json"))
testLogs, err := golden.ReadLogs(filepath.Join("testdata", "logs", "input.yaml"))
assert.NoError(t, err)
assert.NoError(t, conn.ConsumeLogs(context.Background(), testLogs))

allMetrics := sink.AllMetrics()
assert.Equal(t, 1, len(allMetrics))

// golden.WriteMetrics(t, filepath.Join("testdata", "logs", tc.name+".json"), allMetrics[0])
expected, err := golden.ReadMetrics(filepath.Join("testdata", "logs", tc.name+".json"))
// golden.WriteMetrics(t, filepath.Join("testdata", "logs", tc.name+".yaml"), allMetrics[0])
expected, err := golden.ReadMetrics(filepath.Join("testdata", "logs", tc.name+".yaml"))
assert.NoError(t, err)
assert.NoError(t, pmetrictest.CompareMetrics(expected, allMetrics[0],
pmetrictest.IgnoreTimestamp(),
Expand Down
126 changes: 0 additions & 126 deletions connector/countconnector/testdata/logs/condition_and_attribute.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
resourceMetrics:
- resource:
attributes:
- key: resource.required
value:
stringValue: foo
- key: resource.optional
value:
stringValue: bar
scopeMetrics:
- metrics:
- description: Log count by attribute if ...
name: log.count.if.by_attr
sum:
aggregationTemporality: 1
dataPoints:
- asInt: "2"
attributes:
- key: log.required
value:
stringValue: foo
timeUnixNano: "1678390948399018000"
- asInt: "1"
attributes:
- key: log.required
value:
stringValue: notfoo
timeUnixNano: "1678390948399018000"
isMonotonic: true
scope:
name: otelcol/countconnector
- resource:
attributes:
- key: resource.required
value:
stringValue: foo
- key: resource.optional
value:
stringValue: notbar
scopeMetrics:
- metrics:
- description: Log count by attribute if ...
name: log.count.if.by_attr
sum:
aggregationTemporality: 1
dataPoints:
- asInt: "2"
attributes:
- key: log.required
value:
stringValue: foo
timeUnixNano: "1678390948399021000"
- asInt: "1"
attributes:
- key: log.required
value:
stringValue: notfoo
timeUnixNano: "1678390948399021000"
isMonotonic: true
scope:
name: otelcol/countconnector
Loading

0 comments on commit f2ece40

Please sign in to comment.