Skip to content

Commit 36f2eef

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 d6d6fe8 commit 36f2eef

File tree

135 files changed

+101006
-418
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

+101006
-418
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
@@ -856,13 +852,19 @@ jobs:
856852
file: bosh-windows-stemcell-builder-ci/ci/tasks/test-integration-stembuild-windows/task.yml
857853
timeout: 3h
858854
params:
859-
VCENTER_BASE_URL: ((nimbus_windows-demo_base_url))
855+
CONTRACT_TEST_VM_NAME: stembuild_base_vm_2019_
856+
CONTRACT_TEST_VM_PASSWORD: ((stembuild_vm_user.password))
857+
CONTRACT_TEST_VM_USERNAME: ((stembuild_vm_user.username))
858+
860859
GOVC_DATASTORE: ((nimbus_windows-demo_ds))
861860
GOVC_NETWORK: internal-network
862861
GOVC_RESOURCE_POOL: /dc0/host/concourse_cluster/Resources
862+
863863
VCENTER_ADMIN_CREDENTIAL_URL: ((nimbus_windows-demo_auth_url))
864+
VCENTER_BASE_URL: ((nimbus_windows-demo_base_url))
864865
VCENTER_USERNAME: ((nimbus_windows-demo_user.username))
865866
VCENTER_PASSWORD: ((nimbus_windows-demo_user.password))
867+
866868
VM_FOLDER: /dc0/vm/bosh-windows-ci-vms-and-templates
867869
VM_USERNAME: ((stembuild_vm_user.username))
868870
VM_PASSWORD: ((stembuild_vm_user.password))
@@ -925,7 +927,6 @@ jobs:
925927
- get: blobstore-gcs-cli
926928
- get: windows-bsdtar
927929
- get: windows-winsw
928-
- get: govmomi
929930
- put: version
930931
inputs: detect
931932
resource: stembuild-linux-build-number
@@ -944,20 +945,6 @@ jobs:
944945
- task: unit-test
945946
file: bosh-windows-stemcell-builder-ci/ci/tasks/test-units-stembuild-linux/task.yml
946947
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))
961948
- task: setup-integration-test-vm
962949
file: bosh-windows-stemcell-builder-ci/ci/tasks/setup-integration-test-vm/task.yml
963950
image: bosh-windows-stemcell-builder-ci-image
@@ -983,13 +970,19 @@ jobs:
983970
tags: [windows-nimbus]
984971
timeout: 3h
985972
params:
986-
VCENTER_BASE_URL: ((nimbus_windows-demo_base_url))
973+
CONTRACT_TEST_VM_NAME: stembuild_base_vm_2019_
974+
CONTRACT_TEST_VM_PASSWORD: ((stembuild_vm_user.password))
975+
CONTRACT_TEST_VM_USERNAME: ((stembuild_vm_user.username))
976+
987977
GOVC_DATASTORE: ((nimbus_windows-demo_ds))
988978
GOVC_NETWORK: internal-network
989979
GOVC_RESOURCE_POOL: /dc0/host/concourse_cluster/Resources
980+
990981
VCENTER_ADMIN_CREDENTIAL_URL: ((nimbus_windows-demo_auth_url))
982+
VCENTER_BASE_URL: ((nimbus_windows-demo_base_url))
991983
VCENTER_USERNAME: ((nimbus_windows-demo_user.username))
992984
VCENTER_PASSWORD: ((nimbus_windows-demo_user.password))
985+
993986
VM_FOLDER: /dc0/vm/bosh-windows-ci-vms-and-templates
994987
VM_USERNAME: ((stembuild_vm_user.username))
995988
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 & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +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

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-
}

0 commit comments

Comments
 (0)