|
9 | 9 |
|
10 | 10 | pprofile "github.com/google/pprof/profile" |
11 | 11 | "github.com/stretchr/testify/require" |
| 12 | + |
12 | 13 | "github.com/threadedstream/ppmerge/profile" |
13 | 14 | ) |
14 | 15 |
|
@@ -193,10 +194,28 @@ func TestMergeUnpack(t *testing.T) { |
193 | 194 | require.NoError(t, profileMerger.WriteCompressed(compressedBB)) |
194 | 195 | require.Greater(t, compressedBB.Len(), 0) |
195 | 196 |
|
| 197 | + unpacker := NewProfileUnPacker(nil) |
| 198 | + p, err := unpacker.UnpackCompressed(compressedBB.Bytes(), 0) |
| 199 | + require.NoError(t, err) |
| 200 | + require.NotNil(t, p) |
| 201 | + }) |
| 202 | + |
| 203 | + t.Run("merge unpack raw", func(t *testing.T) { |
| 204 | + profiles := getProfilesVtProto(t, false, "hprof1", "hprof2", "hprof3", "hprof4") |
| 205 | + |
| 206 | + profileMerger := NewProfileMerger() |
| 207 | + mergedProfile := profileMerger.Merge(profiles...) |
| 208 | + require.NotNil(t, mergedProfile) |
| 209 | + |
| 210 | + compressedBB := bytes.NewBuffer(nil) |
| 211 | + require.NoError(t, profileMerger.WriteUncompressed(compressedBB)) |
| 212 | + require.Greater(t, compressedBB.Len(), 0) |
| 213 | + |
196 | 214 | unpacker := NewProfileUnPacker(nil) |
197 | 215 | p, err := unpacker.UnpackRaw(compressedBB.Bytes(), 0) |
198 | 216 | require.NoError(t, err) |
199 | 217 | require.NotNil(t, p) |
| 218 | + |
200 | 219 | }) |
201 | 220 |
|
202 | 221 | t.Run("merge unpack debug goroutine profiles", func(t *testing.T) { |
@@ -242,21 +261,21 @@ func TestMergeUnpack(t *testing.T) { |
242 | 261 | require.NoError(t, profileMerger.WriteCompressed(bb)) |
243 | 262 |
|
244 | 263 | unpackerOne := NewGoroutineProfileUnPacker(nil) |
245 | | - p, err := unpackerOne.UnpackRaw(bb.Bytes(), 0) |
| 264 | + p, err := unpackerOne.UnpackCompressed(bb.Bytes(), 0) |
246 | 265 | require.NoError(t, err) |
247 | 266 | require.NotNil(t, p) |
248 | 267 | require.Equal(t, profiles[0].GetTotal(), p.GetTotal()) |
249 | 268 | require.Equal(t, profiles[0].GetStacktraces(), p.GetStacktraces()) |
250 | 269 |
|
251 | 270 | unpackerTwo := NewGoroutineProfileUnPacker(nil) |
252 | | - p, err = unpackerTwo.UnpackRaw(bb.Bytes(), 1) |
| 271 | + p, err = unpackerTwo.UnpackCompressed(bb.Bytes(), 1) |
253 | 272 | require.NoError(t, err) |
254 | 273 | require.NotNil(t, p) |
255 | 274 | require.Equal(t, profiles[1].GetTotal(), p.GetTotal()) |
256 | 275 | require.Equal(t, profiles[1].GetStacktraces(), p.GetStacktraces()) |
257 | 276 |
|
258 | 277 | unpackerThree := NewGoroutineProfileUnPacker(nil) |
259 | | - p, err = unpackerThree.UnpackRaw(bb.Bytes(), 2) |
| 278 | + p, err = unpackerThree.UnpackCompressed(bb.Bytes(), 2) |
260 | 279 | require.NoError(t, err) |
261 | 280 | require.NotNil(t, p) |
262 | 281 | require.Equal(t, profiles[2].GetTotal(), p.GetTotal()) |
|
0 commit comments