@@ -61,63 +61,119 @@ func TestAccResourceContainer(t *testing.T) {
61
61
name string
62
62
step []resource.TestStep
63
63
}{
64
- {"create and start container" , []resource.TestStep {{
65
- Config : te .RenderConfig (`
66
- resource "proxmox_virtual_environment_container" "test_container" {
67
- node_name = "{{.NodeName}}"
68
- vm_id = {{.TestContainerID}}
69
- disk {
70
- datastore_id = "local-lvm"
71
- size = 4
72
- }
73
- mount_point {
74
- volume = "local-lvm"
75
- size = "4G"
76
- path = "mnt/local"
77
- }
78
- device_passthrough {
79
- path = "/dev/zero"
80
- }
81
- description = <<-EOT
82
- my
83
- description
84
- value
85
- EOT
86
- initialization {
87
- hostname = "test"
88
- ip_config {
89
- ipv4 {
90
- address = "dhcp"
64
+ {"create, start and update container" , []resource.TestStep {
65
+ {
66
+ Config : te .RenderConfig (`
67
+ resource "proxmox_virtual_environment_container" "test_container" {
68
+ node_name = "{{.NodeName}}"
69
+ vm_id = {{.TestContainerID}}
70
+ timeout_delete = 10
71
+ unprivileged = true
72
+ disk {
73
+ datastore_id = "local-lvm"
74
+ size = 4
75
+ }
76
+ mount_point {
77
+ volume = "local-lvm"
78
+ size = "4G"
79
+ path = "mnt/local"
80
+ }
81
+ device_passthrough {
82
+ path = "/dev/zero"
83
+ }
84
+ description = <<-EOT
85
+ my
86
+ description
87
+ value
88
+ EOT
89
+ initialization {
90
+ hostname = "test"
91
+ ip_config {
92
+ ipv4 {
93
+ address = "dhcp"
94
+ }
91
95
}
92
96
}
93
- }
94
- network_interface {
95
- name = "vmbr0"
96
- }
97
- operating_system {
98
- template_file_id = "local:vztmpl/{{.ImageFileName}}"
99
- type = "ubuntu"
100
- }
101
- }` , WithRootUser ()),
102
- Check : resource .ComposeTestCheckFunc (
103
- resource .TestCheckResourceAttr (accTestContainerName , "description" , "my\n description\n value\n " ),
104
- resource .TestCheckResourceAttr (accTestContainerName , "device_passthrough.#" , "1" ),
105
- func (* terraform.State ) error {
106
- ctx , cancel := context .WithTimeout (context .Background (), 10 * time .Second )
107
- defer cancel ()
97
+ network_interface {
98
+ name = "vmbr0"
99
+ }
100
+ operating_system {
101
+ template_file_id = "local:vztmpl/{{.ImageFileName}}"
102
+ type = "ubuntu"
103
+ }
104
+ }` , WithRootUser ()),
105
+ Check : resource .ComposeTestCheckFunc (
106
+ ResourceAttributes (accTestContainerName , map [string ]string {
107
+ "description" : "my\n description\n value\n " ,
108
+ "device_passthrough.#" : "1" ,
109
+ "initialization.0.dns.#" : "0" ,
110
+ }),
111
+ func (* terraform.State ) error {
112
+ ctx , cancel := context .WithTimeout (context .Background (), 10 * time .Second )
113
+ defer cancel ()
108
114
109
- ct := te .NodeClient ().Container (accTestContainerID )
110
- err := ct .WaitForContainerStatus (ctx , "running" )
111
- require .NoError (te .t , err , "container did not start" )
115
+ ct := te .NodeClient ().Container (accTestContainerID )
116
+ err := ct .WaitForContainerStatus (ctx , "running" )
117
+ require .NoError (te .t , err , "container did not start" )
112
118
113
- ctInfo , err := ct .GetContainer (ctx )
114
- require .NoError (te .t , err , "failed to get container" )
115
- require .NotNil (te .t , ctInfo .DevicePassthrough0 )
119
+ ctInfo , err := ct .GetContainer (ctx )
120
+ require .NoError (te .t , err , "failed to get container" )
121
+ require .NotNil (te .t , ctInfo .DevicePassthrough0 )
116
122
117
- return nil
118
- },
119
- ),
120
- }}},
123
+ return nil
124
+ },
125
+ ),
126
+ },
127
+ {
128
+ Config : te .RenderConfig (`
129
+ resource "proxmox_virtual_environment_container" "test_container" {
130
+ node_name = "{{.NodeName}}"
131
+ vm_id = {{.TestContainerID}}
132
+ timeout_delete = 10
133
+ unprivileged = true
134
+ disk {
135
+ datastore_id = "local-lvm"
136
+ size = 4
137
+ }
138
+ mount_point {
139
+ volume = "local-lvm"
140
+ size = "4G"
141
+ path = "mnt/local"
142
+ }
143
+ device_passthrough {
144
+ path = "/dev/zero"
145
+ }
146
+ description = <<-EOT
147
+ my
148
+ description
149
+ value
150
+ EOT
151
+ initialization {
152
+ hostname = "test"
153
+ ip_config {
154
+ ipv4 {
155
+ address = "172.16.10.10/15"
156
+ gateway = "172.16.0.1"
157
+ }
158
+ }
159
+ }
160
+ network_interface {
161
+ name = "vmbr0"
162
+ }
163
+ operating_system {
164
+ template_file_id = "local:vztmpl/{{.ImageFileName}}"
165
+ type = "ubuntu"
166
+ }
167
+ }` , WithRootUser ()),
168
+ Check : resource .ComposeTestCheckFunc (
169
+ ResourceAttributes (accTestContainerName , map [string ]string {
170
+ "description" : "my\n description\n value\n " ,
171
+ "device_passthrough.#" : "1" ,
172
+ "initialization.0.dns.#" : "0" ,
173
+ }),
174
+ ),
175
+ },
176
+ }},
121
177
{"update mount points" , []resource.TestStep {
122
178
{
123
179
Config : te .RenderConfig (`
0 commit comments