hs-test: replaced gofmt with goimports 36/41636/2
authorAdrian Villin <[email protected]>
Thu, 26 Sep 2024 09:24:34 +0000 (11:24 +0200)
committerFlorin Coras <[email protected]>
Sat, 28 Sep 2024 02:11:59 +0000 (02:11 +0000)
- goimports properly formats imports

Type: test

Change-Id: I78c162dd552fd3ee3d59955d7ea215af30601425
Signed-off-by: Adrian Villin <[email protected]>
18 files changed:
.gitignore
extras/hs-test/Makefile
extras/hs-test/http_test.go
extras/hs-test/infra/container.go
extras/hs-test/infra/cpu.go
extras/hs-test/infra/hst_suite.go
extras/hs-test/infra/suite_cpu_pinning.go
extras/hs-test/infra/suite_envoy_proxy.go
extras/hs-test/infra/suite_vpp_proxy.go
extras/hs-test/infra/vppinstance.go
extras/hs-test/mem_leak_test.go
extras/hs-test/nginx_test.go
extras/hs-test/proxy_test.go
extras/vpp_if_stats/apimock.go
extras/vpp_if_stats/json_structs.go
extras/vpp_if_stats/statsmock.go
extras/vpp_if_stats/vpp_if_stats.go
extras/vpp_if_stats/vpp_if_stats_test.go

index ea3ab8d..89fcb34 100644 (file)
@@ -132,6 +132,7 @@ compile_commands.json
 /extras/hs-test/.build.ok
 /extras/hs-test/.build.cov.ok
 /extras/hs-test/.last_hst_ppid
+/extras/hs-test/.goimports.ok
 /extras/hs-test/summary/
 
 # ./configure
index 2a50158..b72aca1 100644 (file)
@@ -184,10 +184,19 @@ install-deps:
        @apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
        @touch .deps.ok
 
+.goimports.ok:
+       @rm -f .goimports.ok
+       go install golang.org/x/tools/cmd/[email protected]
+       @touch .goimports.ok
+
 .PHONY: checkstyle-go
-checkstyle-go:
-       @output=$$(gofmt -d $${WS_ROOT}); \
-    if [ -z "$$output" ]; then \
+checkstyle-go: .goimports.ok
+       $(eval GOPATH := $(shell go env GOPATH))
+       @output=$$($(GOPATH)/bin/goimports -d $${WS_ROOT}); \
+       status=$$?; \
+       if [ $$status -ne 0 ]; then \
+               exit $$status; \
+    elif [ -z "$$output" ]; then \
         echo "*******************************************************************"; \
         echo "Checkstyle OK."; \
         echo "*******************************************************************"; \
@@ -200,9 +209,10 @@ checkstyle-go:
     fi
 
 .PHONY: fixstyle-go
-fixstyle-go:
+fixstyle-go: .goimports.ok
+       $(eval GOPATH := $(shell go env GOPATH))
        @echo "Modified files:"
-       @gofmt -w -l $(WS_ROOT)
+       @$(GOPATH)/bin/goimports -w -l $(WS_ROOT)
        @go mod tidy
        @echo "*******************************************************************"
        @echo "Fixstyle done."
