Select Git revision
pod_test.go
pod_test.go 5.09 KiB
//go:build e2e
// +build e2e
package test
import (
"fmt"
"strings"
"testing"
"time"
"github.com/kelseyhightower/envconfig"
"github.com/stretchr/testify/suite"
)
const (
hostPathVolumeType = "hostPath"
localVolumeType = "local"
)
type PodTestSuite struct {
suite.Suite
config testConfig
kustomizeDir string
}
func (p *PodTestSuite) SetupSuite() {
err := envconfig.Process("test", &p.config)
if err != nil {
panic(err)
}
p.T().Logf("using test config: %+v", p.config)
p.TearDownSuite()
//kind load docker-image "$image"
cmds := []string{
fmt.Sprintf("kind create cluster --config=%s --wait=120s", testdataFile("kind-cluster.yaml")),
fmt.Sprintf("kind load docker-image %s", p.config.IMAGE),
}
for _, cmd := range cmds {
_, err = runCmd(
p.T(),
cmd,
"",
p.config.envs(),
nil,
)
if err != nil {
p.FailNow("", "failed to create the cluster or load image", err)
}
}
}
func (p *PodTestSuite) TearDownSuite() {
err := deleteCluster(
p.T(),
p.config.envs(),
)
if err != nil {
p.Failf("", "failed to delete the cluster: %v", err)
}
}
func (p *PodTestSuite) TearDownTest() {
err := deleteKustomizeDeployment(
p.T(),
p.kustomizeDir,