Skip to content

Commit a54c272

Browse files
Eng 786 do not require UUID in node base image (#58)
* chore(node): add udpate test
1 parent 4f95411 commit a54c272

File tree

8 files changed

+10976
-26
lines changed

8 files changed

+10976
-26
lines changed

resources/node_test.go

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,19 @@ func TestNode_Create_RequiredAttributesOnly(t *testing.T) {
4949
}
5050

5151
func TestNode_Create_AllAttributes(t *testing.T) {
52-
var got models.Node
53-
var expected models.Node
52+
var gotCreated, gotUpdated, expectCreated, expectUpdated models.Node
5453

55-
// input config
56-
inputPath := "node/create_complete.tf"
57-
input := mustGetTestInput(t, inputPath)
54+
// input configs
55+
createPath := "node/create_all.tf"
56+
inputCreate := mustGetTestInput(t, createPath)
57+
updatePath := "node/update_all.tf"
58+
inputUpdate := mustGetTestInput(t, updatePath)
5859

5960
// expected output
60-
expectedPath := "node/create_complete.yaml"
61-
mustGetExpectedOutput(t, expectedPath, &expected)
61+
createPath = "node/create_all.yaml"
62+
mustGetExpectedOutput(t, createPath, &expectCreated)
63+
updatePath = "node/update_all.yaml"
64+
mustGetExpectedOutput(t, updatePath, &expectUpdated)
6265

6366
// terraform acceptance test case
6467
resource.Test(t, resource.TestCase{
@@ -67,25 +70,37 @@ func TestNode_Create_AllAttributes(t *testing.T) {
6770
Providers: testAccProviders,
6871
Steps: []resource.TestStep{
6972
{
70-
Config: input,
73+
Config: inputCreate,
7174
Check: resource.ComposeTestCheckFunc(
72-
testNodeExists("zedcloud_edgenode.complete", &got),
73-
resource.TestCheckResourceAttr("zedcloud_edgenode.complete", "name", "complete"),
74-
resource.TestCheckResourceAttr("zedcloud_edgenode.complete", "model_id", "2f716b55-2639-486c-9a2f-55a2e94146a6"),
75-
resource.TestCheckResourceAttr("zedcloud_edgenode.complete", "title", "complete-title"),
75+
testNodeExists("zedcloud_edgenode.test_tf_provider", &gotCreated),
76+
resource.TestCheckResourceAttr("zedcloud_edgenode.test_tf_provider", "name", "test_tf_provider"),
77+
resource.TestCheckResourceAttr("zedcloud_edgenode.test_tf_provider", "model_id", "2f716b55-2639-486c-9a2f-55a2e94146a6"),
78+
resource.TestCheckResourceAttr("zedcloud_edgenode.test_tf_provider", "title", "test_tf_provider-title"),
7679
resource.TestMatchResourceAttr(
77-
"zedcloud_edgenode.complete",
80+
"zedcloud_edgenode.test_tf_provider",
7881
"id",
7982
regexp.MustCompile("^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[8|9|aA|bB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$"),
8083
),
81-
testNodeAttributes(t, &got, &expected),
84+
testNodeAttributes(t, &gotCreated, &expectCreated),
85+
),
86+
},
87+
{
88+
Config: inputUpdate,
89+
Check: resource.ComposeTestCheckFunc(
90+
testNodeExists("zedcloud_edgenode.test_tf_provider", &gotUpdated),
91+
resource.TestCheckResourceAttr("zedcloud_edgenode.test_tf_provider", "name", "test_tf_provider"),
92+
resource.TestCheckResourceAttr("zedcloud_edgenode.test_tf_provider", "model_id", "2f716b55-2639-486c-9a2f-55a2e94146a6"),
93+
resource.TestCheckResourceAttr("zedcloud_edgenode.test_tf_provider", "title", "test_tf_provider-title"),
94+
resource.TestMatchResourceAttr(
95+
"zedcloud_edgenode.test_tf_provider",
96+
"id",
97+
regexp.MustCompile("^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[8|9|aA|bB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$"),
98+
),
99+
testNodeAttributes(t, &gotUpdated, &expectUpdated),
82100
),
83101
},
84102
},
85103
})
86-
87-
// update all fields
88-
// create and update fields with custom logic and separate api requests
89104
}
90105

91106
// testNodeExists retrieves the Node and stores it in the provided *models.DeviceConfig.

resources/terraform.log

Lines changed: 10621 additions & 0 deletions
Large diffs are not rendered by default.

resources/testdata/node/create_complete.tf renamed to resources/testdata/node/create_all.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
resource "zedcloud_edgenode" "complete" {
1+
resource "zedcloud_edgenode" "test_tf_provider" {
22
# required
3-
name = "complete"
3+
name = "test_tf_provider"
44
model_id = "2f716b55-2639-486c-9a2f-55a2e94146a6"
55
project_id = "4754cd0f-82d7-4e06-a68f-ff9e23e75ccf"
6-
title = "complete-title"
6+
title = "test_tf_provider-title"
77

88
# optional
99
onboarding_key = "5d0767ee-0547-4569-b530-387e526f8cb9"
@@ -137,7 +137,7 @@ resource "zedcloud_edgenode" "complete" {
137137
# kind = "NETWORK_INSTANCE_KIND_LOCAL"
138138
# name = "default_net_inst-name"
139139
# port = "eth1"
140-
# title = "default_net_inst-complete-config"
140+
# title = "default_net_inst-test_tf_provider-config"
141141

142142
# # optional
143143
# project_id = "default-project"

resources/testdata/node/create_complete.yaml renamed to resources/testdata/node/create_all.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ interfaces:
5555
location: ""
5656
memory: 0
5757
modelid: 2f716b55-2639-486c-9a2f-55a2e94146a6
58-
name: complete
58+
name: test_tf_provider
5959
obkey: 5d0767ee-0547-4569-b530-387e526f8cb9
6060
onboarding: null
6161
preparepoweroffcounter: 0
@@ -71,6 +71,6 @@ tags:
7171
tag-key-1: tag-value-1
7272
tag-key-2: tag-value-2
7373
thread: 0
74-
title: complete-title
74+
title: test_tf_provider-title
7575
token: token
7676
utype: null

resources/testdata/node/update_all.tf

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
resource "zedcloud_edgenode" "test_tf_provider" {
2+
# required
3+
name = "test_tf_provider"
4+
model_id = "2f716b55-2639-486c-9a2f-55a2e94146a6"
5+
project_id = "4754cd0f-82d7-4e06-a68f-ff9e23e75ccf"
6+
title = "test_tf_provider-title"
7+
8+
# optional
9+
onboarding_key = "5d0767ee-0547-4569-b530-387e526f8cb9"
10+
serialno = "d6aebfa5-56b6-4b66-9d8e-6552b0e2b45b"
11+
admin_state = "ADMIN_STATE_INACTIVE"
12+
asset_id = "asset_id"
13+
deployment_tag = "depl_tag_update"
14+
description = "description_update"
15+
generate_soft_serial = false
16+
token = "token_update"
17+
18+
site_pictures = []
19+
20+
# base_image {
21+
# activate = true
22+
# image_name = "test_mirageOS"
23+
# # imvol_id = ""
24+
# # uuid = "e46405ab-9155-4a98-96e0-19336703fd01"
25+
# version = "test_mirageOS"
26+
# }
27+
28+
interfaces {
29+
cost = 255
30+
intf_usage = "ADAPTER_USAGE_MANAGEMENT"
31+
intfname = "defaultIPv4"
32+
ipaddr = "127.0.0.1"
33+
macaddr = "00:00:00:00:00:00"
34+
tags = {
35+
"system_interface_1_key" = "system_interface_1_value"
36+
"system_interface_2_key" = "system_interface_2_value"
37+
}
38+
}
39+
interfaces {
40+
intfname = "eth0"
41+
intf_usage = "ADAPTER_USAGE_UNSPECIFIED"
42+
}
43+
44+
config_item {
45+
bool_value = false
46+
float_value = 1.0
47+
key = "key"
48+
string_value = "string_update"
49+
uint32_value = 32
50+
uint64_value = 64
51+
value_type = "value type"
52+
}
53+
54+
dev_location {
55+
city = "berlin"
56+
country = "germany"
57+
freeloc = "freeloc"
58+
hostname = "hostname"
59+
loc = "52.520008, 13.404954"
60+
org = "zededa"
61+
postal = "10115"
62+
region = "europe/west"
63+
underlay_ip = ""
64+
}
65+
66+
tags = {
67+
"tag-key-1" = "tag-value-1"
68+
"tag-key-2" = "tag-value-2"
69+
"tag-key-2_update" = "tag-value-2_update"
70+
}
71+
72+
# not supported by api
73+
# storage = 64
74+
# client_ip = "1.1.1.1"
75+
# deprecated = "false"
76+
# identity = "identity"
77+
# memory = 32
78+
# prepare_power_off_time = "undocumented format"
79+
# prepare_power_off_counter = 2
80+
# thread = 1
81+
# cluster_id = "1" conflict
82+
# cpu = 2
83+
# edgeviewconfig {
84+
# # optional
85+
# app_policy {
86+
# # optional
87+
# allow_app = false
88+
# }
89+
# dev_policy {
90+
# # optional
91+
# allow_dev = false
92+
# }
93+
# ext_policy {
94+
# # optional
95+
# allow_ext = false
96+
# }
97+
# generation_id = 0
98+
# jwt_info {
99+
# # optional
100+
# allow_sec = 1
101+
# disp_url = "http://localhost"
102+
# encrypt = false
103+
# expire_sec = "6000"
104+
# num_inst = 1
105+
# }
106+
# # token = "token"
107+
# }
108+
# dlisp {
109+
# e_id = "e id"
110+
# e_id_hash_len = 1
111+
# client_addr = ""
112+
# eid_allocation_prefix = "prefix"
113+
# eid_allocation_prefix_len = 0
114+
# lisp_instance = 0
115+
# lisp_map_servers {
116+
# name_or_ip = "string"
117+
# credential = "string"
118+
# }
119+
# mode = ""
120+
# zed_servers {
121+
# host_name = "hostname"
122+
# e_id = [
123+
# "string"
124+
# ]
125+
# }
126+
# }
127+
}
128+
129+
# default_net_inst {
130+
# id = ""
131+
# name = "default-test-network"
132+
# }
133+
134+
# default_net_inst {
135+
# # required
136+
# device_id = "default_net_inst-device_id"
137+
# # device_id = data.zedcloud_edgenode.Data-Sample-Device.id
138+
# kind = "NETWORK_INSTANCE_KIND_LOCAL"
139+
# name = "default_net_inst-name"
140+
# port = "eth1"
141+
# title = "default_net_inst-test_tf_provider-config"
142+
143+
# # optional
144+
# project_id = "default-project"
145+
# network_policy_id = "tft-test-network-policy-id"
146+
# port_tags = {
147+
# "port-tag1" = "port-tag-value-1"
148+
# "port-tag2" = "port-tag-value-2"
149+
# }
150+
# tags = {
151+
# "ni-tag1" = "ni-tag-value-1"
152+
# "ni-tag2" = "ni-tag-value-2"
153+
# }
154+
# type = "NETWORK_INSTANCE_DHCP_TYPE_V4"
155+
# description = "default_net_inst-description"
156+
# device_default = false
157+
# # dhcp = true
158+
# dns_list {
159+
# addrs = [
160+
# "10.1.1.1",
161+
# "10.1.1.2"
162+
# ]
163+
# hostname = "wwww.ns1.example.com"
164+
# }
165+
# dns_list {
166+
# addrs = [
167+
# "10.1.2.1",
168+
# "10.1.2.2"
169+
# ]
170+
# hostname = "wwww.ns2.example.com"
171+
# }
172+
# ip {
173+
# # optional
174+
# dhcp_range {
175+
# end = "10.10.1.0"
176+
# start = "10.10.1.255"
177+
# }
178+
# dns = [
179+
# "www.ns1.example.com",
180+
# "www.ns2.example.com"
181+
# ]
182+
# domain = "example.com"
183+
# gateway = "10.1.0.1"
184+
# mask = "255.255.255.0"
185+
# ntp = "10.1.0.2"
186+
# subnet = "10.1.0.0"
187+
# }
188+
# lisp {
189+
# # optional
190+
# allocate = false
191+
# allocationprefix = ""
192+
# allocationprefixlen = 0
193+
# exportprivate = false
194+
# lispiid = 0
195+
# sp {}
196+
# }
197+
# oconfig = ""
198+
# opaque {
199+
# oconfig = "test config"
200+
# type = "OPAQUE_CONFIG_TYPE_UNSPECIFIED"
201+
# }
202+
# opaque {
203+
# # required
204+
# device_id = ""
205+
# kind = ""
206+
# name = ""
207+
# port = ""
208+
# title = ""
209+
210+
# # optional
211+
# cluster_id = ""
212+
# description = ""
213+
# device_default = ""
214+
# dhcp = false
215+
# dns_list {}
216+
# ip {
217+
# # optional
218+
# dhcp_range {
219+
# # optional
220+
# end = ""
221+
# start = ""
222+
# }
223+
# dns {}
224+
# domain = ""
225+
# gateway = ""
226+
# mask = ""
227+
# ntp = ""
228+
# subnet = ""
229+
# }
230+
# # lisp = # LispConfig
231+
# network_policy_id = ""
232+
# oconfig = ""
233+
# # opaque =
234+
# port_tags {}
235+
# project_id = ""
236+
# tags {}
237+
# type = ""
238+
# }
239+
# }

0 commit comments

Comments
 (0)