Skip to content

Commit

Permalink
[e2e] Add support for platform=none
Browse files Browse the repository at this point in the history
- Add platform=none as new cloud provider in WMCO e2e test suite
- Add a check in testWindowsNodeCreation test to avoid the creation of
  Windows machines via machineSet, and just wait for the Windows instance(s)
  to become Windows node(s).
- Introduce a parametrized entry point in Makefile to invoke the e2e-test
  suite from CI, just for the BYOH use case.
- Add a new step in run-ci-e2e-test.sh script to create the windows-instances
  configMap once the operator deployment process is complete.
  • Loading branch information
jrvaldes committed Jan 7, 2022
1 parent 4379b3b commit 0289df3
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ run-ci-e2e-test:
run-ci-e2e-upgrade-test:
hack/run-ci-e2e-test.sh -t upgrade

# TODO: Consolidate run-ci-e2e-* targets into a single target with arguments.
# For example: run-ci-e2e-test $(ARGS). Requires updates in release steps.
.PHONY: run-ci-e2e-byoh-test $(ARGS)
run-ci-e2e-byoh-test:
hack/run-ci-e2e-test.sh ${ARGS}

.PHONY: clean
clean:
rm -rf ${OUTPUT_DIR}
Expand Down
19 changes: 19 additions & 0 deletions hack/run-ci-e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ BYOH_NODE_COUNT_OPTION=""
SKIP_NODE_DELETION=""
WMCO_PATH_OPTION=""

# WINDOWS_INSTANCES_DATA holds the windows-instances configMap data section
declare -r WINDOWS_INSTANCES_DATA=${WINDOWS_INSTANCES_DATA:-}

export CGO_ENABLED=0

get_WMCO_logs() {
Expand Down Expand Up @@ -101,6 +104,22 @@ if ! [[ "$OPENSHIFT_CI" = "true" && "$TEST" = "upgrade" ]]; then
done
fi

# Check windows-instances data and create the windows-instances configMap, if
# any. The configMap creation must takes place after the operator's deployment
# process is complete, because the namespace is removed as part of the cleanup
# function (cleanup_WMCO) while retrying the deployment.
if [[ -n "$WINDOWS_INSTANCES_DATA" ]]; then
# create configMap
cat <<EOF | oc apply -f -
kind: ConfigMap
apiVersion: v1
metadata:
name: windows-instances
namespace: ${WMCO_DEPLOY_NAMESPACE}
${WINDOWS_INSTANCES_DATA}
EOF
fi

# The bool flags in golang does not respect key value pattern. They follow -flag=x pattern.
# -flag x is allowed for non-boolean flags only(https://golang.org/pkg/flag/)

Expand Down
12 changes: 12 additions & 0 deletions test/e2e/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ func testWindowsNodeCreation(t *testing.T) {
// Create a private key secret with the known private key.
require.NoError(t, testCtx.createPrivateKeySecret(true), "could not create known private key secret")

// in case platform=none is detected just wait for Windows worker node to become available
if testCtx.CloudProvider.GetType() == config.NonePlatformType {
// TODO: setPowerShellDefaultShell for given Windows instance(s)
// TODO: validate windows-instances configMap
t.Run("[platform=none] Windows instance configured by ConfigMap controller", func(t *testing.T) {
err = testCtx.waitForWindowsNodes(gc.numberOfBYOHNodes, false, false, true)
assert.NoError(t, err, "Windows node creation failed")
})
// Expected number of Windows instances configured as worker nodes, return
return
}

t.Run("Machine controller", testCtx.testMachineConfiguration)
// BYOH creation must occur after the Machine creation, as the MachineConfiguration tests change the private key
// multiple times, and BYOH doesnt have the functionality of rotating keys on the VMs. This would result in BYOH
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/providers/cloudprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
oc "github.com/openshift/windows-machine-config-operator/test/e2e/clusterinfo"
awsProvider "github.com/openshift/windows-machine-config-operator/test/e2e/providers/aws"
azureProvider "github.com/openshift/windows-machine-config-operator/test/e2e/providers/azure"
noneProvider "github.com/openshift/windows-machine-config-operator/test/e2e/providers/none"
vSphereProvider "github.com/openshift/windows-machine-config-operator/test/e2e/providers/vsphere"
)

Expand Down Expand Up @@ -37,6 +38,8 @@ func NewCloudProvider(hasCustomVXLANPort bool) (CloudProvider, error) {
return azureProvider.New(openshift, hasCustomVXLANPort)
case config.VSpherePlatformType:
return vSphereProvider.New(openshift)
case config.NonePlatformType:
return noneProvider.New(openshift)
default:
return nil, fmt.Errorf("the '%v' cloud provider is not supported", provider)
}
Expand Down
31 changes: 31 additions & 0 deletions test/e2e/providers/none/none.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package none

import (
"github.com/pkg/errors"

config "github.com/openshift/api/config/v1"
mapi "github.com/openshift/api/machine/v1beta1"
"github.com/openshift/windows-machine-config-operator/test/e2e/clusterinfo"
)

// Provider is a provider struct for testing platform=none
type Provider struct {
oc *clusterinfo.OpenShift
}

// New returns a Provider implementation for platform=none
func New(clientset *clusterinfo.OpenShift) (*Provider, error) {
return &Provider{
oc: clientset,
}, nil
}

// GenerateMachineSet is not supported for platform=none and throws an exception
func (p *Provider) GenerateMachineSet(withWindowsLabel bool, replicas int32) (*mapi.MachineSet, error) {
return nil, errors.New("MachineSet generation not supported for platform=none")
}

// GetType returns the platform type for platform=none
func (p *Provider) GetType() config.PlatformType {
return config.NonePlatformType
}

0 comments on commit 0289df3

Please sign in to comment.