Skip to content

Commit

Permalink
Merge pull request #12401 from edsantiago/lint_tests
Browse files Browse the repository at this point in the history
e2e tests: enable golint
  • Loading branch information
openshift-merge-robot authored Nov 29, 2021
2 parents 3d19f1a + b63d696 commit c234c20
Show file tree
Hide file tree
Showing 48 changed files with 179 additions and 186 deletions.
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ run:
skip-dirs:
- contrib
- dependencies
- test
skip-files:
- swagger.go
modules-download-mode: readonly
Expand Down
2 changes: 1 addition & 1 deletion pkg/bindings/test/attach_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test_bindings
package bindings_test

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bindings/test/auth_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test_bindings
package bindings_test

import (
"io/ioutil"
Expand Down
4 changes: 2 additions & 2 deletions pkg/bindings/test/common_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test_bindings
package bindings_test

import (
"context"
Expand Down Expand Up @@ -51,7 +51,7 @@ var (
shortName: "busybox",
tarballName: "busybox.tar",
}
CACHE_IMAGES = []testImage{alpine, busybox}
CACHE_IMAGES = []testImage{alpine, busybox} //nolint:golint,stylecheck
)

type bindingTest struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/bindings/test/connection_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test_bindings
package bindings_test

import (
"context"
Expand Down
3 changes: 2 additions & 1 deletion pkg/bindings/test/containers_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test_bindings
package bindings_test

import (
"net/http"
Expand Down Expand Up @@ -103,6 +103,7 @@ var _ = Describe("Podman containers ", func() {
Expect(err).To(BeNil())
// Pause by name
err = containers.Pause(bt.conn, name, nil)
Expect(err).To(BeNil(), "error from containers.Pause()")
//paused := "paused"
//_, err = containers.Wait(bt.conn, cid, &paused)
//Expect(err).To(BeNil())
Expand Down
2 changes: 1 addition & 1 deletion pkg/bindings/test/create_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test_bindings
package bindings_test

import (
"time"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bindings/test/exec_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test_bindings
package bindings_test

import (
"time"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bindings/test/generator_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test_bindings
package bindings_test

import (
"github.com/containers/podman/v3/pkg/bindings/containers"
Expand Down
13 changes: 12 additions & 1 deletion pkg/bindings/test/images_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test_bindings
package bindings_test

import (
"net/http"
Expand Down Expand Up @@ -89,6 +89,10 @@ var _ = Describe("Podman images", func() {
response, errs := images.Remove(bt.conn, []string{"foobar5000"}, nil)
Expect(len(errs)).To(BeNumerically(">", 0))
code, _ := bindings.CheckResponseCode(errs[0])
// FIXME FIXME FIXME: #12441: THIS IS BROKEN
// FIXME FIXME FIXME: we get msg: "foobar5000: image not known"
// FIXME FIXME FIXME: ...with no ResponseCode
Expect(code).To(BeNumerically("==", -1))

// Remove an image by name, validate image is removed and error is nil
inspectData, err := images.GetImage(bt.conn, busybox.shortName, nil)
Expand All @@ -99,6 +103,7 @@ var _ = Describe("Podman images", func() {
Expect(inspectData.ID).To(Equal(response.Deleted[0]))
inspectData, err = images.GetImage(bt.conn, busybox.shortName, nil)
code, _ = bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound))

// Start a container with alpine image
var top string = "top"
Expand All @@ -113,6 +118,9 @@ var _ = Describe("Podman images", func() {
// deleting hence image cannot be deleted until the container is deleted.
response, errs = images.Remove(bt.conn, []string{alpine.shortName}, nil)
code, _ = bindings.CheckResponseCode(errs[0])
// FIXME FIXME FIXME: #12441: another invalid error
// FIXME FIXME FIXME: this time msg="Image used by SHA: ..."
Expect(code).To(BeNumerically("==", -1))

// Removing the image "alpine" where force = true
options := new(images.RemoveOptions).WithForce(true)
Expand All @@ -122,10 +130,12 @@ var _ = Describe("Podman images", func() {
// is gone as well.
_, err = containers.Inspect(bt.conn, "top", nil)
code, _ = bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound))

// Now make sure both images are gone.
inspectData, err = images.GetImage(bt.conn, busybox.shortName, nil)
code, _ = bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusNotFound))

inspectData, err = images.GetImage(bt.conn, alpine.shortName, nil)
code, _ = bindings.CheckResponseCode(err)
Expand Down Expand Up @@ -339,6 +349,7 @@ var _ = Describe("Podman images", func() {

// Search with a fqdn
reports, err = images.Search(bt.conn, "quay.io/libpod/alpine_nginx", nil)
Expect(err).To(BeNil(), "Error in images.Search()")
Expect(len(reports)).To(BeNumerically(">=", 1))
})

Expand Down
2 changes: 1 addition & 1 deletion pkg/bindings/test/info_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test_bindings
package bindings_test

import (
"runtime"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bindings/test/manifests_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test_bindings
package bindings_test

import (
"net/http"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bindings/test/networks_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test_bindings
package bindings_test

import (
"context"
Expand Down
6 changes: 5 additions & 1 deletion pkg/bindings/test/pods_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test_bindings
package bindings_test

import (
"fmt"
Expand Down Expand Up @@ -79,6 +79,7 @@ var _ = Describe("Podman pods", func() {
var newpod2 string = "newpod2"
bt.Podcreate(&newpod2)
podSummary, err = pods.List(bt.conn, nil)
Expect(err).To(BeNil(), "Error from pods.List")
Expect(len(podSummary)).To(Equal(2))
var names []string
for _, i := range podSummary {
Expand Down Expand Up @@ -106,6 +107,7 @@ var _ = Describe("Podman pods", func() {
options := new(pods.ListOptions).WithFilters(filters)
filteredPods, err := pods.List(bt.conn, options)
Expect(err).ToNot(BeNil())
Expect(len(filteredPods)).To(Equal(0), "len(filteredPods)")
code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", http.StatusInternalServerError))

Expand Down Expand Up @@ -301,6 +303,7 @@ var _ = Describe("Podman pods", func() {
// No pods pruned since no pod in exited state
pruneResponse, err := pods.Prune(bt.conn, nil)
Expect(err).To(BeNil())
Expect(len(pruneResponse)).To(Equal(0), "len(pruneResponse)")
podSummary, err := pods.List(bt.conn, nil)
Expect(err).To(BeNil())
Expect(len(podSummary)).To(Equal(2))
Expand All @@ -317,6 +320,7 @@ var _ = Describe("Podman pods", func() {
Expect(response.State).To(Equal(define.PodStateExited))
pruneResponse, err = pods.Prune(bt.conn, nil)
Expect(err).To(BeNil())
Expect(len(pruneResponse)).To(Equal(1), "len(pruneResponse)")
// Validate status and record pod id of pod to be pruned
Expect(response.State).To(Equal(define.PodStateExited))
podID := response.ID
Expand Down
2 changes: 1 addition & 1 deletion pkg/bindings/test/resource_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test_bindings
package bindings_test

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bindings/test/secrets_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test_bindings
package bindings_test

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bindings/test/system_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test_bindings
package bindings_test

import (
"sync"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bindings/test/test_suite_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test_bindings_test
package bindings_test

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion pkg/bindings/test/volumes_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test_bindings
package bindings_test

import (
"context"
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/checkpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,9 @@ var _ = Describe("Podman checkpoint", func() {
"podman checkpoint and restore container out of and into pod (%s)",
share,
)

share := share // copy into local scope, for use inside function

It(testName, func() {
if !criu.CheckForCriu(criu.PodCriuVersion) {
Skip("CRIU is missing or too old.")
Expand Down
46 changes: 19 additions & 27 deletions test/e2e/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/containers/storage/pkg/reexec"
"github.com/containers/storage/pkg/stringid"
jsoniter "github.com/json-iterator/go"
"github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
Expand All @@ -33,16 +32,14 @@ import (
)

var (
PODMAN_BINARY string
CONMON_BINARY string
CNI_CONFIG_DIR string
RUNC_BINARY string
INTEGRATION_ROOT string
CGROUP_MANAGER = "systemd"
ARTIFACT_DIR = "/tmp/.artifacts"
RESTORE_IMAGES = []string{ALPINE, BB, nginx}
//lint:ignore ST1003
PODMAN_BINARY string //nolint:golint,stylecheck
INTEGRATION_ROOT string //nolint:golint,stylecheck
CGROUP_MANAGER = "systemd" //nolint:golint,stylecheck
ARTIFACT_DIR = "/tmp/.artifacts" //nolint:golint,stylecheck
RESTORE_IMAGES = []string{ALPINE, BB, nginx} //nolint:golint,stylecheck
defaultWaitTimeout = 90
CGROUPSV2, _ = cgroups.IsCgroup2UnifiedMode()
CGROUPSV2, _ = cgroups.IsCgroup2UnifiedMode() //nolint:golint,stylecheck
)

// PodmanTestIntegration struct for command line options
Expand Down Expand Up @@ -74,8 +71,6 @@ type testResult struct {
length float64
}

var noCache = "Cannot run nocache with remote"

type testResultsSorted []testResult

func (a testResultsSorted) Len() int { return len(a) }
Expand Down Expand Up @@ -475,7 +470,7 @@ func (p *PodmanTestIntegration) PodmanPID(args []string) (*PodmanSessionIntegrat
if err != nil {
Fail(fmt.Sprintf("unable to run podman command: %s", strings.Join(podmanOptions, " ")))
}
podmanSession := &PodmanSession{session}
podmanSession := &PodmanSession{Session: session}
return &PodmanSessionIntegration{podmanSession}, command.Process.Pid
}

Expand Down Expand Up @@ -597,9 +592,9 @@ func (p *PodmanTestIntegration) RunHealthCheck(cid string) error {
return errors.Errorf("unable to detect %s as running", cid)
}

func (p *PodmanTestIntegration) CreateSeccompJson(in []byte) (string, error) {
func (p *PodmanTestIntegration) CreateSeccompJSON(in []byte) (string, error) {
jsonFile := filepath.Join(p.TempDir, "seccomp.json")
err := WriteJsonFile(in, jsonFile)
err := WriteJSONFile(in, jsonFile)
if err != nil {
return "", err
}
Expand All @@ -622,14 +617,14 @@ func SkipIfRootlessCgroupsV1(reason string) {
func SkipIfRootless(reason string) {
checkReason(reason)
if os.Geteuid() != 0 {
ginkgo.Skip("[rootless]: " + reason)
Skip("[rootless]: " + reason)
}
}

func SkipIfNotRootless(reason string) {
checkReason(reason)
if os.Geteuid() == 0 {
ginkgo.Skip("[notRootless]: " + reason)
Skip("[notRootless]: " + reason)
}
}

Expand All @@ -640,7 +635,7 @@ func SkipIfSystemdNotRunning(reason string) {
err := cmd.Run()
if err != nil {
if _, ok := err.(*exec.Error); ok {
ginkgo.Skip("[notSystemd]: not running " + reason)
Skip("[notSystemd]: not running " + reason)
}
Expect(err).ToNot(HaveOccurred())
}
Expand All @@ -649,14 +644,14 @@ func SkipIfSystemdNotRunning(reason string) {
func SkipIfNotSystemd(manager, reason string) {
checkReason(reason)
if manager != "systemd" {
ginkgo.Skip("[notSystemd]: " + reason)
Skip("[notSystemd]: " + reason)
}
}

func SkipIfNotFedora() {
info := GetHostDistributionInfo()
if info.Distribution != "fedora" {
ginkgo.Skip("Test can only run on Fedora")
Skip("Test can only run on Fedora")
}
}

Expand Down Expand Up @@ -684,10 +679,7 @@ func SkipIfCgroupV2(reason string) {

func isContainerized() bool {
// This is set to "podman" by podman automatically
if os.Getenv("container") != "" {
return true
}
return false
return os.Getenv("container") != ""
}

func SkipIfContainerized(reason string) {
Expand All @@ -702,7 +694,7 @@ func SkipIfRemote(reason string) {
if !IsRemote() {
return
}
ginkgo.Skip("[remote]: " + reason)
Skip("[remote]: " + reason)
}

// SkipIfInContainer skips a test if the test is run inside a container
Expand Down Expand Up @@ -872,10 +864,10 @@ func (p *PodmanTestIntegration) removeCNINetwork(name string) {
Expect(session.ExitCode()).To(BeNumerically("<=", 1), "Exit code must be 0 or 1")
}

func (p *PodmanSessionIntegration) jq(jqCommand string) (string, error) {
func (s *PodmanSessionIntegration) jq(jqCommand string) (string, error) {
var out bytes.Buffer
cmd := exec.Command("jq", jqCommand)
cmd.Stdin = strings.NewReader(p.OutputToString())
cmd.Stdin = strings.NewReader(s.OutputToString())
cmd.Stdout = &out
err := cmd.Run()
return strings.TrimRight(out.String(), "\n"), err
Expand Down
16 changes: 8 additions & 8 deletions test/e2e/config_amd64.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package integration

var (
STORAGE_FS = "vfs"
STORAGE_OPTIONS = "--storage-driver vfs"
ROOTLESS_STORAGE_FS = "vfs"
ROOTLESS_STORAGE_OPTIONS = "--storage-driver vfs"
CACHE_IMAGES = []string{ALPINE, BB, fedoraMinimal, nginx, redis, registry, infra, labels, healthcheck, ubi_init, ubi_minimal, fedoraToolbox}
STORAGE_FS = "vfs" //nolint:golint,stylecheck
STORAGE_OPTIONS = "--storage-driver vfs" //nolint:golint,stylecheck
ROOTLESS_STORAGE_FS = "vfs" //nolint:golint,stylecheck
ROOTLESS_STORAGE_OPTIONS = "--storage-driver vfs" //nolint:golint,stylecheck
CACHE_IMAGES = []string{ALPINE, BB, fedoraMinimal, nginx, redis, registry, infra, labels, healthcheck, UBI_INIT, UBI_MINIMAL, fedoraToolbox} //nolint:golint,stylecheck
nginx = "quay.io/libpod/alpine_nginx:latest"
BB_GLIBC = "docker.io/library/busybox:glibc"
BB_GLIBC = "docker.io/library/busybox:glibc" //nolint:golint,stylecheck
registry = "quay.io/libpod/registry:2.6"
labels = "quay.io/libpod/alpine_labels:latest"
ubi_minimal = "registry.access.redhat.com/ubi8-minimal"
ubi_init = "registry.access.redhat.com/ubi8-init"
UBI_MINIMAL = "registry.access.redhat.com/ubi8-minimal" //nolint:golint,stylecheck
UBI_INIT = "registry.access.redhat.com/ubi8-init" //nolint:golint,stylecheck
cirros = "quay.io/libpod/cirros:latest"
)
2 changes: 1 addition & 1 deletion test/e2e/container_create_volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ VOLUME %s/`, data, dest, dest)

func createContainersConfFile(pTest *PodmanTestIntegration) {
configPath := filepath.Join(pTest.TempDir, "containers.conf")
containersConf := []byte(fmt.Sprintf("[containers]\nprepare_volume_on_create = true\n"))
containersConf := []byte("[containers]\nprepare_volume_on_create = true\n")
err := ioutil.WriteFile(configPath, containersConf, os.ModePerm)
Expect(err).To(BeNil())

Expand Down
Loading

0 comments on commit c234c20

Please sign in to comment.