mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-05 05:24:01 +00:00
chore: refactor container acc test (#1408)
+ beautify test output on CI --------- Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
c926484249
commit
a0d9300f0f
14
.github/workflows/test.yml
vendored
14
.github/workflows/test.yml
vendored
@ -73,11 +73,21 @@ jobs:
|
|||||||
if: ${{ steps.filter.outputs.go == 'true' }}
|
if: ${{ steps.filter.outputs.go == 'true' }}
|
||||||
run: go mod download
|
run: go mod download
|
||||||
|
|
||||||
|
- name: Set up gotestfmt
|
||||||
|
run: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
|
||||||
|
|
||||||
- name: Unit tests
|
- name: Unit tests
|
||||||
if: ${{ steps.filter.outputs.go == 'true' }}
|
if: ${{ steps.filter.outputs.go == 'true' }}
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
run: go test -v -cover ./...
|
run: go test -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt -hide empty-packages
|
||||||
|
|
||||||
|
- name: Upload test log
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
name: test-log
|
||||||
|
path: /tmp/gotest.log
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
- name: Check for uncommitted changes in generated docs
|
- name: Check for uncommitted changes in generated docs
|
||||||
run: make docs && git diff --exit-code
|
run: make docs && git diff --exit-code
|
||||||
|
|
||||||
|
11
.github/workflows/testacc.yml
vendored
11
.github/workflows/testacc.yml
vendored
@ -69,4 +69,13 @@ jobs:
|
|||||||
PROXMOX_VE_ACC_NODE_SSH_PORT: ${{ matrix.port }}
|
PROXMOX_VE_ACC_NODE_SSH_PORT: ${{ matrix.port }}
|
||||||
PROXMOX_VE_ACC_CLOUD_IMAGES_SERVER: ${{ secrets.PROXMOX_VE_ACC_CLOUD_IMAGES_SERVER }}
|
PROXMOX_VE_ACC_CLOUD_IMAGES_SERVER: ${{ secrets.PROXMOX_VE_ACC_CLOUD_IMAGES_SERVER }}
|
||||||
PROXMOX_VE_ACC_CONTAINER_IMAGES_SERVER: ${{ secrets.PROXMOX_VE_ACC_CONTAINER_IMAGES_SERVER }}
|
PROXMOX_VE_ACC_CONTAINER_IMAGES_SERVER: ${{ secrets.PROXMOX_VE_ACC_CONTAINER_IMAGES_SERVER }}
|
||||||
run: make testacc
|
run:
|
||||||
|
go test -json --timeout=30m --tags=acceptance -count=1 -v github.com/bpg/terraform-provider-proxmox/fwprovider/... 2>&1 | tee /tmp/gotest.log | gotestfmt -hide empty-packages
|
||||||
|
|
||||||
|
- name: Upload test log
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
name: test-log
|
||||||
|
path: /tmp/gotest.log
|
||||||
|
if-no-files-found: error
|
||||||
|
@ -11,14 +11,14 @@ issues:
|
|||||||
- EXC0012
|
- EXC0012
|
||||||
- EXC0014
|
- EXC0014
|
||||||
exclude-rules:
|
exclude-rules:
|
||||||
# Exclude duplicate code and function length and complexity checking in test
|
# Exclude some checks in tests
|
||||||
# files (due to common repeats and long functions in test code)
|
|
||||||
- path: _(test|gen)\.go
|
- path: _(test|gen)\.go
|
||||||
linters:
|
linters:
|
||||||
- cyclop
|
- cyclop
|
||||||
- dupl
|
- dupl
|
||||||
- gocognit
|
|
||||||
- funlen
|
- funlen
|
||||||
|
- gocognit
|
||||||
|
- gosec
|
||||||
- lll
|
- lll
|
||||||
- path: _types\.go
|
- path: _types\.go
|
||||||
linters:
|
linters:
|
||||||
|
2
Makefile
2
Makefile
@ -95,7 +95,7 @@ test:
|
|||||||
.PHONY: testacc
|
.PHONY: testacc
|
||||||
testacc:
|
testacc:
|
||||||
@# explicitly add TF_ACC=1 to trigger the acceptance tests, `testacc.env` might be missing or incomplete
|
@# explicitly add TF_ACC=1 to trigger the acceptance tests, `testacc.env` might be missing or incomplete
|
||||||
@TF_ACC=1 env $$(cat testacc.env | xargs) go test --timeout=30m -count=1 -v github.com/bpg/terraform-provider-proxmox/fwprovider/...
|
@TF_ACC=1 env $$(cat testacc.env | xargs) go test --timeout=30m --tags=acceptance -count=1 -v github.com/bpg/terraform-provider-proxmox/fwprovider/...
|
||||||
|
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
lint:
|
lint:
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//go:build acceptance || all
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//go:build acceptance || all
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//go:build acceptance || all
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//go:build acceptance || all
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//go:build acceptance || all
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//go:build acceptance || all
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//go:build acceptance || all
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//go:build acceptance || all
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//go:build acceptance || all
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//go:build acceptance || all
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
@ -13,101 +15,88 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/brianvoe/gofakeit/v7"
|
||||||
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
|
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
|
||||||
"github.com/hashicorp/terraform-plugin-testing/terraform"
|
"github.com/hashicorp/terraform-plugin-testing/terraform"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/bpg/terraform-provider-proxmox/proxmox/helpers/ptr"
|
||||||
|
"github.com/bpg/terraform-provider-proxmox/proxmox/nodes/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
accTestContainerName = "proxmox_virtual_environment_container.test_container"
|
accTestContainerName = "proxmox_virtual_environment_container.test_container"
|
||||||
)
|
)
|
||||||
|
|
||||||
//nolint:gochecknoglobals
|
func TestAccResourceContainer(t *testing.T) {
|
||||||
var (
|
t.Parallel()
|
||||||
accTestContainerID = 100000 + rand.Intn(99999) //nolint:gosec
|
|
||||||
accCloneContainerID = 200000 + rand.Intn(99999) //nolint:gosec
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestAccResourceContainer(t *testing.T) { //nolint:wsl
|
|
||||||
// download fails with 404 or "exit code 8" if run in parallel
|
|
||||||
// t.Parallel()
|
|
||||||
|
|
||||||
te := InitEnvironment(t)
|
te := InitEnvironment(t)
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
imageFileName := gofakeit.Word() + "-ubuntu-23.04-standard_23.04-1_amd64.tar.zst"
|
||||||
ProtoV6ProviderFactories: te.AccProviders,
|
accTestContainerID := 100000 + rand.Intn(99999)
|
||||||
Steps: []resource.TestStep{
|
accTestContainerIDClone := 100000 + rand.Intn(99999)
|
||||||
{
|
|
||||||
Config: te.RenderConfig(testAccResourceContainerCreateConfig(te, false)),
|
te.AddTemplateVars(map[string]interface{}{
|
||||||
Check: testAccResourceContainerCreateCheck(te),
|
"ImageFileName": imageFileName,
|
||||||
},
|
"TestContainerID": accTestContainerID,
|
||||||
{
|
"TestContainerIDClone": accTestContainerIDClone,
|
||||||
Config: te.RenderConfig(testAccResourceContainerCreateConfig(te, true) + testAccResourceContainerCreateCloneConfig(te)),
|
|
||||||
Check: testAccResourceContainerCreateCloneCheck(te),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
func testAccResourceContainerCreateConfig(te *Environment, isTemplate bool) string {
|
err := te.NodeStorageClient().DownloadFileByURL(context.Background(), &storage.DownloadURLPostRequestBody{
|
||||||
te.t.Helper()
|
Content: ptr.Ptr("vztmpl"),
|
||||||
|
FileName: ptr.Ptr(imageFileName),
|
||||||
|
Node: ptr.Ptr(te.NodeName),
|
||||||
|
Storage: ptr.Ptr(te.DatastoreID),
|
||||||
|
URL: ptr.Ptr(fmt.Sprintf("%s/images/system/ubuntu-23.04-standard_23.04-1_amd64.tar.zst", te.ContainerImagesServer)),
|
||||||
|
})
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
return fmt.Sprintf(`
|
t.Cleanup(func() {
|
||||||
resource "proxmox_virtual_environment_download_file" "ubuntu_container_template" {
|
e := te.NodeStorageClient().DeleteDatastoreFile(context.Background(), fmt.Sprintf("vztmpl/%s", imageFileName))
|
||||||
content_type = "vztmpl"
|
require.NoError(t, e)
|
||||||
datastore_id = "local"
|
})
|
||||||
node_name = "{{.NodeName}}"
|
|
||||||
url = "{{.ContainerImagesServer}}/images/system/ubuntu-23.04-standard_23.04-1_amd64.tar.zst"
|
tests := []struct {
|
||||||
overwrite_unmanaged = true
|
name string
|
||||||
}
|
step []resource.TestStep
|
||||||
|
}{
|
||||||
|
{"crete and start container", []resource.TestStep{{
|
||||||
|
Config: te.RenderConfig(`
|
||||||
resource "proxmox_virtual_environment_container" "test_container" {
|
resource "proxmox_virtual_environment_container" "test_container" {
|
||||||
node_name = "{{.NodeName}}"
|
node_name = "{{.NodeName}}"
|
||||||
vm_id = %d
|
vm_id = {{.TestContainerID}}
|
||||||
template = %t
|
|
||||||
|
|
||||||
disk {
|
disk {
|
||||||
datastore_id = "local-lvm"
|
datastore_id = "local-lvm"
|
||||||
size = 4
|
size = 4
|
||||||
}
|
}
|
||||||
|
|
||||||
mount_point {
|
mount_point {
|
||||||
volume = "local-lvm"
|
volume = "local-lvm"
|
||||||
size = "4G"
|
size = "4G"
|
||||||
path = "mnt/local"
|
path = "mnt/local"
|
||||||
}
|
}
|
||||||
|
|
||||||
description = <<-EOT
|
description = <<-EOT
|
||||||
my
|
my
|
||||||
description
|
description
|
||||||
value
|
value
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
initialization {
|
initialization {
|
||||||
hostname = "test"
|
hostname = "test"
|
||||||
|
|
||||||
ip_config {
|
ip_config {
|
||||||
ipv4 {
|
ipv4 {
|
||||||
address = "dhcp"
|
address = "dhcp"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
network_interface {
|
network_interface {
|
||||||
name = "vmbr0"
|
name = "vmbr0"
|
||||||
}
|
}
|
||||||
|
|
||||||
operating_system {
|
operating_system {
|
||||||
template_file_id = proxmox_virtual_environment_download_file.ubuntu_container_template.id
|
template_file_id = "local:vztmpl/{{.ImageFileName}}"
|
||||||
type = "ubuntu"
|
type = "ubuntu"
|
||||||
}
|
}
|
||||||
}
|
}`),
|
||||||
`, accTestContainerID, isTemplate)
|
Check: resource.ComposeTestCheckFunc(
|
||||||
}
|
|
||||||
|
|
||||||
func testAccResourceContainerCreateCheck(te *Environment) resource.TestCheckFunc {
|
|
||||||
te.t.Helper()
|
|
||||||
|
|
||||||
return resource.ComposeTestCheckFunc(
|
|
||||||
resource.TestCheckResourceAttr(accTestContainerName, "description", "my\ndescription\nvalue\n"),
|
resource.TestCheckResourceAttr(accTestContainerName, "description", "my\ndescription\nvalue\n"),
|
||||||
func(*terraform.State) error {
|
func(*terraform.State) error {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
@ -118,17 +107,127 @@ func testAccResourceContainerCreateCheck(te *Environment) resource.TestCheckFunc
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
)
|
),
|
||||||
|
}}},
|
||||||
|
{"update mount points", []resource.TestStep{
|
||||||
|
{
|
||||||
|
SkipFunc: func() (bool, error) {
|
||||||
|
// mount point deletion: https://github.com/bpg/terraform-provider-proxmox/issues/1392
|
||||||
|
return true, nil
|
||||||
|
},
|
||||||
|
Config: te.RenderConfig(`
|
||||||
|
resource "proxmox_virtual_environment_container" "test_container" {
|
||||||
|
node_name = "{{.NodeName}}"
|
||||||
|
vm_id = {{.RandomVMID}}
|
||||||
|
started = false
|
||||||
|
disk {
|
||||||
|
datastore_id = "local-lvm"
|
||||||
|
size = 4
|
||||||
|
}
|
||||||
|
mount_point {
|
||||||
|
volume = "local-lvm"
|
||||||
|
size = "4G"
|
||||||
|
path = "mnt/local1"
|
||||||
|
}
|
||||||
|
mount_point {
|
||||||
|
volume = "local"
|
||||||
|
size = "8G"
|
||||||
|
path = "mnt/local2"
|
||||||
|
}
|
||||||
|
initialization {
|
||||||
|
hostname = "test"
|
||||||
|
ip_config {
|
||||||
|
ipv4 {
|
||||||
|
address = "dhcp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
network_interface {
|
||||||
|
name = "vmbr0"
|
||||||
|
}
|
||||||
|
operating_system {
|
||||||
|
template_file_id = "local:vztmpl/{{.ImageFileName}}"
|
||||||
|
type = "ubuntu"
|
||||||
|
}
|
||||||
|
}`),
|
||||||
|
Check: ResourceAttributes("proxmox_virtual_environment_container.test_container", map[string]string{
|
||||||
|
"mount_point.#": "2",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
SkipFunc: func() (bool, error) {
|
||||||
|
// mount point deletion: https://github.com/bpg/terraform-provider-proxmox/issues/1392
|
||||||
|
return true, nil
|
||||||
|
},
|
||||||
|
Config: te.RenderConfig(`
|
||||||
|
resource "proxmox_virtual_environment_container" "test_container" {
|
||||||
|
node_name = "{{.NodeName}}"
|
||||||
|
started = false
|
||||||
|
disk {
|
||||||
|
datastore_id = "local-lvm"
|
||||||
|
size = 4
|
||||||
|
}
|
||||||
|
mount_point {
|
||||||
|
volume = "local-lvm"
|
||||||
|
size = "4G"
|
||||||
|
path = "mnt/local1"
|
||||||
|
}
|
||||||
|
initialization {
|
||||||
|
hostname = "test"
|
||||||
|
ip_config {
|
||||||
|
ipv4 {
|
||||||
|
address = "dhcp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
network_interface {
|
||||||
|
name = "vmbr0"
|
||||||
|
}
|
||||||
|
operating_system {
|
||||||
|
template_file_id = "local:vztmpl/{{.ImageFileName}}"
|
||||||
|
type = "ubuntu"
|
||||||
|
}
|
||||||
|
}`),
|
||||||
|
Check: ResourceAttributes("proxmox_virtual_environment_container.test_container", map[string]string{
|
||||||
|
"mount_point.#": "2",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
{"clone container", []resource.TestStep{{
|
||||||
|
Config: te.RenderConfig(`
|
||||||
|
resource "proxmox_virtual_environment_container" "test_container" {
|
||||||
|
node_name = "{{.NodeName}}"
|
||||||
|
vm_id = {{.RandomVMID}}
|
||||||
|
template = true
|
||||||
|
disk {
|
||||||
|
datastore_id = "local-lvm"
|
||||||
|
size = 4
|
||||||
|
}
|
||||||
|
mount_point {
|
||||||
|
volume = "local-lvm"
|
||||||
|
size = "4G"
|
||||||
|
path = "mnt/local"
|
||||||
|
}
|
||||||
|
initialization {
|
||||||
|
hostname = "test"
|
||||||
|
ip_config {
|
||||||
|
ipv4 {
|
||||||
|
address = "dhcp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
network_interface {
|
||||||
|
name = "vmbr0"
|
||||||
|
}
|
||||||
|
operating_system {
|
||||||
|
template_file_id = "local:vztmpl/{{.ImageFileName}}"
|
||||||
|
type = "ubuntu"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccResourceContainerCreateCloneConfig(te *Environment) string {
|
|
||||||
te.t.Helper()
|
|
||||||
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
resource "proxmox_virtual_environment_container" "test_container_clone" {
|
resource "proxmox_virtual_environment_container" "test_container_clone" {
|
||||||
depends_on = [proxmox_virtual_environment_container.test_container]
|
depends_on = [proxmox_virtual_environment_container.test_container]
|
||||||
node_name = "{{.NodeName}}"
|
node_name = "{{.NodeName}}"
|
||||||
vm_id = %d
|
vm_id = {{.TestContainerIDClone}}
|
||||||
|
|
||||||
clone {
|
clone {
|
||||||
vm_id = proxmox_virtual_environment_container.test_container.id
|
vm_id = proxmox_virtual_environment_container.test_container.id
|
||||||
@ -137,22 +236,27 @@ resource "proxmox_virtual_environment_container" "test_container_clone" {
|
|||||||
initialization {
|
initialization {
|
||||||
hostname = "test-clone"
|
hostname = "test-clone"
|
||||||
}
|
}
|
||||||
}
|
}`),
|
||||||
`, accCloneContainerID)
|
Check: resource.ComposeTestCheckFunc(
|
||||||
}
|
|
||||||
|
|
||||||
func testAccResourceContainerCreateCloneCheck(te *Environment) resource.TestCheckFunc {
|
|
||||||
te.t.Helper()
|
|
||||||
|
|
||||||
return resource.ComposeTestCheckFunc(
|
|
||||||
func(*terraform.State) error {
|
func(*terraform.State) error {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
err := te.NodeClient().Container(accCloneContainerID).WaitForContainerStatus(ctx, "running")
|
err := te.NodeClient().Container(accTestContainerIDClone).WaitForContainerStatus(ctx, "running")
|
||||||
require.NoError(te.t, err, "container did not start")
|
require.NoError(te.t, err, "container did not start")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
)
|
),
|
||||||
|
}}},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
resource.ParallelTest(t, resource.TestCase{
|
||||||
|
ProtoV6ProviderFactories: te.AccProviders,
|
||||||
|
Steps: tt.step,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//go:build acceptance || all
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//go:build acceptance || all
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//go:build acceptance || all
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//go:build acceptance || all
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//go:build acceptance || all
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//go:build acceptance || all
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
package test
|
package test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -39,6 +45,8 @@ type Environment struct {
|
|||||||
AccProviders map[string]func() (tfprotov6.ProviderServer, error)
|
AccProviders map[string]func() (tfprotov6.ProviderServer, error)
|
||||||
once sync.Once
|
once sync.Once
|
||||||
c api.Client
|
c api.Client
|
||||||
|
CloudImagesServer string
|
||||||
|
ContainerImagesServer string
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitEnvironment initializes a new test environment for acceptance tests.
|
// InitEnvironment initializes a new test environment for acceptance tests.
|
||||||
@ -101,6 +109,8 @@ provider "proxmox" {
|
|||||||
NodeName: nodeName,
|
NodeName: nodeName,
|
||||||
DatastoreID: datastoreID,
|
DatastoreID: datastoreID,
|
||||||
AccProviders: muxProviders(t),
|
AccProviders: muxProviders(t),
|
||||||
|
CloudImagesServer: cloudImagesServer,
|
||||||
|
ContainerImagesServer: containerImagesServer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//go:build acceptance || all
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
//go:build acceptance || all
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
package cpu_test
|
package cpu_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//go:build acceptance || all
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
//go:build acceptance || all
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
package vga_test
|
package vga_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2831,13 +2831,15 @@ func containerUpdate(ctx context.Context, d *schema.ResourceData, m interface{})
|
|||||||
|
|
||||||
// Prepare the new mount point configuration.
|
// Prepare the new mount point configuration.
|
||||||
if d.HasChange(mkMountPoint) {
|
if d.HasChange(mkMountPoint) {
|
||||||
mountPoint := d.Get(mkMountPoint).([]interface{})
|
_, newMountPoints := d.GetChange(mkMountPoint)
|
||||||
|
|
||||||
|
mountPoints := newMountPoints.([]interface{})
|
||||||
mountPointArray := make(
|
mountPointArray := make(
|
||||||
containers.CustomMountPointArray,
|
containers.CustomMountPointArray,
|
||||||
len(mountPoint),
|
len(mountPoints),
|
||||||
)
|
)
|
||||||
|
|
||||||
for i, mp := range mountPoint {
|
for i, mp := range mountPoints {
|
||||||
mountPointMap := mp.(map[string]interface{})
|
mountPointMap := mp.(map[string]interface{})
|
||||||
mountPointObject := containers.CustomMountPoint{}
|
mountPointObject := containers.CustomMountPoint{}
|
||||||
|
|
||||||
@ -2861,7 +2863,7 @@ func containerUpdate(ctx context.Context, d *schema.ResourceData, m interface{})
|
|||||||
mountPointObject.Volume = volume
|
mountPointObject.Volume = volume
|
||||||
|
|
||||||
if len(mountOptions) > 0 {
|
if len(mountOptions) > 0 {
|
||||||
mountOptionsArray := make([]string, 0, len(mountPoint))
|
mountOptionsArray := make([]string, 0, len(mountPoints))
|
||||||
|
|
||||||
for _, option := range mountOptions {
|
for _, option := range mountOptions {
|
||||||
mountOptionsArray = append(mountOptionsArray, option.(string))
|
mountOptionsArray = append(mountOptionsArray, option.(string))
|
||||||
@ -3040,7 +3042,7 @@ func containerUpdate(ctx context.Context, d *schema.ResourceData, m interface{})
|
|||||||
}
|
}
|
||||||
|
|
||||||
// As a final step in the update procedure, we might need to reboot the container.
|
// As a final step in the update procedure, we might need to reboot the container.
|
||||||
if !bool(template) && rebootRequired {
|
if !bool(template) && started && rebootRequired {
|
||||||
rebootTimeout := 300
|
rebootTimeout := 300
|
||||||
|
|
||||||
e = containerAPI.RebootContainer(
|
e = containerAPI.RebootContainer(
|
||||||
|
Loading…
Reference in New Issue
Block a user