Skip to content

Commit

Permalink
Fix php_test.go
Browse files Browse the repository at this point in the history
Init cleans up all gatherd calls, we don't want to call it randomly
because it breaks asserts in Run
  • Loading branch information
razmser committed Mar 28, 2024
1 parent bf14f5a commit 27bd26c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions internal/receiver/php_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ type phpMachine struct {
code []string
}

func (p *phpMachine) Init(_ *rapid.T) {
func (p *phpMachine) init() {
p.numCounts = 0
p.sumCountsOther = floatsMap{}
p.sumTimestamp = intsMap{}
Expand Down Expand Up @@ -300,10 +300,13 @@ func (p *phpMachine) Run(t *rapid.T) {
total := p.numCounts + p.valueMetrics.size() + p.uniqueMetrics.size() + p.stopMetrics.size()
if total == 0 {
t.Skip("no metrics to send/receive")
return
}

recv, err := receiver.ListenUDP(phpStatsHouseAddr, receiver.DefaultConnBufSize, false, nil, nil)
t.Logf("listen err %v for %v", err, phpStatsHouseAddr)
if err != nil {
t.Logf("listen err %v for %v", err, phpStatsHouseAddr)
}
require.NoError(t, err)
defer func() { _ = recv.Close() }()

Expand Down Expand Up @@ -369,7 +372,7 @@ func (p *phpMachine) Run(t *rapid.T) {
require.Equal(t, p.stopMetrics, stopMetrics)
require.Equal(t, p.numCounts, numCounts)

p.Init(t)
p.init()
}

func (p *phpMachine) Check(*rapid.T) {}
Expand Down Expand Up @@ -402,7 +405,7 @@ func TestPHPRoundtrip(t *testing.T) {
}
rapid.Check(t, func(t *rapid.T) {
m := phpMachine{}
m.Init(t)
m.init()
t.Repeat(rapid.StateMachineActions(&m))
})
}

0 comments on commit 27bd26c

Please sign in to comment.