Skip to content

Commit

Permalink
Remove go-iperf tmp directories
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelrahmanElawady committed Oct 24, 2023
1 parent caf5e81 commit e874869
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
3 changes: 1 addition & 2 deletions cmds/modules/noded/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,7 @@ func action(cli *cli.Context) error {
return errors.Wrap(err, "failed to create a new perfMon")
}

iperfTest := iperf.NewIperfTest()
perfMon.AddTask(&iperfTest)
perfMon.AddTask(iperf.NewTask())

cpuBenchmarkTask := cpubench.NewCPUBenchmarkTask()
perfMon.AddTask(&cpuBenchmarkTask)
Expand Down
15 changes: 12 additions & 3 deletions pkg/perf/iperf/iperf_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import (
"encoding/json"
"fmt"
"net"
"os"
"os/exec"
"path/filepath"

"github.com/pkg/errors"
"github.com/rs/zerolog/log"
"github.com/threefoldtech/zos/pkg/environment"
"github.com/threefoldtech/zos/pkg/network/iperf"
"github.com/threefoldtech/zos/pkg/perf"
)

// IperfTest for iperf tcp/udp tests
Expand All @@ -30,9 +33,15 @@ type IperfResult struct {
CpuReport CPUUtilizationPercent `json:"cpu_report"`
}

// NewIperfTest creates a new iperf test
func NewIperfTest() IperfTest {
return IperfTest{taskID: "iperf", schedule: "0 0 */6 * * *"}
// NewTask creates a new iperf test
func NewTask() perf.Task {
// because go-iperf left tmp directories with perf binary in it each time
// the task had run
matches, _ := filepath.Glob("/tmp/goiperf*")
for _, match := range matches {
os.RemoveAll(match)
}
return &IperfTest{taskID: "iperf", schedule: "0 0 */6 * * *"}
}

// ID returns the ID of the tcp task
Expand Down

0 comments on commit e874869

Please sign in to comment.