Skip to content

Commit cbeb37b

Browse files
committed
stembuild: move integration-ish iaas_cli tests to integration
- some tests under iaas_cli/ can be run locally but not when mixed with specs which require access to vCenter or similar setup - moves tests which require external resources under integration/iaas_cli/ - moves test-contract-stembuild-linux task testing into integration task
1 parent d6d6fe8 commit cbeb37b

File tree

18 files changed

+264
-362
lines changed

18 files changed

+264
-362
lines changed

ci/pipelines/stemcells-windows.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -944,20 +944,6 @@ jobs:
944944
- task: unit-test
945945
file: bosh-windows-stemcell-builder-ci/ci/tasks/test-units-stembuild-linux/task.yml
946946
image: bosh-windows-stemcell-builder-ci-image
947-
- task: contract-test
948-
file: bosh-windows-stemcell-builder-ci/ci/tasks/test-contract-stembuild-linux/task.yml
949-
image: bosh-windows-stemcell-builder-ci-image
950-
tags: [windows-nimbus]
951-
params:
952-
VCENTER_ADMIN_CREDENTIAL_URL: ((nimbus_windows-demo_auth_url))
953-
VM_FOLDER: /dc0/vm/bosh-windows-ci-vms-and-templates
954-
PACKAGE_TEST_VM_NAME: stembuild-package-integration-tests-base-vm
955-
VCENTER_BASE_URL: ((nimbus_windows-demo_base_url))
956-
VCENTER_USERNAME: ((nimbus_windows-demo_user.username))
957-
VCENTER_PASSWORD: ((nimbus_windows-demo_user.password))
958-
CONTRACT_TEST_VM_NAME: stembuild_base_vm_2019_
959-
CONTRACT_TEST_VM_PASSWORD: ((stembuild_vm_user.password))
960-
CONTRACT_TEST_VM_USERNAME: ((stembuild_vm_user.username))
961947
- task: setup-integration-test-vm
962948
file: bosh-windows-stemcell-builder-ci/ci/tasks/setup-integration-test-vm/task.yml
963949
image: bosh-windows-stemcell-builder-ci-image
@@ -983,6 +969,10 @@ jobs:
983969
tags: [windows-nimbus]
984970
timeout: 3h
985971
params:
972+
CONTRACT_TEST_VM_NAME: stembuild_base_vm_2019_
973+
CONTRACT_TEST_VM_PASSWORD: ((stembuild_vm_user.password))
974+
CONTRACT_TEST_VM_USERNAME: ((stembuild_vm_user.username))
975+
986976
VCENTER_BASE_URL: ((nimbus_windows-demo_base_url))
987977
GOVC_DATASTORE: ((nimbus_windows-demo_ds))
988978
GOVC_NETWORK: internal-network

ci/tasks/test-contract-stembuild-linux/run.sh

100755100644
File mode changed.

ci/tasks/test-integration-stembuild-linux/run.sh

Lines changed: 0 additions & 29 deletions
This file was deleted.

ci/tasks/test-integration-stembuild-linux/task.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

ci/tasks/test-integration-stembuild-windows/run.ps1

Lines changed: 0 additions & 37 deletions
This file was deleted.

ci/tasks/test-integration-stembuild-windows/task.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

