Skip to content

Commit 958ce3f

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/ - iaas_clients tests explicitly pass the vCenter's certificate, the integration/iaas_cli/ specs previously were not run on windows and on linux they rely on test setup which adds the certificate to the container's certificate store; the specs now write the certificate to disk and pass this path to vcenterclientfactory.FactoryConfig, as the - "contract tests" use vcsim as library, instead of building from source, this should allow testing on windows - (more) test code uses "_test" package names
1 parent 5bc8d2c commit 958ce3f

File tree

135 files changed

+100994
-406
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+100994
-406
lines changed

ci/pipelines/stemcells-windows.yml

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,6 @@ resources:
165165
type: git
166166
source:
167167
uri: https://github.com/cloudfoundry/windows-utilities-release.git
168-
- name: govmomi
169-
type: git
170-
source:
171-
uri: https://github.com/vmware/govmomi.git
172168

173169
# type: docker-image
174170
- name: bosh-windows-stemcell-builder-ci-docker-image
@@ -865,13 +861,19 @@ jobs:
865861
file: bosh-windows-stemcell-builder-ci/ci/tasks/test-integration-stembuild-windows/task.yml
866862
timeout: 3h
867863
params:
868-
VCENTER_BASE_URL: ((nimbus_windows-demo_base_url))
864+
CONTRACT_TEST_VM_NAME: stembuild_base_vm_2019_
865+
CONTRACT_TEST_VM_PASSWORD: ((stembuild_vm_user.password))
866+
CONTRACT_TEST_VM_USERNAME: ((stembuild_vm_user.username))
867+
869868
GOVC_DATASTORE: ((nimbus_windows-demo_ds))
870869
GOVC_NETWORK: internal-network
871870
GOVC_RESOURCE_POOL: /dc0/host/concourse_cluster/Resources
871+
872872
VCENTER_ADMIN_CREDENTIAL_URL: ((nimbus_windows-demo_auth_url))
873+
VCENTER_BASE_URL: ((nimbus_windows-demo_base_url))
873874
VCENTER_USERNAME: ((nimbus_windows-demo_user.username))
874875
VCENTER_PASSWORD: ((nimbus_windows-demo_user.password))
876+
875877
VM_FOLDER: /dc0/vm/bosh-windows-ci-vms-and-templates
876878
VM_USERNAME: ((stembuild_vm_user.username))
877879
VM_PASSWORD: ((stembuild_vm_user.password))
@@ -936,7 +938,6 @@ jobs:
936938
- get: blobstore-gcs-cli
937939
- get: windows-bsdtar
938940
- get: windows-winsw
939-
- get: govmomi
940941
- put: version
941942
inputs: detect
942943
resource: stembuild-linux-build-number
@@ -955,20 +956,6 @@ jobs:
955956
- task: unit-test
956957
file: bosh-windows-stemcell-builder-ci/ci/tasks/test-units-stembuild-linux/task.yml
957958
image: bosh-windows-stemcell-builder-ci-image
958-
- task: contract-test
959-
file: bosh-windows-stemcell-builder-ci/ci/tasks/test-contract-stembuild-linux/task.yml
960-
image: bosh-windows-stemcell-builder-ci-image
961-
tags: [windows-nimbus]
962-
params:
963-
VCENTER_ADMIN_CREDENTIAL_URL: ((nimbus_windows-demo_auth_url))
964-
VM_FOLDER: /dc0/vm/bosh-windows-ci-vms-and-templates
965-
PACKAGE_TEST_VM_NAME: stembuild-package-integration-tests-base-vm
966-
VCENTER_BASE_URL: ((nimbus_windows-demo_base_url))
967-
VCENTER_USERNAME: ((nimbus_windows-demo_user.username))
968-
VCENTER_PASSWORD: ((nimbus_windows-demo_user.password))
969-
CONTRACT_TEST_VM_NAME: stembuild_base_vm_2019_
970-
CONTRACT_TEST_VM_PASSWORD: ((stembuild_vm_user.password))
971-
CONTRACT_TEST_VM_USERNAME: ((stembuild_vm_user.username))
972959
- task: setup-integration-test-vm
973960
file: bosh-windows-stemcell-builder-ci/ci/tasks/setup-integration-test-vm/task.yml
974961
image: bosh-windows-stemcell-builder-ci-image
@@ -994,13 +981,19 @@ jobs:
994981
tags: [windows-nimbus]
995982
timeout: 3h
996983
params:
997-
VCENTER_BASE_URL: ((nimbus_windows-demo_base_url))
984+
CONTRACT_TEST_VM_NAME: stembuild_base_vm_2019_
985+
CONTRACT_TEST_VM_PASSWORD: ((stembuild_vm_user.password))
986+
CONTRACT_TEST_VM_USERNAME: ((stembuild_vm_user.username))
987+
998988
GOVC_DATASTORE: ((nimbus_windows-demo_ds))
999989
GOVC_NETWORK: internal-network
1000990
GOVC_RESOURCE_POOL: /dc0/host/concourse_cluster/Resources
991+
1001992
VCENTER_ADMIN_CREDENTIAL_URL: ((nimbus_windows-demo_auth_url))
993+
VCENTER_BASE_URL: ((nimbus_windows-demo_base_url))
1002994
VCENTER_USERNAME: ((nimbus_windows-demo_user.username))
1003995
VCENTER_PASSWORD: ((nimbus_windows-demo_user.password))
996+
1004997
VM_FOLDER: /dc0/vm/bosh-windows-ci-vms-and-templates
1005998
VM_USERNAME: ((stembuild_vm_user.username))
1006999
VM_PASSWORD: ((stembuild_vm_user.password))

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

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

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

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

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,22 @@ set -x
44

