Skip to content

E2e mhc tests #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bootstrap/kubeadm/config/manager/manager_image_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ spec:
template:
spec:
containers:
- image: gcr.io/k8s-staging-cluster-api/kubeadm-bootstrap-controller:master
- image: gcr.io/k8s-staging-cluster-api/kubeadm-bootstrap-controller-amd64:dev
name: manager
2 changes: 1 addition & 1 deletion config/manager/manager_image_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ spec:
template:
spec:
containers:
- image: gcr.io/k8s-staging-cluster-api/cluster-api-controller:master
- image: gcr.io/k8s-staging-cluster-api/cluster-api-controller-amd64:dev
name: manager
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ spec:
template:
spec:
containers:
- image: gcr.io/k8s-staging-cluster-api/kubeadm-control-plane-controller:master
- image: gcr.io/k8s-staging-cluster-api/kubeadm-control-plane-controller-amd64:dev
name: manager
35 changes: 35 additions & 0 deletions test/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,28 @@ import (
"context"
"fmt"
"path/filepath"
"strings"

. "github.com/onsi/ginkgo"

"github.com/blang/semver"
"github.com/onsi/gomega/types"
corev1 "k8s.io/api/core/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3"
"sigs.k8s.io/cluster-api/test/framework"
"sigs.k8s.io/cluster-api/util"
)

// Test suite constants for e2e config variables
const (
KubernetesVersion = "KUBERNETES_VERSION"
CNIPath = "CNI"
KubernetesVersionUpgradeFrom = "KUBERNETES_VERSION_UPGRADE_FROM"
KubernetesVersionUpgradeTo = "KUBERNETES_VERSION_UPGRADE_TO"
EtcdVersionUpgradeTo = "ETCD_VERSION_UPGRADE_TO"
CoreDNSVersionUpgradeTo = "COREDNS_VERSION_UPGRADE_TO"
)

func Byf(format string, a ...interface{}) {
By(fmt.Sprintf(format, a...))
}
Expand Down Expand Up @@ -72,3 +85,25 @@ func dumpSpecResourcesAndCleanup(ctx context.Context, specName string, clusterPr
}
cancelWatches()
}

// HaveValidVersion succeeds if version is a valid semver version
func HaveValidVersion(version string) types.GomegaMatcher {
return &validVersionMatcher{version: version}
}

type validVersionMatcher struct{ version string }

func (m *validVersionMatcher) Match(actual interface{}) (success bool, err error) {
if _, err := semver.Parse(strings.TrimPrefix(strings.TrimSpace(m.version), "v")); err != nil {
return false, err
}
return true, nil
}

func (m *validVersionMatcher) FailureMessage(actual interface{}) (message string) {
return fmt.Sprintf("Expected\n%s\n%s", m.version, " to be a valid version ")
}

func (m *validVersionMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return fmt.Sprintf("Expected\n%s\n%s", m.version, " not to be a valid version ")
}
8 changes: 4 additions & 4 deletions test/e2e/config/docker-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ providers:

variables:
KUBERNETES_VERSION: "v1.18.2"
ETCD_VERSION_CURRENT: "3.4.3-0"
COREDNS_VERSION_CURRENT: "1.6.7"
ETCD_VERSION_UPGRADE_TO: "3.4.3-0"
COREDNS_VERSION_UPGRADE_TO: "1.6.7"
KUBERNETES_VERSION_UPGRADE_TO: "v1.18.2"
KUBERNETES_VERSION_UPGRADE_FROM: "v1.17.2"
KUBERNETES_VERSION_MINIMUM_CAPI_SUPPORTED: "v1.16.4"
DOCKER_SERVICE_DOMAIN: "cluster.local"
DOCKER_SERVICE_CIDRS: "10.128.0.0/12"
# IMPORTANT! This values should match the one used by the CNI provider
Expand All @@ -79,4 +79,4 @@ intervals:
default/wait-worker-nodes: ["5m", "10s"]
default/wait-delete-cluster: ["3m", "10s"]
default/wait-machine-upgrade: ["20m", "10s"]

