Skip to content

Commit

Permalink
address comments and fix e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziopandini committed Sep 21, 2021
1 parent 7e93b60 commit 89df947
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 18 deletions.
8 changes: 4 additions & 4 deletions cmd/clusterctl/client/cluster/inventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
clusterv1v1alpha3 "sigs.k8s.io/cluster-api/api/v1alpha3"
clusterv1alpha3 "sigs.k8s.io/cluster-api/api/v1alpha3"
clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
"sigs.k8s.io/cluster-api/cmd/clusterctl/internal/test"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -285,15 +285,15 @@ func Test_CheckCAPIContract(t *testing.T) {
Spec: apiextensionsv1.CustomResourceDefinitionSpec{
Versions: []apiextensionsv1.CustomResourceDefinitionVersion{
{
Name: clusterv1v1alpha3.GroupVersion.Version,
Name: clusterv1alpha3.GroupVersion.Version,
Storage: true,
},
},
},
}),
},
args: args{
options: []CheckCAPIContractOption{AllowCAPIContract{Contract: clusterv1v1alpha3.GroupVersion.Version}, AllowCAPIContract{Contract: test.PreviousCAPIContractNotSupported}},
options: []CheckCAPIContractOption{AllowCAPIContract{Contract: clusterv1alpha3.GroupVersion.Version}, AllowCAPIContract{Contract: test.PreviousCAPIContractNotSupported}},
},
wantErr: false,
},
Expand All @@ -316,7 +316,7 @@ func Test_CheckCAPIContract(t *testing.T) {
}),
},
args: args{
options: []CheckCAPIContractOption{AllowCAPIContract{Contract: clusterv1v1alpha3.GroupVersion.Version}, AllowCAPIContract{Contract: test.PreviousCAPIContractNotSupported}},
options: []CheckCAPIContractOption{AllowCAPIContract{Contract: clusterv1alpha3.GroupVersion.Version}, AllowCAPIContract{Contract: test.PreviousCAPIContractNotSupported}},
},
wantErr: false,
},
Expand Down
6 changes: 3 additions & 3 deletions cmd/clusterctl/client/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1v1alpha3 "sigs.k8s.io/cluster-api/api/v1alpha3"
clusterv1alpha3 "sigs.k8s.io/cluster-api/api/v1alpha3"
clusterv1old "sigs.k8s.io/cluster-api/api/v1alpha4"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
Expand Down Expand Up @@ -57,7 +57,7 @@ func (c *clusterctlClient) PlanUpgrade(options PlanUpgradeOptions) ([]UpgradePla
// NOTE: given that v1beta1 (current) and v1alpha4 (previous) does not have breaking changes, we support also upgrades from v1alpha3 to v1beta1;
// this is an exception and support for skipping releases should be removed in future releases.
if err := clusterClient.ProviderInventory().CheckCAPIContract(
cluster.AllowCAPIContract{Contract: clusterv1v1alpha3.GroupVersion.Version},
cluster.AllowCAPIContract{Contract: clusterv1alpha3.GroupVersion.Version},
cluster.AllowCAPIContract{Contract: clusterv1old.GroupVersion.Version},
); err != nil {
return nil, err
Expand Down Expand Up @@ -123,7 +123,7 @@ func (c *clusterctlClient) ApplyUpgrade(options ApplyUpgradeOptions) error {
// NOTE: given that v1beta1 (current) and v1alpha4 (previous) does not have breaking changes, we support also upgrades from v1alpha3 to v1beta1;
// this is an exception and support for skipping releases should be removed in future releases.
if err := clusterClient.ProviderInventory().CheckCAPIContract(
cluster.AllowCAPIContract{Contract: clusterv1v1alpha3.GroupVersion.Version},
cluster.AllowCAPIContract{Contract: clusterv1alpha3.GroupVersion.Version},
cluster.AllowCAPIContract{Contract: clusterv1old.GroupVersion.Version},
); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/clusterctl_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
. "github.com/onsi/ginkgo"
)

var _ = Describe("When testing clusterctl upgrades", func() {
var _ = Describe("When testing clusterctl upgrades [clusterctl-Upgrade]", func() {

ClusterctlUpgradeSpec(ctx, func() ClusterctlUpgradeSpecInput {
return ClusterctlUpgradeSpecInput{
Expand Down
40 changes: 30 additions & 10 deletions test/e2e/config/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,21 @@ providers:
- name: v0.3.23 # latest published release in the v1alpha3 series; this is used for v1alpha3 --> v1beta1 clusterctl upgrades test only.
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.3.23/core-components.yaml"
type: "url"
contract: v1alpha3
replacements:
- old: --metrics-addr=127.0.0.1:8080
new: --metrics-addr=:8080
files:
- sourcePath: "../data/shared/v1alpha3/metadata.yaml"
- name: v0.4.3 # latest published release in the v1alpha4 series; this is used for v1alpha4 --> v1beta1 clusterctl upgrades test only.
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.3/core-components.yaml"
type: "url"
replacements:
- old: --metrics-addr=127.0.0.1:8080
new: --metrics-addr=:8080
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.3/core-components.yaml"
type: "url"
contract: v1alpha4
replacements:
- old: --metrics-addr=127.0.0.1:8080
new: --metrics-addr=:8080
files:
- sourcePath: "../data/shared/v1alpha4/metadata.yaml"
- name: v1.0.99 # next; use manifest from source files
value: ../../../config/default
replacements:
Expand All @@ -55,15 +61,21 @@ providers:
- name: v0.3.23 # latest published release in the v1alpha3 series; this is used for v1alpha3 --> v1beta1 clusterctl upgrades test only.
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.3.23/bootstrap-components.yaml"
type: "url"
contract: v1alpha3
replacements:
- old: --metrics-addr=127.0.0.1:8080
new: --metrics-addr=:8080
files:
- sourcePath: "../data/shared/v1alpha3/metadata.yaml"
- name: v0.4.3 # latest published release in the v1alpha4 series; this is used for v1alpha4 --> v1beta1 clusterctl upgrades test only.
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.3/bootstrap-components.yaml"
type: "url"
contract: v1alpha4
replacements:
- old: --metrics-addr=127.0.0.1:8080
new: --metrics-addr=:8080
files:
- sourcePath: "../data/shared/v1alpha4/metadata.yaml"
- name: v1.0.99 # next; use manifest from source files
value: ../../../bootstrap/kubeadm/config/default
replacements:
Expand All @@ -78,15 +90,21 @@ providers:
- name: v0.3.23 # latest published release in the v1alpha3 series; this is used for v1alpha3 --> v1beta1 clusterctl upgrades test only.
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.3.23/control-plane-components.yaml"
type: "url"
contract: v1alpha3
replacements:
- old: --metrics-addr=127.0.0.1:8080
new: --metrics-addr=:8080
files:
- sourcePath: "../data/shared/v1alpha3/metadata.yaml"
- name: v0.4.3 # latest published release in the v1alpha4 series; this is used for v1alpha4 --> v1beta1 clusterctl upgrades test only.
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.3/control-plane-components.yaml"
type: "url"
contract: v1alpha4
replacements:
- old: --metrics-addr=127.0.0.1:8080
new: --metrics-addr=:8080
files:
- sourcePath: "../data/shared/v1alpha4/metadata.yaml"
- name: v1.0.99 # next; use manifest from source files
value: ../../../controlplane/kubeadm/config/default
replacements:
Expand All @@ -101,20 +119,22 @@ providers:
- name: v0.3.23 # latest published release in the v1alpha3 series; this is used for v1alpha3 --> v1beta1 clusterctl upgrades test only.
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.3.23/infrastructure-components-development.yaml"
type: "url"
contract: v1alpha3
replacements:
- old: --metrics-addr=127.0.0.1:8080
new: --metrics-addr=:8080
files:
# Add cluster templates
- sourcePath: "../data/shared/v1alpha3/metadata.yaml"
- sourcePath: "../data/infrastructure-docker/v1alpha3/cluster-template.yaml"
- name: v0.4.3 # latest published release in the v1alpha4 series; this is used for v1alpha4 --> v1beta1 clusterctl upgrades test only.
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.3/infrastructure-components-development.yaml"
type: "url"
contract: v1alpha4
replacements:
- old: --metrics-addr=127.0.0.1:8080
new: --metrics-addr=:8080
files:
# Add cluster templates
- sourcePath: "../data/shared/v1alpha4/metadata.yaml"
- sourcePath: "../data/infrastructure-docker/v1alpha4/cluster-template.yaml"
- name: v1.0.99 # next; use manifest from source files
value: ../../../test/infrastructure/docker/config/default
Expand Down Expand Up @@ -156,9 +176,9 @@ variables:
NODE_DRAIN_TIMEOUT: "60s"
# NOTE: INIT_WITH_BINARY and INIT_WITH_KUBERNETES_VERSION are only used by the clusterctl upgrade test to initialize
# the management cluster to be upgraded.
INIT_WITH_BINARY: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.3.23/clusterctl-{OS}-{ARCH}"
# CAPI v0.3.x cannot be deployed on Kubernetes >= v1.22.
INIT_WITH_KUBERNETES_VERSION: "v1.21.2"
INIT_WITH_BINARY: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.3/clusterctl-{OS}-{ARCH}"
INIT_WITH_PROVIDERS_CONTRACT: "v1alpha4"
INIT_WITH_KUBERNETES_VERSION: "v1.22.0"

intervals:
default/wait-controllers: ["3m", "10s"]
Expand Down
9 changes: 9 additions & 0 deletions test/e2e/data/shared/v1alpha3/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: clusterctl.cluster.x-k8s.io/v1alpha3
kind: Metadata
releaseSeries:
- major: 0
minor: 3
contract: v1alpha3
- major: 0
minor: 2
contract: v1alpha2

0 comments on commit 89df947

Please sign in to comment.