55
ROOT_DIR=$(pwd)
66

7+
export OUTPUT_DIR="${ROOT_DIR}/output"
8+
79
VERSION=$(cat version/version)
8-
OUTPUT_DIR="${ROOT_DIR}/output"
10+
export STEMBUILD_VERSION="${VERSION}"
911

1012
source "bosh-windows-stemcell-builder-ci/ci/common-scripts/update_nimbus_urls_and_cert.sh"
1113

12-
echo '***Installing VMWare OVF Tools***'
13-
chmod +x ./ovftool/VMware-ovftool-4.2.0-5965791-lin.x86_64.bundle
14-
./ovftool/VMware-ovftool-4.2.0-5965791-lin.x86_64.bundle --eulas-agreed --required
14+
echo '---> Install VMWare OVF Tools'
15+
chmod +x "${ROOT_DIR}/ovftool/VMware-ovftool-4.2.0-5965791-lin.x86_64.bundle"
16+
"${ROOT_DIR}/ovftool/VMware-ovftool-4.2.0-5965791-lin.x86_64.bundle" --eulas-agreed --required
1517

16-
export STEMBUILD_VERSION
1718
export TARGET_VM_IP
18-
export VM_NAME
19-
20-
STEMBUILD_VERSION=$(cat version/version)
2119
TARGET_VM_IP=$(cat nimbus-ips/name)
20+
export VM_NAME
2221
VM_NAME=$(cat integration-vm-name/name)
23-
24-
echo "Using Existing VM IP/Name: ${TARGET_VM_IP}/${VM_NAME}"
22+
echo "Using VM @ IPAddr: ${VM_NAME}@${TARGET_VM_IP}"
2523

2624
pushd "${ROOT_DIR}/stemcell-builder/stembuild"
2725
echo '***Test Stembuild Code***'

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

stembuild/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ go 1.23.0
55
require (
66
github.com/concourse/pool-resource v1.1.1
77
github.com/google/subcommands v1.2.0
8-
github.com/google/uuid v1.6.0
98
github.com/masterzen/winrm v0.0.0-20240702205601-3fad6e106085
109
github.com/maxbrunsfeld/counterfeiter/v6 v6.11.3
1110
github.com/onsi/ginkgo/v2 v2.23.4
@@ -29,6 +28,7 @@ require (
2928
github.com/gofrs/uuid v4.4.0+incompatible // indirect
3029
github.com/google/go-cmp v0.7.0 // indirect
3130
github.com/google/pprof v0.0.0-20250630185457-6e76a2b096b5 // indirect
31+
github.com/google/uuid v1.6.0 // indirect
3232
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
3333
github.com/hashicorp/go-uuid v1.0.3 // indirect
3434
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
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: 1 addition & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,13 @@
1-
package iaas_clients
1+
package iaas_clients_test
22

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

106
. "github.com/onsi/ginkgo/v2"
117
. "github.com/onsi/gomega"
12-
"github.com/vmware/govmomi/object"
13-
14-
vcenterclientfactory "github.com/cloudfoundry/bosh-windows-stemcell-builder/stembuild/iaas_cli/iaas_clients/vcenter_manager"
158
)
169

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

0 commit comments

Comments
 (0)