index bfd2d34..d1d28fb 100644 (file)
@@ -3,8 +3,6 @@ package main
 import (
        "bytes"
        "fmt"
-       "github.com/onsi/gomega/ghttp"
-       "github.com/onsi/gomega/gmeasure"
        "io"
        "math/rand"
        "net"
@@ -15,6 +13,9 @@ import (
        "sync"
        "time"
 
+       "github.com/onsi/gomega/ghttp"
+       "github.com/onsi/gomega/gmeasure"
+
        . "fd.io/hs-test/infra"
        . "github.com/onsi/ginkgo/v2"
 )
index 974d154..8ec9b8c 100644 (file)
@@ -4,7 +4,6 @@ import (
        "bytes"
        "context"
        "fmt"
-       "github.com/docker/go-units"
        "os"
        "os/exec"
        "regexp"
@@ -14,6 +13,8 @@ import (
        "text/template"
        "time"
 
+       "github.com/docker/go-units"
+
        "github.com/cilium/cilium/pkg/sysctl"
        containerTypes "github.com/docker/docker/api/types/container"
        "github.com/docker/docker/api/types/filters"
index a168281..615f8a3 100644 (file)
@@ -4,11 +4,12 @@ import (
        "bufio"
        "errors"
        "fmt"
-       . "github.com/onsi/ginkgo/v2"
        "os"
        "os/exec"
        "strconv"
        "strings"
+
+       . "github.com/onsi/ginkgo/v2"
 )
 
 var CgroupPath = "/sys/fs/cgroup/"
index ed8da3f..234a840 100644 (file)
@@ -4,7 +4,6 @@ import (
        "bufio"
        "flag"
        "fmt"
-       "github.com/edwarnicke/exechelper"
        "io"
        "log"
        "net/http"
@@ -17,6 +16,8 @@ import (
        "strings"
        "time"
 
+       "github.com/edwarnicke/exechelper"
+
        containerTypes "github.com/docker/docker/api/types/container"
        "github.com/docker/docker/client"
        "github.com/onsi/gomega/gmeasure"
index e829efa..355fdf9 100644 (file)
@@ -2,10 +2,11 @@ package hst
 
 import (
        "fmt"
-       . "github.com/onsi/ginkgo/v2"
        "reflect"
        "runtime"
        "strings"
+
+       . "github.com/onsi/ginkgo/v2"
 )
 
 var cpuPinningTests = map[string][]func(s *CpuPinningSuite){}
index 8071521..e34a7d7 100644 (file)
@@ -7,10 +7,11 @@ package hst
 
 import (
        "fmt"
-       . "github.com/onsi/ginkgo/v2"
        "reflect"
        "runtime"
        "strings"
+
+       . "github.com/onsi/ginkgo/v2"
 )
 
 const (
index 21e81e0..868684b 100644 (file)
@@ -7,10 +7,11 @@ package hst
 
 import (
        "fmt"
-       . "github.com/onsi/ginkgo/v2"
        "reflect"
        "runtime"
        "strings"
+
+       . "github.com/onsi/ginkgo/v2"
 )
 
 // These correspond to names used in yaml config
index b3ae995..a1f2ce4 100644 (file)
@@ -4,7 +4,6 @@ import (
        "context"
        "encoding/json"
        "fmt"
-       "go.fd.io/govpp/binapi/ethernet_types"
        "io"
        "net"
        "os"
@@ -15,6 +14,8 @@ import (
        "syscall"
        "time"
 
+       "go.fd.io/govpp/binapi/ethernet_types"
+
        "github.com/edwarnicke/exechelper"
        . "github.com/onsi/ginkgo/v2"
        "github.com/sirupsen/logrus"
index 76966ae..0d8831d 100644 (file)
@@ -1,8 +1,9 @@
 package main
 
 import (
-       . "fd.io/hs-test/infra"
        "fmt"
+
+       . "fd.io/hs-test/infra"
 )
 
 func init() {
index fa6afda..8bf681d 100644 (file)
@@ -1,11 +1,12 @@
 package main
 
 import (
-       . "fd.io/hs-test/infra"
        "fmt"
-       . "github.com/onsi/ginkgo/v2"
        "os"
        "strings"
+
+       . "fd.io/hs-test/infra"
+       . "github.com/onsi/ginkgo/v2"
 )
 
 func init() {
index 7ec97c7..7580644 100644 (file)
@@ -1,8 +1,9 @@
 package main
 
 import (
-       . "fd.io/hs-test/infra"
        "fmt"
+
+       . "fd.io/hs-test/infra"
 )
 
 func init() {
index 7736334..25e76ed 100755 (executable)
@@ -5,10 +5,11 @@
 package main
 
 import (
-       api "git.fd.io/govpp.git/api"
-       gomock "github.com/golang/mock/gomock"
        reflect "reflect"
        time "time"
+
+       api "git.fd.io/govpp.git/api"
+       gomock "github.com/golang/mock/gomock"
 )
 
 // MockChannel is a mock of Channel interface
index a42b6d8..8e73337 100755 (executable)
@@ -4,6 +4,7 @@ import (
        "bytes"
        "encoding/json"
        "fmt"
+
        "git.fd.io/govpp.git/examples/bin_api/vpe"
 )
 
index 72528f5..172176f 100755 (executable)
@@ -5,9 +5,10 @@
 package main
 
 import (
+       reflect "reflect"
+
        adapter "git.fd.io/govpp.git/adapter"
        gomock "github.com/golang/mock/gomock"
-       reflect "reflect"
 )
 
 // MockStatsAPI is a mock of StatsAPI interface
index 90c1700..751bbe5 100644 (file)
@@ -3,6 +3,8 @@ package main
 import (
        "flag"
        "fmt"
+       "log"
+
        "git.fd.io/govpp.git"
        "git.fd.io/govpp.git/adapter"
        "git.fd.io/govpp.git/adapter/vppapiclient"
@@ -10,7 +12,6 @@ import (
        "git.fd.io/govpp.git/core"
        "git.fd.io/govpp.git/examples/bin_api/interfaces"
        "git.fd.io/govpp.git/examples/bin_api/vpe"
-       "log"
 )
 
 //////////////////////////////////////
index 3c22ce8..53c990c 100644 (file)
@@ -1,15 +1,16 @@
 package main
 
 import (
+       "math/rand"
+       "testing"
+       "time"
+
        "git.fd.io/govpp.git/adapter"
        "git.fd.io/govpp.git/api"
        "git.fd.io/govpp.git/examples/bin_api/interfaces"
        "git.fd.io/govpp.git/examples/bin_api/vpe"
        "github.com/golang/mock/gomock"
        "github.com/stretchr/testify/assert"
-       "math/rand"
-       "testing"
-       "time"
 )
 
 var (