default/wait-machine-remediation: ["3m", "10s"]
7 changes: 4 additions & 3 deletions test/e2e/config/docker-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ providers:

variables:
KUBERNETES_VERSION: "v1.18.2"
ETCD_VERSION_CURRENT: "3.4.3-0"
COREDNS_VERSION_CURRENT: "1.6.7"
ETCD_VERSION_UPGRADE_TO: "3.4.3-0"
COREDNS_VERSION_UPGRADE_TO: "1.6.7"
KUBERNETES_VERSION_UPGRADE_TO: "v1.18.2"
KUBERNETES_VERSION_UPGRADE_FROM: "v1.17.2"
KUBERNETES_VERSION_MINIMUM_CAPI_SUPPORTED: "v1.16.4"
DOCKER_SERVICE_DOMAIN: "cluster.local"
DOCKER_SERVICE_CIDRS: "10.128.0.0/12"
# IMPORTANT! This values should match the one used by the CNI provider
Expand All @@ -110,3 +110,4 @@ intervals:
default/wait-worker-nodes: ["3m", "10s"]
default/wait-delete-cluster: ["3m", "10s"]
default/wait-machine-upgrade: ["15m", "10s"]
default/wait-machine-remediation: ["3m", "10s"]
113 changes: 0 additions & 113 deletions test/e2e/data/infrastructure-aws/cluster-template.yaml

This file was deleted.

16 changes: 16 additions & 0 deletions test/e2e/data/infrastructure-docker/cluster-template-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,19 @@ spec:
name: "${ CLUSTER_NAME }-md-0"
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3
kind: DockerMachineTemplate
---

apiVersion: cluster.x-k8s.io/v1alpha3
kind: MachineHealthCheck
metadata:
name: "${CLUSTER_NAME}-mhc-0"
spec:
clusterName: "${ CLUSTER_NAME }"
maxUnhealthy: 40%
selector:
matchLabels:
mhc: unhealthy
unhealthyConditions:
- type: E2ENodeUnhealthy
status: "True"
timeout: 30s
16 changes: 16 additions & 0 deletions test/e2e/data/infrastructure-docker/cluster-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,19 @@ spec:
name: "${ CLUSTER_NAME }-md-0"
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3
kind: DockerMachineTemplate
---

apiVersion: cluster.x-k8s.io/v1alpha3
kind: MachineHealthCheck
metadata:
name: "${CLUSTER_NAME}-mhc-0"
spec:
clusterName: "${ CLUSTER_NAME }"
maxUnhealthy: 40%
selector:
matchLabels:
mhc: unhealthy
unhealthyConditions:
- type: E2ENodeUnhealthy
status: "True"
timeout: 30s
6 changes: 5 additions & 1 deletion test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"path/filepath"
"strings"
"testing"
"time"

. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/config"
Expand Down Expand Up @@ -78,11 +79,14 @@ func init() {
}

func TestE2E(t *testing.T) {
configPath = "/Users/ssavas/dev/qa_capi/tilttest/cluster-api/test/e2e/config/docker-dev.yaml"
artifactFolder = "/Users/ssavas/dev/qa_capi/tilttest/cluster-api/test/e2e/artifacts/"
// If running in prow, make sure to use the artifacts folder that will be reported in test grid (ignoring the value provided by flag).
if prowArtifactFolder, exists := os.LookupEnv("ARTIFACTS"); exists {
artifactFolder = prowArtifactFolder
}

SetDefaultEventuallyTimeout(2 * time.Minute)
SetDefaultEventuallyPollingInterval(10 * time.Second)
RegisterFailHandler(Fail)
junitPath := filepath.Join(artifactFolder, fmt.Sprintf("junit.e2e_suite.%d.xml", config.GinkgoConfig.ParallelNode))
junitReporter := reporters.NewJUnitReporter(junitPath)
Expand Down
Loading