stembuild/Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ clean :
3434
rm -rf assets/StemcellAutomation.zip out/*
3535

3636
units : stubbed-stemcell-automation-zip
37-
go run github.com/onsi/ginkgo/v2/ginkgo run -r --randomize-all --randomize-suites --keep-going --skip-package integration,iaas_cli
38-
39-
iaas_cli :
40-
go run github.com/onsi/ginkgo/v2/ginkgo run -r --randomize-all --randomize-suites --keep-going --flake-attempts 2 iaas_cli
37+
go run github.com/onsi/ginkgo/v2/ginkgo run -r --randomize-all --randomize-suites --keep-going --skip-package integration
4138

4239
integration : stubbed-stemcell-automation-zip
4340
go run github.com/onsi/ginkgo/v2/ginkgo run -r --timeout 3h -vv --randomize-all --keep-going --flake-attempts 2 integration
Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package iaas_cli_test
22

33
import (
4-
"fmt"
5-
"os"
64
"testing"
75

86
. "github.com/onsi/ginkgo/v2"
@@ -13,18 +11,3 @@ func TestIaasCli(t *testing.T) {
1311
RegisterFailHandler(Fail)
1412
RunSpecs(t, "IaasCli Suite")
1513
}
16-
17-
var targetVMPath string
18-
var vCenterCredentialUrl string
19-
20-
var _ = BeforeSuite(func() {
21-
vCenterCredentialUrl = os.Getenv("VCENTER_ADMIN_CREDENTIAL_URL")
22-
Expect(vCenterCredentialUrl).NotTo(Equal(""), "VCENTER_ADMIN_CREDENTIAL_URL is required")
23-
24-
vmFolder := os.Getenv("VM_FOLDER")
25-
Expect(vmFolder).NotTo(Equal(""), "VM_FOLDER is required")
26-
vmName := os.Getenv("PACKAGE_TEST_VM_NAME")
27-
Expect(vmName).NotTo(Equal(""), "PACKAGE_TEST_VM_NAME is required")
28-
29-
targetVMPath = fmt.Sprintf("%s/%s", vmFolder, vmName)
30-
})
Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,13 @@
11
package iaas_clients
22

33
import (
4-
"context"
5-
"fmt"
6-
"os"
74
"testing"
8-
"time"
95

10-
"github.com/google/uuid"
116
. "github.com/onsi/ginkgo/v2"
127
. "github.com/onsi/gomega"
13-
"github.com/vmware/govmomi/object"
14-
15-
vcenterclientfactory "github.com/cloudfoundry/bosh-windows-stemcell-builder/stembuild/iaas_cli/iaas_clients/vcenter_manager"
168
)
179

1810
func TestIaasClients(t *testing.T) {
1911
RegisterFailHandler(Fail)
2012
RunSpecs(t, "IaasClients Suite")
2113
}
22-
23-
const (
24-
VcenterUrl = "VCENTER_BASE_URL"
25-
VcenterUsername = "VCENTER_USERNAME"
26-
VcenterPassword = "VCENTER_PASSWORD"
27-
VcenterCACert = "VCENTER_CA_CERT"
28-
VmFolder = "VM_FOLDER"
29-
TestVmName = "CONTRACT_TEST_VM_NAME"
30-
TestVmPassword = "CONTRACT_TEST_VM_PASSWORD"
31-
TestVmUsername = "CONTRACT_TEST_VM_USERNAME"
32-
)
33-
34-
var TestVmPath string
35-
var VM *object.VirtualMachine
36-
var CTX context.Context
37-
var _ = BeforeSuite(func() {
38-
39-
managerFactory := &vcenterclientfactory.ManagerFactory{Config: vcenterclientfactory.FactoryConfig{
40-
VCenterServer: envMustExist(VcenterUrl),
41-
Username: envMustExist(VcenterUsername),
42-
Password: envMustExist(VcenterPassword),
43-
ClientCreator: &vcenterclientfactory.ClientCreator{},
44-
FinderCreator: &vcenterclientfactory.GovmomiFinderCreator{},
45-
},
46-
}
47-
48-
CTX = context.TODO()
49-
50-
vCenterManager, err := managerFactory.VCenterManager(CTX)
51-
Expect(err).ToNot(HaveOccurred())
52-
53-
err = vCenterManager.Login(CTX)
54-
Expect(err).ToNot(HaveOccurred())
55-
56-
vmFolder := envMustExist(VmFolder)
57-
testVmName := envMustExist(TestVmName)
58-
testVmPath := fmt.Sprintf("%s/%s", vmFolder, testVmName)
59-
60-
vmToClone, err := vCenterManager.FindVM(CTX, testVmPath)
61-
Expect(err).ToNot(HaveOccurred())
62-
63-
TestVmPath = testVmPath + fmt.Sprintf("%s", uuid.New())[0:8] //nolint:staticcheck
64-
65-
err = vCenterManager.CloneVM(CTX, vmToClone, TestVmPath)
66-
Expect(err).ToNot(HaveOccurred())
67-
68-
time.Sleep(30 * time.Second)
69-
70-
VM, err = vCenterManager.FindVM(CTX, TestVmPath)
71-
Expect(err).ToNot(HaveOccurred())
72-
73-
})
74-
75-
var _ = AfterSuite(func() {
76-
77-
if VM != nil {
78-
task, err := VM.PowerOff(CTX)
79-
Expect(err).ToNot(HaveOccurred())
80-
err = task.WaitEx(CTX)
81-
Expect(err).ToNot(HaveOccurred())
82-
83-
task, err = VM.Destroy(CTX)
84-
Expect(err).ToNot(HaveOccurred())
85-
err = task.WaitEx(CTX)
86-
Expect(err).ToNot(HaveOccurred())
87-
}
88-
})
89-
90-
func envMustExist(variableName string) string {
91-
result := os.Getenv(variableName)
92-
if result == "" {
93-
Fail(fmt.Sprintf("%s must be set", variableName))
94-
}
95-
96-
return result
97-
}
Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
package vcenter_manager_test
22

33
import (
4-
"os"
5-
"os/exec"
6-
"path/filepath"
7-
"runtime"
84
"testing"
9-
"time"
105

116
. "github.com/onsi/ginkgo/v2"
127
. "github.com/onsi/gomega"
@@ -16,36 +11,3 @@ func TestVcenterManager(t *testing.T) {
1611
RegisterFailHandler(Fail)
1712
RunSpecs(t, "VcenterManager Suite")
1813
}
19-
20-
var (
21-
CertPath string
22-
cmd *exec.Cmd
23-
keyPath string
24-
)
25-
26-
var _ = BeforeSuite(func() {
27-
28-
if runtime.GOOS != "windows" {
29-
workingDir, err := os.Getwd()
30-
Expect(err).NotTo(HaveOccurred())
31-
CertPath = filepath.Join(workingDir, "..", "fixtures", "dummycert")
32-
keyPath = filepath.Join(workingDir, "..", "fixtures", "dummykey")
33-
34-
vcsimBinary := filepath.Join(os.Getenv("GOPATH"), "bin", "vcsim")
35-
36-
cmd = exec.Command(vcsimBinary, "-tlscert", CertPath, "-tlskey", keyPath)
37-
38-
err = cmd.Start()
39-
Expect(err).ToNot(HaveOccurred())
40-
41-
time.Sleep(3 * time.Second) // the vcsim server needs a moment to come up
42-
}
43-
44-
})
45-
46-
var _ = AfterSuite(func() {
47-
if runtime.GOOS != "windows" && cmd != nil {
48-
err := cmd.Process.Kill()
49-
Expect(err).ToNot(HaveOccurred())
50-
}
51-
})

0 commit comments

Comments
 (0)