Skip to content

Commit

Permalink
ci: test reset feature in cli tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juadk committed Sep 19, 2023
1 parent 4960ffc commit 89c37a1
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/master-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,11 @@ jobs:
- name: Install a simple application
if: inputs.test_type == 'cli' && contains(inputs.upstream_cluster_version, 'k3s')
run: cd tests && make e2e-install-app && make e2e-check-app
- name: Reset a node in the cluster
if: inputs.test_type == 'cli'
run: cd tests && make e2e-reset
- name: Stop the test
run: exit 1
- name: Upgrade Elemental Operator
if: inputs.test_type == 'cli' && inputs.operator_upgrade != ''
id: operator_upgrade
Expand Down
2 changes: 2 additions & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ e2e-check-app: deps
ginkgo --label-filter check-app -r -v ./e2e
e2e-configure-rancher: deps
ginkgo --label-filter configure -r -v ./e2e
e2e-reset: deps
ginkgo --label-filter reset -r -v ./e2e
e2e-get-logs: deps
ginkgo --label-filter logs -r -v ./e2e
e2e-install-rancher: deps
Expand Down
7 changes: 7 additions & 0 deletions tests/assets/machineRegistration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,11 @@ spec:
poweroff: true
device: /dev/sda
debug: true
reset:
debug: true
enabled: true
reset-persistent: true
reset-oem: true
poweroff: false
reboot: true
machineName: %VM_NAME%-${System Information/UUID}
3 changes: 3 additions & 0 deletions tests/assets/reset_machine_inventory.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
metadata:
annotations:
elemental.cattle.io/resettable: "true"
54 changes: 54 additions & 0 deletions tests/e2e/reset_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
Copyright © 2022 - 2023 SUSE LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package e2e_test

import (
"os/exec"
"strings"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/rancher-sandbox/ele-testhelpers/kubectl"
)

var _ = Describe("E2E - Test the reset feature", Label("reset"), func() {
It("Reset one node in the cluster", func() {
// Get the machine inventory name list
machineInventory, err := kubectl.Run("get", "machineinventory", "-A", "-o", "jsonpath='{.items[*].metadata.name}'")
Expect(err).To(Not(HaveOccurred()))
firstMachineInventory := strings.Split(machineInventory, " ")[1]

By("Configuring reset at machine inventory level", func() {
// Patch the first machine inventory to enable reset
_, err = kubectl.Run("patch", "machineinventory", firstMachineInventory, "--namespace", clusterNS, "--type", "merge", "--patch-file", resetMachineInv)
Expect(err).To(Not(HaveOccurred()))
})

By("Deleting and removing the node from the cluster", func() {
machineToRemove, err := exec.Command("kubectl", "get", "machines", "-A", "|", "awk '/ "+firstMachineInventory+"/ {print $2}").CombinedOutput()
Expect(err).To(Not(HaveOccurred()))
kubectl.Run("delete", "machines", string(machineToRemove), "-A")

})

By("Checking machine inventory", func() {

})

By("Adding the node back into the cluster", func() {

})
})
})
1 change: 1 addition & 0 deletions tests/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const (
numberOfNodesMax = 30
osListYaml = "../assets/managedOSVersionChannel.yaml"
registrationYaml = "../assets/machineRegistration.yaml"
resetMachineInv = "../assets/reset_machine_inventory.yaml"
restoreYaml = "../assets/restore.yaml"
seedimageYaml = "../assets/seedImage.yaml"
selectorYaml = "../assets/selector.yaml"
Expand Down

0 comments on commit 89c37a1

Please sign in to comment.