Skip to content

Commit a833107

Browse files
author
Arman Keyoumarsi
committed
Simplified the Sanity test structure
1 parent 490558f commit a833107

File tree

3 files changed

+56
-70
lines changed

3 files changed

+56
-70
lines changed

tests/sanity/README.md

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Sanity Test for new Functionality
22

3-
**Copy of a TF Plan shoud be submmited with each PR, new functionality/variable should be explicitly added here.**
3+
**Copy of a TF Plan shoud be submmited with each PR, new functionality/variable should be explicitly added here under static values section in the main.tf file.**
44

55
### tfvars Example:
66

@@ -11,67 +11,33 @@ vipassword = "fill"
1111
1212
vm = {
1313
linuxvm = {
14-
vmname = "example-server-linux",
1514
vmtemp = "Template name",
16-
instances = 2
1715
is_windows_image = false
1816
vmrp = "fill"
1917
dc = "fill",
2018
datastore = "fill"
2119
vmfolder = "fill"
2220
vmgateway = "10.13.13.1"
2321
dns_servers = ["1.1.1.1"]
24-
data_disk = {
25-
disk1 = {
26-
size_gb = 3,
27-
thin_provisioned = false,
28-
data_disk_scsi_controller = 0,
29-
},
30-
disk2 = {
31-
size_gb = 4,
32-
thin_provisioned = true,
33-
data_disk_scsi_controller = 1,
34-
storage_policy_id = "D680B3D4-ACBE-40B5-BD9C-2EB1526A5EDD"
35-
},
36-
disk3 = {
37-
size_gb = 5,
38-
thin_provisioned = true,
39-
data_disk_scsi_controller = 1,
40-
datastore_id = "datastore-90679"
41-
}
42-
disk4 = {
43-
size_gb = 5,
44-
thin_provisioned = true,
45-
unit_number = 30,
46-
datastore_id = "datastore-90679"
47-
}
48-
}
4922
network = {
5023
"VM Port Group" = ["10.13.13.2", ""], # To use DHCP create Empty list for each instance
5124
"VM Port Group" = ["", ""]
5225
}
53-
tags = {}
54-
annotation = null
5526
},
5627
windowsvm = {
57-
vmname = "example-server-windows",
5828
vmtemp = "fill"
59-
instances = 2
6029
is_windows_image = true
6130
vmrp = "fill"
6231
dc = "fill"
6332
vmfolder = "fill"
6433
datastore = "fill"
6534
dns_servers = null
66-
data_disk = {}
6735
vmgateway = "10.13.13.1"
6836
network = {
6937
"VM Port Group" = ["10.13.13.2", ""], # To use DHCP create Empty list for each instance
7038
"VM Port Group" = ["", ""]
7139
}
7240
}
73-
tags = {}
74-
annotation = null
7541
}
7642
```
7743

tests/sanity/main.tf

Lines changed: 50 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# This workspace id to test the newly added functionality of the changes.
2+
#
3+
# Testing Tags
14
resource "vsphere_tag_category" "category" {
25
name = "terraform-test-category"
36
cardinality = "SINGLE"
@@ -14,59 +17,71 @@ resource "vsphere_tag" "tag" {
1417
category_id = vsphere_tag_category.category.id
1518
description = "Managed by Terraform"
1619
}
17-
20+
#to test naming convention
1821
variable "env" {
1922
default = "dev"
2023
}
2124

25+
#Do not add any new variables here unless it is sensitive
2226
variable "vm" {
2327
type = map(object({
24-
vmname = string
25-
vmtemp = string
26-
dc = string
27-
vmrp = string
28-
vmfolder = string
29-
datastore = string
30-
is_windows_image = bool
31-
tags = map(string)
32-
instances = number
33-
network = map(list(string))
34-
vmgateway = string
35-
dns_servers = list(string)
36-
data_disk = map(map(string))
37-
cpu_share_level = string
38-
cpu_share_count = number
39-
memory_share_level = string
40-
memory_share_count = number
41-
io_reservation = list(number)
42-
io_share_level = list(string)
43-
io_share_count = list(number)
28+
vmname = string
29+
vmtemp = string
30+
dc = string
31+
vmrp = string
32+
vmfolder = string
33+
datastore = string
34+
is_windows_image = bool
35+
network = map(list(string))
36+
vmgateway = string
37+
dns_servers = list(string)
4438
}))
4539
}
4640

41+
#add the new added function/variables here
4742
module "example-server-basic" {
4843
source = "../../"
4944
for_each = var.vm
50-
vmnameformat = "%03d${var.env}"
51-
tag_depends_on = [vsphere_tag.tag.id]
52-
tags = each.value.tags
53-
vmtemp = each.value.vmtemp
54-
is_windows_image = each.value.is_windows_image
55-
instances = each.value.instances
56-
vmname = each.value.vmname
5745
vmrp = each.value.vmrp
5846
vmfolder = each.value.vmfolder
47+
vmtemp = each.value.vmtemp
48+
is_windows_image = each.value.is_windows_image
5949
network = each.value.network
6050
vmgateway = each.value.vmgateway
6151
dc = each.value.dc
6252
datastore = each.value.datastore
63-
data_disk = each.value.data_disk
64-
cpu_share_level = each.value.cpu_share_level
65-
# cpu_share_count = each.value.cpu_share_level == "custom" ? each.value.cpu_share_count : null
66-
# memory_share_level = each.value.memory_share_level
67-
# memory_share_count = each.value.memory_share_level == "custom" ? each.value.memory_share_count : null
68-
# io_share_level = each.value.io_share_level
69-
# io_share_count = each.value.io_share_level == "custom" ? each.value.io_share_count : null
53+
#starting of static values
54+
instances = 2
55+
vmnameformat = "%03d${var.env}"
56+
vmname = "terraform-sanitytest"
57+
annotation = "Terraform Sanity Test"
58+
tag_depends_on = [vsphere_tag.tag.id]
59+
tags = {
60+
"terraform-test-category" = "terraform-test-tag",
61+
}
62+
data_disk = {
63+
disk1 = {
64+
size_gb = 30,
65+
thin_provisioned = false,
66+
data_disk_scsi_controller = 0,
67+
storage_policy_id = "ff45cc66-b624-4621-967f-1aef6437f568"
68+
},
69+
disk2 = {
70+
size_gb = 70,
71+
thin_provisioned = true,
72+
data_disk_scsi_controller = 1,
73+
io_reservation = 15
74+
io_share_level = "custom"
75+
io_share_count = 2000
76+
}
77+
}
78+
io_reservation = [15]
79+
io_share_level = ["custom"]
80+
io_share_count = [2000]
81+
memory_share_level = "custom"
82+
memory_share_count = 2000
83+
cpu_share_level = "custom"
84+
cpu_share_count = 2000
7085
}
7186

7287
output "DC_ID" {

tests/smoke/main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#######################################
2+
# This workspace is for smoke test
3+
# do not modify this file
4+
# #####################################
5+
16
variable "vm" {
27
type = map(object({
38
vmname = string

0 commit comments

Comments
 (0)