Skip to content

Commit

Permalink
ci/integration: refactoring + cleaning
Browse files Browse the repository at this point in the history
Signed-off-by: Loic Devulder <ldevulder@suse.com>
  • Loading branch information
ldevulder committed Oct 26, 2022
1 parent dde508a commit 9321436
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 82 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ concurrency:
env:
REPO: ttl.sh/elemental-ci
jobs:
tests-installer:
container-tests:
runs-on: macos-12
steps:
- name: Checkout code
Expand All @@ -39,8 +39,6 @@ jobs:
- name: Download artifacts
uses: dawidd6/action-download-artifact@v2.24.0
with:
#workflow: ${{ github.event.workflow_run.workflow_id }}
#workflow_conclusion: success
workflow: build-ci.yaml
run_id: ${{ github.event.workflow_run.id }}
name: iso-image
Expand All @@ -53,7 +51,7 @@ jobs:
export CONTAINER_IMAGE=${REPO}:${GIT_TAG}-${GIT_COMMIT_SHORT}
export COS_HOST=127.0.0.1:2222
export ISO=$PWD/$(ls elemental-*.iso 2>/dev/null)
cd tests && make installer-tests
cd tests && make container-tests
- name: Upload logs
uses: actions/upload-artifact@v3
if: failure()
Expand All @@ -66,7 +64,7 @@ jobs:
run: |
cd tests && make clean || true
sudo rm -rf build bin dist || true
tests-vbox:
iso-tests:
runs-on: macos-12
steps:
- name: Checkout code
Expand Down Expand Up @@ -96,8 +94,6 @@ jobs:
- name: Download artifacts
uses: dawidd6/action-download-artifact@v2.24.0
with:
#workflow: ${{ github.event.workflow_run.workflow_id }}
#workflow_conclusion: success
workflow: build-ci.yaml
run_id: ${{ github.event.workflow_run.id }}
name: iso-image
Expand All @@ -107,7 +103,7 @@ jobs:
run: |
export COS_HOST=127.0.0.1:2222
export ISO=$PWD/$(ls elemental-*.iso 2>/dev/null)
cd tests && make vbox-tests
cd tests && make iso-tests
- name: Upload logs
uses: actions/upload-artifact@v3
if: failure()
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*.swp
.idea
/tests/build
/tests/.vagrant
/tests/build-box
/cypress/videos/*
/cypress/screenshots/*
Expand Down
57 changes: 15 additions & 42 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,72 +12,47 @@ ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

export CLOUD_INIT_ISO?=$(ROOT_DIR)/build/ci.iso

clean: clean_vm_from_iso
(vagrant destroy -f) 2> /dev/null || true
(vagrant box remove $(BOX_IMAGE)) 2> /dev/null || true
clean:
VBoxManage controlvm "test" poweroff &>/dev/null || true
VBoxManage unregistervm "test" --delete &>/dev/null || true
VBoxManage closemedium disk sda.vdi --delete &>/dev/null || true
rm -rf build-box build || true

.PHONY: up
up: build/ci.iso
@echo "Cloud init iso at $(CLOUD_INIT_ISO)"
ls -liah $(CLOUD_INIT_ISO)

deps:
go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo
go install -mod=mod github.com/onsi/gomega
go mod tidy

run:
ginkgo -r -v ./smoke

.PHONY: install
install:
ginkgo --label-filter setup -r -v ./install

build/ci.iso:
./prepare_cloudinit

vbox-tests: build/ci.iso deps iso-to-vm
$(MAKE) run

build-box:
# Targets to run tests on VBox (GHA macOS runners)
build-box/sda.vdi:
mkdir build-box

# targets to run tests on VBox (GHA macOS runners)
build-box/sda.vdi: build-box
VBoxManage createmedium disk --filename build-box/sda.vdi --size 40000

iso-to-vm: build-box/sda.vdi deps
# Test installation from ISO image
iso-tests: build-box/sda.vdi deps
VBoxManage createvm --name "test" --register
VBoxManage modifyvm "test" --firmware efi --memory 10240 --cpus 3
VBoxManage modifyvm "test" --nic1 nat --boot1 disk --boot2 dvd --natpf1 "guestssh,tcp,,2222,,22"
VBoxManage storagectl "test" --name "sata controller" --add sata --portcount 2 --hostiocache off
VBoxManage storageattach "test" --storagectl "sata controller" --port 0 --device 0 --type hdd --medium build-box/sda.vdi
VBoxManage storageattach "test" --storagectl "sata controller" --port 1 --device 0 --type dvddrive --medium $(ISO)
VBoxManage startvm "test" --type headless
$(MAKE) install
VBoxManage controlvm "test" poweroff &>/dev/null || true
VBoxManage storageattach 'test' --storagectl 'sata controller' --port 1 --device 0 --type dvddrive --medium emptydrive --forceunmount
VBoxManage storageattach "test" --storagectl "sata controller" --port 1 --device 0 --type dvddrive --medium $(CLOUD_INIT_ISO)
VBoxManage startvm "test" --type headless

clean_vm_from_iso:
VBoxManage controlvm "test" poweroff &>/dev/null || true
VBoxManage unregistervm "test" --delete &>/dev/null || true
VBoxManage closemedium disk sda.vdi --delete &>/dev/null || true
ginkgo --label-filter iso -r -v ./install
ginkgo -r -v ./smoke

installer-tests: build-box/sda.vdi deps
# Test installation from container image
container-tests: build-box/sda.vdi deps
VBoxManage createvm --name "test" --register
VBoxManage modifyvm "test" --firmware efi --memory 10240 --cpus 3
VBoxManage modifyvm "test" --nic1 nat --boot1 disk --boot2 dvd --natpf1 "guestssh,tcp,,2222,,22"
VBoxManage storagectl "test" --name "sata controller" --add sata --portcount 2 --hostiocache off
VBoxManage storageattach "test" --storagectl "sata controller" --port 0 --device 0 --type hdd --medium build-box/sda.vdi
VBoxManage storageattach "test" --storagectl "sata controller" --port 1 --device 0 --type dvddrive --medium $(ISO)
VBoxManage startvm "test" --type headless
ginkgo --label-filter "!setup" -r -v ./install
VBoxManage controlvm "test" poweroff &>/dev/null || true
ginkgo --label-filter container -r -v ./install
ginkgo -r -v ./smoke

# e2e CI tests
# E2E tests
e2e-install-rancher: deps
ginkgo --label-filter install -r -v ./e2e
e2e-configure-rancher: deps
Expand All @@ -88,7 +63,5 @@ e2e-bootstrap-node: deps
ginkgo --label-filter bootstrap -r -v ./e2e
e2e-upgrade-node: deps
ginkgo --label-filter upgrade -r -v ./e2e

# e2e UI tests
start-cypress-tests:
@./scripts/start_cypress_tests.sh
28 changes: 8 additions & 20 deletions tests/install/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ func checkOsAfterReboot(s *sut.SUT) {
Expect(out).To(ContainSubstring("my-own-name"))
}

var _ = Describe("Elemental installation from ISO", Label("setup"), func() {
var _ = Describe("Elemental Installation tests", func() {
var s *sut.SUT
BeforeEach(func() {
s = sut.NewSUT()
s.EventuallyConnects()
})

// This is used to setup the machine that will run other tests
Context("First boot", func() {
Context("From ISO", Label("iso"), func() {
It("can install", func() {
err := s.SendFile("../assets/cloud_init.yaml", "/tmp/cloud_init.yaml", "0640")
Expect(err).ToNot(HaveOccurred())
Expand All @@ -62,24 +62,12 @@ var _ = Describe("Elemental installation from ISO", Label("setup"), func() {
ContainSubstring("Mounting disk partitions"),
ContainSubstring("Finished copying /run/cos/state/cOS/active.img into /run/cos/state/cOS/passive.img"),
ContainSubstring("Setting default grub entry to Elemental"),
))
})

It("has customization applied", func() {
checkOsAfterReboot(s)
), out)
})
})
})

var _ = Describe("Elemental installation from container", func() {
var s *sut.SUT
BeforeEach(func() {
s = sut.NewSUT()
s.EventuallyConnects()
})

Context("First boot", func() {
It("can install from a container image", func() {
Context("From container", Label("container"), func() {
It("can install", func() {
containerImage := os.Getenv("CONTAINER_IMAGE")
if containerImage == "" {
Skip("No CONTAINER_IMAGE defined")
Expand All @@ -99,9 +87,9 @@ var _ = Describe("Elemental installation from container", func() {
ContainSubstring("Setting default grub entry to Elemental"),
), out)
})
})

It("has customization applied", func() {
checkOsAfterReboot(s)
})
It("has customization applied", Label("iso", "container"), func() {
checkOsAfterReboot(s)
})
})
11 changes: 0 additions & 11 deletions tests/prepare_cloudinit

This file was deleted.

0 comments on commit 9321436

Please sign in to comment.