Skip to content

Commit

Permalink
test-test
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Rantil committed Nov 21, 2023
1 parent 5186850 commit afe00df
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 45 deletions.
4 changes: 2 additions & 2 deletions hack/ci-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ docker run --name image-server-e2e -d \
set +e

# Run the e2e tests
# make test-e2e GINKGO_FOCUS="should provision a BMH with live ISO and then deprovision it"
make test-e2e
make test-e2e GINKGO_FOCUS="should provision a BMH with live ISO and then deprovision it"
# make test-e2e
test_status="$?"

# Collect all artifacts
Expand Down
9 changes: 1 addition & 8 deletions hack/clean-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,10 @@ docker rm -f vbmc
docker rm -f image-server-e2e
docker rm -f sushy-tools
virsh -c qemu:///system destroy --domain bmo-e2e-0
virsh -c qemu:///system undefine --domain bmo-e2e-0 --remove-all-storage
virsh -c qemu:///system undefine --domain bmo-e2e-0 --nvram --remove-all-storage
virsh -c qemu:///system net-destroy baremetal-e2e
virsh -c qemu:///system net-undefine baremetal-e2e

rm -rfv "${REPO_ROOT}/test/e2e/_artifacts"
rm -rfv "${REPO_ROOT}/artifacts.tar.gz"
rm -rfv "${REPO_ROOT}/test/e2e/images"

# Remove the test ssh key pair
IP_ADDRESS="192.168.222.122" #need to be sure it is the same always
KEY_DIR="/tmp/ssh_testkeys"
rm -f "$KEY_DIR/ssh_testkey" "$KEY_DIR/ssh_testkey.pub"
rm -rf "$KEY_DIR"
ssh-keygen -f "${HOME}/.ssh/known_hosts" -R ${IP_ADDRESS}
3 changes: 2 additions & 1 deletion hack/e2e/net.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
<ip address='192.168.222.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.222.2' end='192.168.222.199'/>
<host mac='52:54:00:6c:3c:01' name='vm1' ip='192.168.222.199'/>
<host mac='52:54:00:6c:3c:01' name='minikube' ip='192.168.222.199'/>
<host mac='00:60:2f:31:81:01' name='bmo-e2e-0' ip='192.168.222.122'/>
<bootp file='http://192.168.222.199:6180/boot.ipxe'/>
</dhcp>
</ip>
Expand Down
29 changes: 5 additions & 24 deletions test/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,31 +212,8 @@ func WaitForBmhInPowerState(ctx context.Context, input WaitForBmhInPowerStateInp
}, intervals...).Should(Succeed())
}

func createUserData(publicKey string) string {
userData := fmt.Sprintf(`#cloud-config
users:
- name: ubuntu
shell: /bin/bash
ssh_authorized_keys:
- %s
`, publicKey)

fmt.Println("Generated user-data:")
fmt.Println(userData)
return userData
}

func getPublicKey() string {
publicKey, err := os.ReadFile("/tmp/ssh_testkeys/ssh_testkey.pub")
if err != nil {
fmt.Println("Error reading public key")
return ""
}
return string(publicKey)
}


func executeSSHCommand(client *ssh.Client, command string) (string, error) {
session, err := client.NewSession()
if err != nil {
Expand Down Expand Up @@ -302,3 +279,7 @@ func IsBootedFromDisk(client *ssh.Client) (bool, error) {

return isDisk, nil
}

func StringPtr(s string) *string {
return &s
}
2 changes: 1 addition & 1 deletion test/e2e/config/ironic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ intervals:
default/wait-namespace-deleted: ["10m", "1s"]
ironic/wait-deployment: ["10m", "2s"]
default/wait-power-state: ["10m", "100ms"]
default/wait-provisioning: ["1m", "1s"]
default/wait-provisioning: ["30s", "1s"] #was 1 minute
default/wait-provisioned: ["5m", "1s"]
default/wait-deprovisioning: ["1m", "10ms"]
live-iso-test/privisioning: ["10m", "1s"]
Expand Down
15 changes: 6 additions & 9 deletions test/e2e/live_iso_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ var _ = Describe("Live-ISO", func() {
Expect(err).NotTo(HaveOccurred())
bmh.Spec.Image = &metal3api.Image{
URL: e2eConfig.GetVariable("IMAGE_URL"),
// Checksum: e2eConfig.GetVariable("IMAGE_CHECKSUM"),
Checksum: e2eConfig.GetVariable("IMAGE_CHECKSUM"),
// Checksum: "",
// ChecksumType: "",
DiskFormat: StringPtr("live-iso"), // Adding DiskFormat
// DiskFormat: StringPtr("live-iso"), // Adding DiskFormat
}
bmh.Spec.RootDeviceHints = &metal3api.RootDeviceHints{
DeviceName: "/dev/vda",
Expand All @@ -130,8 +130,6 @@ var _ = Describe("Live-ISO", func() {
}, e2eConfig.GetIntervals(specName, "wait-provisioned")...)

By("Verifying the node booted from live ISO image")


fmt.Println("WE ARE HERE")
// Set up SSH client configuration
config := &ssh.ClientConfig{
Expand All @@ -144,10 +142,9 @@ var _ = Describe("Live-ISO", func() {

// Establish an SSH connection
client, err := ssh.Dial("tcp", "192.168.222.122:22", config)
if err != nil {
fmt.Printf("failed to dial: %v\n", err)
return
}
if err != nil { // clean away the if statement
Expect(err).NotTo(HaveOccurred(), "failed to dial: %v\n", err)
}
defer client.Close()

fmt.Println("WE ARE HERE TOO")
Expand All @@ -162,7 +159,7 @@ var _ = Describe("Live-ISO", func() {
fmt.Println("WE ARE HERE THREE!")

By("Triggering the deprovisioning of the BMH")
helper, err := patch.NewHelper(&bmh, clusterProxy.GetClient())
helper, err = patch.NewHelper(&bmh, clusterProxy.GetClient())
Expect(err).NotTo(HaveOccurred())
bmh.Spec.Image = nil
Expect(helper.Patch(ctx, &bmh)).To(Succeed())
Expand Down

0 comments on commit afe00df

Please sign in to comment.