Skip to content

Commit 0d013bc

Browse files
author
Joshua Reed
committed
Remove skips in semi-integ unit tests.
1 parent a3675cf commit 0d013bc

File tree

6 files changed

+99
-105
lines changed

6 files changed

+99
-105
lines changed

test/unit/cloud/affinity_groups_test.go

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package cloud_test
1818

1919
import (
2020
"errors"
21+
"fmt"
2122

2223
"github.com/apache/cloudstack-go/v2/cloudstack"
2324
"github.com/aws/cluster-api-provider-cloudstack-staging/test/unit/dummies"
@@ -71,22 +72,39 @@ var _ = Describe("The AffinityGroup interface", func() {
7172

7273
When("using a real CloudStack client", func() {
7374
BeforeEach(func() {
75+
fmt.Println("blah2oomuch")
7476
client = realCloudClient
7577
dummies.AffinityGroup.ID = "" // Force name fetching.
7678
})
7779
It("creates an affinity group.", func() {
7880
Ω(client.GetOrCreateAffinityGroup(dummies.AffinityGroup)).Should(Succeed())
7981
})
80-
It("associates an affinity group.", func() {
81-
Ω(client.GetOrCreateVMInstance(
82-
dummies.CSMachine1, dummies.CAPIMachine, dummies.CSCluster, dummies.CSZone1, dummies.CSAffinityGroup, "",
83-
)).Should(Succeed())
84-
Ω(client.GetOrCreateAffinityGroup(dummies.AffinityGroup)).Should(Succeed())
85-
Ω(client.AssociateAffinityGroup(dummies.CSMachine1, *dummies.AffinityGroup)).Should(Succeed())
86-
})
82+
// Context("with an existing VM", func() {
83+
// BeforeEach(func() {
84+
// Ω(client.ResolveZone(dummies.CSZone1)).Should(Succeed())
85+
// Ω(dummies.CSZone1.Spec.ID).ShouldNot(BeEmpty())
86+
// dummies.CSMachine1.Status.ZoneID = dummies.CSZone1.Spec.ID
87+
// dummies.CSMachine1.Spec.DiskOffering.Name = ""
88+
// dummies.CSCluster.Spec.ControlPlaneEndpoint.Host = ""
89+
// Ω(client.GetOrCreateIsolatedNetwork(dummies.CSZone1, dummies.CSISONet1, dummies.CSCluster)).Should(Succeed())
90+
// dummies.CSZone1.Spec.Network.ID = dummies.CSISONet1.Spec.ID
91+
// Ω(client.GetOrCreateVMInstance(
92+
// dummies.CSMachine1, dummies.CAPIMachine, dummies.CSCluster, dummies.CSZone1, dummies.CSAffinityGroup, "",
93+
// )).Should(Succeed())
94+
// })
95+
// AfterEach(func() {
96+
// Ω(client.DestroyVMInstance(dummies.CSMachine1)).Should(MatchError("VM deletion in progress"))
97+
// })
98+
// It("associates an affinity group and disassociates it", func() {
99+
// Ω(client.GetOrCreateAffinityGroup(dummies.AffinityGroup)).Should(Succeed())
100+
// Ω(client.AssociateAffinityGroup(dummies.CSMachine1, *dummies.AffinityGroup)).Should(Succeed())
101+
// Ω(client.DisassociateAffinityGroup(dummies.CSMachine1, *dummies.AffinityGroup)).Should(Succeed())
102+
// })
103+
// })
87104
It("deletes an affinity group.", func() {
88105
Ω(client.DeleteAffinityGroup(dummies.AffinityGroup)).Should(Succeed())
89106
Ω(client.FetchAffinityGroup(dummies.AffinityGroup)).ShouldNot(Succeed())
90107
})
108+
Context("del", func() {})
91109
})
92110
})

test/unit/cloud/cloud_suite_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ import (
2121
"testing"
2222

2323
"github.com/apache/cloudstack-go/v2/cloudstack"
24+
"github.com/aws/cluster-api-provider-cloudstack-staging/test/unit/dummies"
2425
"github.com/aws/cluster-api-provider-cloudstack/pkg/cloud"
2526
. "github.com/onsi/ginkgo/v2"
2627
. "github.com/onsi/gomega"
2728
)
2829

2930
var (
3031
realCloudClient cloud.Client
32+
client cloud.Client
3133
realCSClient *cloudstack.CloudStackClient
3234
)
3335

@@ -36,9 +38,21 @@ var _ = BeforeSuite(func() {
3638
var connectionErr error
3739
realCloudClient, connectionErr = cloud.NewClient(projDir + "/cloud-config")
3840
Ω(connectionErr).ShouldNot(HaveOccurred())
41+
42+
Ω().Should(Succeed())
3943
})
4044

4145
func TestCloud(t *testing.T) {
4246
RegisterFailHandler(Fail)
4347
RunSpecs(t, "Cloud Suite")
4448
}
49+
50+
// FetchIntegTestResources runs through basic CloudStack Client setup methods needed to test others.
51+
func FetchIntegTestResources() {
52+
Ω(client.ResolveZone(dummies.CSZone1)).Should(Succeed())
53+
Ω(dummies.CSZone1.Spec.ID).ShouldNot(BeEmpty())
54+
dummies.CSMachine1.Status.ZoneID = dummies.CSZone1.Spec.ID
55+
dummies.CSMachine1.Spec.DiskOffering.Name = ""
56+
dummies.CSCluster.Spec.ControlPlaneEndpoint.Host = ""
57+
Ω(client.GetOrCreateIsolatedNetwork(dummies.CSZone1, dummies.CSISONet1, dummies.CSCluster)).Should(Succeed())
58+
}

test/unit/cloud/isolated_network_test.go

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,8 @@ var _ = Describe("Network", func() {
192192
})
193193

194194
Context("Networking Integ Tests", func() {
195-
client, connectionErr := cloud.NewClient("../../cloud-config")
196-
197195
BeforeEach(func() {
198-
if connectionErr != nil { // Only do these tests if an actual ACS instance is available via cloud-config.
199-
Skip("Could not connect to ACS instance.")
200-
}
201-
if err := client.ResolveNetwork(&dummies.Net1); err != nil {
202-
Skip("Could not find network.")
203-
}
204-
196+
client = realCloudClient
205197
// Delete any existing tags
206198
existingTags, err := client.GetTags(cloud.ResourceTypeNetwork, dummies.Net1.ID)
207199
if err != nil {
@@ -213,6 +205,17 @@ var _ = Describe("Network", func() {
213205
Fail("Failed to delete existing tags. Error: " + err.Error())
214206
}
215207
}
208+
dummies.SetDummyVars()
209+
210+
// Setup Isolated Network Dummy Vars.
211+
dummies.CSISONet1.Spec.ID = "" // Make CAPC methods resolve this.
212+
dummies.CSCluster.Spec.ControlPlaneEndpoint.Host = "" // Make CAPC methods resolve this.
213+
dummies.CSZone1.Spec.ID = "" // Make CAPC methods resolve this.
214+
dummies.CSCluster.Status.Zones = capcv1.ZoneStatusMap{}
215+
216+
// Get Zone info needed for network testing.
217+
Ω(client.ResolveZone(dummies.CSZone1)).Should(Succeed())
218+
dummies.CSISONet1.Spec.ID = ""
216219
})
217220

218221
It("fetches an isolated network", func() {
@@ -231,28 +234,6 @@ var _ = Describe("Network", func() {
231234
dummies.CSCluster.Spec.ControlPlaneEndpoint.Host = ""
232235
Ω(client.ResolveNetwork(&dummies.ISONet1)).Should(Succeed())
233236
})
234-
})
235-
236-
Context("Network Semi-Integ Tests", func() {
237-
client, connectionErr := cloud.NewClient("../../cloud-config")
238-
239-
BeforeEach(func() {
240-
if connectionErr != nil { // Only do these tests if an actual ACS instance is available via cloud-config.
241-
Skip("Could not connect to ACS instance.")
242-
}
243-
244-
dummies.SetDummyVars()
245-
246-
// Setup Isolated Network Dummy Vars.
247-
dummies.CSISONet1.Spec.ID = "" // Make CAPC methods resolve this.
248-
dummies.CSCluster.Spec.ControlPlaneEndpoint.Host = "" // Make CAPC methods resolve this.
249-
dummies.CSZone1.Spec.ID = "" // Make CAPC methods resolve this.
250-
dummies.CSCluster.Status.Zones = capcv1.ZoneStatusMap{}
251-
252-
// Get Zone info needed for network testing.
253-
Ω(client.ResolveZone(dummies.CSZone1)).Should(Succeed())
254-
dummies.CSISONet1.Spec.ID = ""
255-
})
256237

257238
It("adds an isolated network and doesn't fail when asked to GetOrCreateIsolatedNetwork multiple times", func() {
258239
Ω(client.GetOrCreateIsolatedNetwork(dummies.CSZone1, dummies.CSISONet1, dummies.CSCluster)).Should(Succeed())

test/unit/cloud/tags_test.go

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -29,111 +29,104 @@ var _ = Describe("Tag Unit Tests", func() {
2929
})
3030

3131
Context("Tag Integ Tests", func() {
32-
client, connectionErr := cloud.NewClient("../../cloud-config")
33-
3432
BeforeEach(func() {
35-
if connectionErr != nil { // Only do these tests if an actual ACS instance is available via cloud-config.
36-
Skip("Could not connect to ACS instance.")
37-
}
38-
if err := client.ResolveNetwork(&dummies.Net1); err != nil {
39-
Skip("Could not find network.")
40-
}
33+
client = realCloudClient
34+
FetchIntegTestResources()
4135

42-
// Delete any existing tags
43-
existingTags, err := client.GetTags(cloud.ResourceTypeNetwork, dummies.Net1.ID)
36+
existingTags, err := client.GetTags(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID)
4437
if err != nil {
4538
Fail("Failed to get existing tags. Error: " + err.Error())
4639
}
4740
if len(existingTags) > 0 {
48-
err = client.DeleteTags(cloud.ResourceTypeNetwork, dummies.Net1.ID, existingTags)
41+
err = client.DeleteTags(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID, existingTags)
4942
if err != nil {
5043
Fail("Failed to delete existing tags. Error: " + err.Error())
5144
}
5245
}
5346
})
5447

5548
It("adds and gets a resource tag", func() {
56-
Ω(client.AddTags(cloud.ResourceTypeNetwork, dummies.Net1.ID, dummies.Tags)).Should(Succeed())
57-
Ω(client.GetTags(cloud.ResourceTypeNetwork, dummies.Net1.ID)).Should(Equal(dummies.Tags))
49+
Ω(client.AddTags(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID, dummies.Tags)).Should(Succeed())
50+
Ω(client.GetTags(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID)).Should(Equal(dummies.Tags))
5851
})
5952

6053
It("deletes a resource tag", func() {
61-
Ω(client.AddTags(cloud.ResourceTypeNetwork, dummies.Net1.ID, dummies.Tags)).Should(Succeed())
62-
Ω(client.DeleteTags(cloud.ResourceTypeNetwork, dummies.Net1.ID, dummies.Tags)).Should(Succeed())
63-
Ω(client.GetTags(cloud.ResourceTypeNetwork, dummies.Net1.ID)).Should(Equal(map[string]string{}))
54+
Ω(client.AddTags(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID, dummies.Tags)).Should(Succeed())
55+
Ω(client.DeleteTags(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID, dummies.Tags)).Should(Succeed())
56+
Ω(client.GetTags(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID)).Should(Equal(map[string]string{}))
6457
})
6558

6659
It("returns an error when you delete a tag that doesn't exist", func() {
67-
Ω(client.DeleteTags(cloud.ResourceTypeNetwork, dummies.Net1.ID, dummies.Tags)).Should(Succeed())
60+
Ω(client.DeleteTags(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID, dummies.Tags)).Should(Succeed())
6861
})
6962

7063
It("adds the tags for a cluster (resource created by CAPC)", func() {
71-
Ω(client.AddCreatedByCAPCTag(cloud.ResourceTypeNetwork, dummies.Net1.ID)).
64+
Ω(client.AddCreatedByCAPCTag(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID)).
7265
Should(Succeed())
73-
Ω(client.AddClusterTag(cloud.ResourceTypeNetwork, dummies.Net1.ID, dummies.CSCluster)).
66+
Ω(client.AddClusterTag(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID, dummies.CSCluster)).
7467
Should(Succeed())
7568

7669
// Verify tags
77-
tags, err := client.GetTags(cloud.ResourceTypeNetwork, dummies.Net1.ID)
70+
tags, err := client.GetTags(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID)
7871
Ω(err).ShouldNot(HaveOccurred())
7972

8073
Ω(tags[dummies.CSClusterTagKey]).Should(Equal(dummies.CSClusterTagVal))
8174
})
8275

8376
It("does not fail when the cluster tags are added twice", func() {
84-
Ω(client.AddClusterTag(cloud.ResourceTypeNetwork, dummies.Net1.ID, dummies.CSCluster)).Should(Succeed())
85-
Ω(client.AddClusterTag(cloud.ResourceTypeNetwork, dummies.Net1.ID, dummies.CSCluster)).Should(Succeed())
77+
Ω(client.AddClusterTag(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID, dummies.CSCluster)).Should(Succeed())
78+
Ω(client.AddClusterTag(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID, dummies.CSCluster)).Should(Succeed())
8679
})
8780

8881
It("doesn't adds the tags for a cluster (resource NOT created by CAPC)", func() {
89-
Ω(client.AddClusterTag(cloud.ResourceTypeNetwork, dummies.Net1.ID, dummies.CSCluster)).Should(Succeed())
82+
Ω(client.AddClusterTag(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID, dummies.CSCluster)).Should(Succeed())
9083

9184
// Verify tags
92-
tags, err := client.GetTags(cloud.ResourceTypeNetwork, dummies.Net1.ID)
85+
tags, err := client.GetTags(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID)
9386
Ω(err).Should(BeNil())
9487
Ω(tags[dummies.CreatedByCapcKey]).Should(Equal(""))
9588
Ω(tags[dummies.CSClusterTagKey]).Should(Equal(""))
9689
})
9790

9891
It("deletes a cluster tag", func() {
99-
Ω(client.AddClusterTag(cloud.ResourceTypeNetwork, dummies.Net1.ID, dummies.CSCluster)).Should(Succeed())
100-
Ω(client.DeleteClusterTag(cloud.ResourceTypeNetwork, dummies.Net1.ID, dummies.CSCluster)).Should(Succeed())
92+
Ω(client.AddClusterTag(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID, dummies.CSCluster)).Should(Succeed())
93+
Ω(client.DeleteClusterTag(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID, dummies.CSCluster)).Should(Succeed())
10194

102-
Ω(client.GetTags(cloud.ResourceTypeNetwork, dummies.Net1.ID)).ShouldNot(HaveKey(dummies.CSClusterTagKey))
95+
Ω(client.GetTags(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID)).ShouldNot(HaveKey(dummies.CSClusterTagKey))
10396
})
10497

10598
It("adds and deletes a created by capc tag", func() {
106-
Ω(client.AddCreatedByCAPCTag(cloud.ResourceTypeNetwork, dummies.Net1.ID)).Should(Succeed())
107-
Ω(client.DeleteCreatedByCAPCTag(cloud.ResourceTypeNetwork, dummies.Net1.ID)).Should(Succeed())
99+
Ω(client.AddCreatedByCAPCTag(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID)).Should(Succeed())
100+
Ω(client.DeleteCreatedByCAPCTag(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID)).Should(Succeed())
108101
})
109102

110103
It("does not fail when cluster and CAPC created tags are deleted twice", func() {
111-
Ω(client.AddClusterTag(cloud.ResourceTypeNetwork, dummies.Net1.ID, dummies.CSCluster)).Should(Succeed())
112-
Ω(client.DeleteClusterTag(cloud.ResourceTypeNetwork, dummies.Net1.ID, dummies.CSCluster)).Should(Succeed())
113-
Ω(client.DeleteClusterTag(cloud.ResourceTypeNetwork, dummies.Net1.ID, dummies.CSCluster)).Should(Succeed())
114-
Ω(client.DeleteCreatedByCAPCTag(cloud.ResourceTypeNetwork, dummies.Net1.ID)).Should(Succeed())
115-
Ω(client.DeleteCreatedByCAPCTag(cloud.ResourceTypeNetwork, dummies.Net1.ID)).Should(Succeed())
104+
Ω(client.AddClusterTag(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID, dummies.CSCluster)).Should(Succeed())
105+
Ω(client.DeleteClusterTag(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID, dummies.CSCluster)).Should(Succeed())
106+
Ω(client.DeleteClusterTag(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID, dummies.CSCluster)).Should(Succeed())
107+
Ω(client.DeleteCreatedByCAPCTag(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID)).Should(Succeed())
108+
Ω(client.DeleteCreatedByCAPCTag(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID)).Should(Succeed())
116109
})
117110

118111
It("does not allow a resource to be deleted when there are no tags", func() {
119-
tagsAllowDisposal, err := client.DoClusterTagsAllowDisposal(cloud.ResourceTypeNetwork, dummies.Net1.ID)
112+
tagsAllowDisposal, err := client.DoClusterTagsAllowDisposal(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID)
120113
Ω(err).Should(BeNil())
121114
Ω(tagsAllowDisposal).Should(BeFalse())
122115
})
123116

124117
It("does not allow a resource to be deleted when there is a cluster tag", func() {
125-
Ω(client.AddClusterTag(cloud.ResourceTypeNetwork, dummies.Net1.ID, dummies.CSCluster)).Should(Succeed())
126-
tagsAllowDisposal, err := client.DoClusterTagsAllowDisposal(cloud.ResourceTypeNetwork, dummies.Net1.ID)
118+
Ω(client.AddClusterTag(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID, dummies.CSCluster)).Should(Succeed())
119+
tagsAllowDisposal, err := client.DoClusterTagsAllowDisposal(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID)
127120
Ω(err).Should(BeNil())
128121
Ω(tagsAllowDisposal).Should(BeFalse())
129122
})
130123

131124
It("does allow a resource to be deleted when there are no cluster tags and there is a CAPC created tag", func() {
132-
Ω(client.AddClusterTag(cloud.ResourceTypeNetwork, dummies.Net1.ID, dummies.CSCluster)).Should(Succeed())
133-
Ω(client.AddCreatedByCAPCTag(cloud.ResourceTypeNetwork, dummies.Net1.ID)).Should(Succeed())
134-
Ω(client.DeleteClusterTag(cloud.ResourceTypeNetwork, dummies.Net1.ID, dummies.CSCluster)).Should(Succeed())
125+
Ω(client.AddClusterTag(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID, dummies.CSCluster)).Should(Succeed())
126+
Ω(client.AddCreatedByCAPCTag(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID)).Should(Succeed())
127+
Ω(client.DeleteClusterTag(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID, dummies.CSCluster)).Should(Succeed())
135128

136-
tagsAllowDisposal, err := client.DoClusterTagsAllowDisposal(cloud.ResourceTypeNetwork, dummies.Net1.ID)
129+
tagsAllowDisposal, err := client.DoClusterTagsAllowDisposal(cloud.ResourceTypeNetwork, dummies.CSISONet1.Spec.ID)
137130
Ω(err).Should(BeNil())
138131
Ω(tagsAllowDisposal).Should(BeTrue())
139132
})

test/unit/cloud/user_credentials_test.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"github.com/aws/cluster-api-provider-cloudstack-staging/test/unit/dummies"
2121
"github.com/aws/cluster-api-provider-cloudstack/pkg/cloud"
2222
. "github.com/onsi/ginkgo/v2"
23-
"github.com/pkg/errors"
2423

2524
. "github.com/onsi/gomega"
2625
)
@@ -37,17 +36,14 @@ var _ = Describe("User Credentials", func() {
3736
})
3837

3938
Context("UserCred Semi-Integ Tests", func() {
40-
client, connectionErr := cloud.NewClient("../../cloud-config")
4139
var domain cloud.Domain
4240
var account cloud.Account
4341
var user cloud.User
4442

4543
BeforeEach(func() {
46-
if connectionErr != nil { // Only do these tests if an actual ACS instance is available via cloud-config.
47-
Skip(errors.Wrapf(connectionErr, "Could not connect to ACS instance").Error())
48-
}
44+
client = realCloudClient
4945

50-
// Settup dummies.
46+
// Setup dummies.
5147
// TODO: move these to the test dummies package.
5248
domain = cloud.Domain{Path: "ROOT/blah/blah/subsub"}
5349
account = cloud.Account{Name: "SuperNested", Domain: domain}

0 commit comments

Comments
 (0)