Skip to content

Commit 22648cd

Browse files
authored
implement e2e test framework (#104)
1 parent 4048c00 commit 22648cd

File tree

5 files changed

+135
-0
lines changed

5 files changed

+135
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: E2E tests
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
logs:
7+
description: 'Set 1 to activate full logs'
8+
required: false
9+
default: '0'
10+
11+
jobs:
12+
e2e:
13+
runs-on: ubuntu-latest
14+
name: launch E2E tests
15+
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
test: [ simple ]
20+
steps:
21+
- name: Checkout Repository
22+
uses: actions/checkout@v3
23+
24+
- name: Setup `packer`
25+
uses: hashicorp/setup-packer@main
26+
id: setup
27+
28+
- name: Run `packer init`
29+
id: init
30+
run: "packer init ."
31+
with:
32+
working_directory: test/e2e/${{ matrix.version}}
33+
34+
- name: Run `packer validate`
35+
id: validate
36+
run: "packer validate ."
37+
env:
38+
PACKER_LOG: ${{ github.event.inputs.logs }}
39+
with:
40+
working_directory: test/e2e/${{ matrix.version}}
41+
42+
- name: Run `packer validate`
43+
id: build
44+
run: "packer build ."
45+
env:
46+
PACKER_LOG: ${{ github.event.inputs.logs }}
47+
with:
48+
working_directory: test/e2e/${{ matrix.version}}

test/e2e/simple/build.pkr.hcl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
build {
2+
source "nutanix.centos" {
3+
name = "centos"
4+
}
5+
6+
provisioner "shell" {
7+
only = ["nutanix.centos"]
8+
environment_vars = [
9+
"FOO=hello world",
10+
]
11+
inline = [
12+
"echo \"FOO is $FOO\" > example.txt",
13+
]
14+
}
15+
}

test/e2e/simple/plugin.pkr.hcl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
packer {
2+
required_plugins {
3+
nutanix = {
4+
version = ">= 0.4.0"
5+
source = "github.com/nutanix-cloud-native/nutanix"
6+
}
7+
}
8+
}

test/e2e/simple/source.pkr.hcl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
source "nutanix" "centos" {
2+
nutanix_username = var.nutanix_username
3+
nutanix_password = var.nutanix_password
4+
nutanix_endpoint = var.nutanix_endpoint
5+
nutanix_port = var.nutanix_port
6+
nutanix_insecure = var.nutanix_insecure
7+
cluster_name = var.nutanix_cluster
8+
os_type = "Linux"
9+
10+
vm_disks {
11+
image_type = "DISK_IMAGE"
12+
source_image_name = var.centos_disk_image_name
13+
disk_size_gb = 40
14+
}
15+
16+
vm_nics {
17+
subnet_name = var.nutanix_subnet
18+
}
19+
20+
image_name = "centos-packer-image"
21+
image_category_key = "region"
22+
image_category_value = "paris"
23+
24+
force_deregister = true
25+
user_data = "I2Nsb3VkLWNvbmZpZwp1c2VyczoKICAtIG5hbWU6IGNlbnRvcwogICAgc3VkbzogWydBTEw9KEFMTCkgTk9QQVNTV0Q6QUxMJ10KY2hwYXNzd2Q6CiAgbGlzdDogfAogICAgY2VudG9zOnBhY2tlcgogIGV4cGlyZTogRmFsc2UKc3NoX3B3YXV0aDogVHJ1ZQ=="
26+
27+
shutdown_command = "echo 'packer' | sudo -S shutdown -P now"
28+
shutdown_timeout = "2m"
29+
ssh_password = "packer"
30+
ssh_username = "centos"
31+
}

test/e2e/simple/variables.pkr.hcl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
variable "nutanix_username" {
2+
type = string
3+
}
4+
5+
variable "nutanix_password" {
6+
type = string
7+
sensitive = true
8+
}
9+
10+
variable "nutanix_endpoint" {
11+
type = string
12+
}
13+
14+
variable "nutanix_port" {
15+
type = number
16+
}
17+
18+
variable "nutanix_insecure" {
19+
type = bool
20+
default = true
21+
}
22+
23+
variable "nutanix_subnet" {
24+
type = string
25+
}
26+
27+
variable "nutanix_cluster" {
28+
type = string
29+
}
30+
31+
variable "centos_disk_image_name" {
32+
type = string
33+
}

0 commit comments

Comments
 (0)