| 88 | } |
| 89 | |
| 90 | func TestBlockMetaJSONProtoRoundTrip(t *testing.T) { |
| 91 | timeParse := func(s string) time.Time { |
| 92 | date, err := time.Parse(time.RFC3339Nano, s) |
| 93 | require.NoError(t, err) |
| 94 | return date |
| 95 | } |
| 96 | |
| 97 | meta := BlockMeta{ |
| 98 | Version: "vParquet3", |
| 99 | BlockID: MustParse("00000000-0000-0000-0000-000000000000"), |
| 100 | TenantID: "single-tenant", |
| 101 | StartTime: timeParse("2021-01-01T00:00:00.0000000Z"), |
| 102 | EndTime: timeParse("2021-01-02T00:00:00.0000000Z"), |
| 103 | TotalObjects: 10, |
| 104 | Size_: 12345, |
| 105 | CompactionLevel: 1, |
| 106 | IndexPageSize: 250000, |
| 107 | TotalRecords: 124356, |
| 108 | BloomShardCount: 244, |
| 109 | FooterSize: 15775, |
| 110 | DedicatedColumns: DedicatedColumns{ |
| 111 | {Scope: "resource", Name: "namespace", Type: "string"}, |
| 112 | {Scope: "resource", Name: "net.host.port", Type: "int"}, |
| 113 | {Scope: "span", Name: "http.method", Type: "string"}, |
| 114 | {Scope: "span", Name: "namespace", Type: "string"}, |
| 115 | {Scope: "span", Name: "http.response.body.size", Type: "int"}, |
| 116 | {Scope: "span", Name: "http.request.header.accept", Type: "string", Options: DedicatedColumnOptions{DedicatedColumnOptionArray}}, |
| 117 | }, |
| 118 | } |
| 119 | expectedJSON := `{ |
| 120 | "format": "vParquet3", |
| 121 | "blockID": "00000000-0000-0000-0000-000000000000", |
| 122 | "tenantID": "single-tenant", |
| 123 | "startTime": "2021-01-01T00:00:00Z", |
| 124 | "endTime": "2021-01-02T00:00:00Z", |
| 125 | "totalObjects": 10, |
| 126 | "size": 12345, |
| 127 | "compactionLevel": 1, |
| 128 | "indexPageSize": 250000, |
| 129 | "totalRecords": 124356, |
| 130 | "bloomShards": 244, |
| 131 | "footerSize": 15775, |
| 132 | "dedicatedColumns": [ |
| 133 | {"s": "resource", "n": "namespace"}, |
| 134 | {"s": "resource", "n": "net.host.port", "t": "int"}, |
| 135 | {"n": "http.method"}, |
| 136 | {"n": "namespace"}, |
| 137 | {"n": "http.response.body.size", "t": "int"}, |
| 138 | {"n": "http.request.header.accept", "o": ["array"]} |
| 139 | ] |
| 140 | }` |
| 141 | |
| 142 | // JSON |
| 143 | metaJSON, err := json.Marshal(meta) |
| 144 | require.NoError(t, err) |
| 145 | assert.JSONEq(t, expectedJSON, string(metaJSON)) |
| 146 | |
| 147 | var metaRoundtrip BlockMeta |