Skip to content

Commit 5e23561

Browse files
Merge pull request #429 from cloudfoundry/skip-tests-on-k8s
After applying this change we couldn't actually get any cats tests to pass when targeting a cf-for-k8s foundation. We ran into incompatibilities like specifying buildpacks, which cf-for-k8s doesn't currently allow.
2 parents 7f4027c + 23dddf4 commit 5e23561

15 files changed

+57
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ include_v3
192192
* `volume_service_plan_name`: The name of the plan of the service provided by the volume service broker.
193193
* `volume_service_create_config`: The JSON configuration that is used when volume service is created.
194194

195+
* `infrastructure`: The name of the infrastructure for the environment that the tests will run against. Must be either "vms" or "kubernetes". Defaults to "vms".
196+
195197
#### Buildpack Names
196198
Many tests specify a buildpack when pushing an app, so that on diego the app staging process completes in less time. The default names for the buildpacks are as follows; if you have buildpacks with different names, you can override them by setting different names:
197199

apps/admin_buildpack_lifecycle.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ var _ = AppsDescribe("Admin Buildpacks", func() {
3232
buildpackArchivePath string
3333
)
3434

35+
SkipOnK8s()
36+
3537
noAppDetectedErrorRegexp := "NoAppDetectedError|An app was not successfully detected by any available buildpack"
3638
buildpackCompileFailedRegexp := "BuildpackCompileFailed|App staging failed in the buildpack compile phase"
3739
buildpackReleaseFailedRegexp := "BuildpackReleaseFailed|App staging failed in the buildpack release phase"

apps/app_stack.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ var _ = AppsDescribe("Specifying a specific stack", func() {
3434
tmpdir string
3535
)
3636

37+
SkipOnK8s()
38+
3739
matchingFilename := func(appName string) string {
3840
return fmt.Sprintf("stack-match-%s", appName)
3941
}

apps/app_staging_environment.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ var _ = AppsDescribe("Buildpack Environment", func() {
3232
tmpdir string
3333
)
3434

35+
SkipOnK8s()
36+
3537
matchingFilename := func(appName string) string {
3638
return fmt.Sprintf("buildpack-environment-match-%s", appName)
3739
}

apps/buildpack_cache.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ var _ = AppsDescribe("Buildpack cache", func() {
3232
buildpackArchivePath string
3333
)
3434

35+
SkipOnK8s()
36+
3537
matchingFilename := func(appName string) string {
3638
return fmt.Sprintf("buildpack-for-buildpack-cache-test-%s", appName)
3739
}

apps/default_environment_variables.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ exit 1
6262
var appName string
6363
var buildpackName string
6464

65+
SkipOnK8s()
66+
6567
BeforeEach(func() {
6668
appName = random_name.CATSRandomName("APP")
6769
})

apps/environment_variables_group.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ exit 1
102102
var buildpackName string
103103
var envVarName string
104104

105+
SkipOnK8s()
106+
105107
BeforeEach(func() {
106108
appName = random_name.CATSRandomName("APP")
107109
envVarName = fmt.Sprintf("CATS_STAGING_TEST_VAR_%s", strconv.Itoa(int(time.Now().UnixNano())))

cats_suite_helpers/cats_suite_helpers.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ var (
2828
SftpPath string
2929
)
3030

31+
func SkipOnK8s() {
32+
BeforeEach(func() {
33+
if Config.RunningOnK8s() {
34+
Skip(skip_messages.SkipK8sMessage)
35+
}
36+
})
37+
}
38+
3139
func AppsDescribe(description string, callback func()) bool {
3240
return Describe("[apps]", func() {
3341
BeforeEach(func() {
@@ -246,6 +254,7 @@ func CredhubDescribe(description string, callback func()) bool {
246254
Skip(skip_messages.SkipCredhubMessage)
247255
}
248256
})
257+
SkipOnK8s()
249258
Describe(description, callback)
250259
})
251260
}
@@ -282,6 +291,7 @@ func WindowsCredhubDescribe(description string, callback func()) bool {
282291
Skip(skip_messages.SkipCredhubMessage)
283292
}
284293
})
294+
SkipOnK8s()
285295
Describe(description, callback)
286296
})
287297
}
@@ -315,6 +325,7 @@ func WindowsDescribe(description string, callback func()) bool {
315325
Skip(skip_messages.SkipWindowsMessage)
316326
}
317327
})
328+
SkipOnK8s()
318329
Describe(description, callback)
319330
})
320331
}

credhub/service_bindings.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ var _ = CredhubDescribe("service bindings", func() {
134134

135135
tmpdir string
136136
)
137+
138+
SkipOnK8s()
139+
137140
BeforeEach(func() {
138141
workflowhelpers.AsUser(TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() {
139142
buildpackName = random_name.CATSRandomName("BPK")

helpers/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ type CatsConfig interface {
9494
SleepTimeoutDuration() time.Duration
9595

9696
GetPublicDockerAppImage() string
97+
98+
RunningOnK8s() bool
9799
}
98100

99101
func NewCatsConfig(path string) (CatsConfig, error) {

helpers/config/config_struct.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ type config struct {
112112
NamePrefix *string `json:"name_prefix"`
113113

114114
ReporterConfig *reporterConfig `json:"reporter_config"`
115+
116+
Infrastructure *string `json:"infrastructure"`
115117
}
116118

117119
type reporterConfig struct {
@@ -223,6 +225,8 @@ func getDefaults() config {
223225
defaults.NamePrefix = ptrToString("CATS")
224226

225227
defaults.Stacks = &[]string{"cflinuxfs3"}
228+
229+
defaults.Infrastructure = ptrToString("vms")
226230
return defaults
227231
}
228232

@@ -447,6 +451,9 @@ func validateConfig(config *config) Errors {
447451
if config.NamePrefix == nil {
448452
errs.Add(fmt.Errorf("* 'name_prefix' must not be null"))
449453
}
454+
if config.Infrastructure == nil {
455+
errs.Add(fmt.Errorf("* 'infrastructure' must not be null"))
456+
}
450457

451458
return errs
452459
}
@@ -1032,3 +1039,7 @@ func (c *config) GetReporterConfig() reporterConfig {
10321039

10331040
return reporterConfig{}
10341041
}
1042+
1043+
func (c *config) RunningOnK8s() bool {
1044+
return *c.Infrastructure == "kubernetes"
1045+
}

helpers/config/config_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ type testConfig struct {
7171
ReporterConfig *testReporterConfig `json:"reporter_config"`
7272

7373
Stacks *[]string `json:"stacks,omitempty"`
74+
75+
Infrastructure *string `json:"infrastructure"`
7476
}
7577

7678
type allConfig struct {
@@ -156,6 +158,8 @@ type allConfig struct {
156158
NamePrefix *string `json:"name_prefix"`
157159

158160
Stacks *[]string `json:"stacks"`
161+
162+
Infrastructure *string `json:"infrastructure"`
159163
}
160164

161165
type testReporterConfig struct {
@@ -210,6 +214,7 @@ var _ = Describe("Config", func() {
210214
testCfg.AdminPassword = ptrToString("admin")
211215
testCfg.SkipSSLValidation = ptrToBool(true)
212216
testCfg.AppsDomain = ptrToString("cf-app.bosh-lite.com")
217+
testCfg.Infrastructure = ptrToString("vms")
213218
})
214219

215220
JustBeforeEach(func() {
@@ -311,6 +316,8 @@ var _ = Describe("Config", func() {
311316
Expect(config.GetRequireProxiedAppTraffic()).To(BeFalse())
312317

313318
Expect(config.GetStacks()).To(ConsistOf("cflinuxfs3"))
319+
320+
Expect(config.RunningOnK8s()).To(BeFalse(), "RunningOnK8s should be false")
314321
})
315322

316323
Context("when all values are null", func() {
@@ -388,6 +395,8 @@ var _ = Describe("Config", func() {
388395
Expect(err.Error()).To(ContainSubstring("'name_prefix' must not be null"))
389396

390397
Expect(err.Error()).To(ContainSubstring("'stacks' must not be null"))
398+
399+
Expect(err.Error()).To(ContainSubstring("'infrastructure' must not be null"))
391400
})
392401
})
393402

@@ -403,6 +412,7 @@ var _ = Describe("Config", func() {
403412
testCfg.TimeoutScale = ptrToFloat(1.0)
404413
testCfg.UnallocatedIPForSecurityGroup = ptrToString("192.168.0.1")
405414
testCfg.RequireProxiedAppTraffic = ptrToBool(true)
415+
testCfg.Infrastructure = ptrToString("kubernetes")
406416
})
407417

408418
It("respects the overriden values", func() {
@@ -419,6 +429,7 @@ var _ = Describe("Config", func() {
419429
Expect(config.SleepTimeoutDuration()).To(Equal(101 * time.Second))
420430
Expect(config.GetUnallocatedIPForSecurityGroup()).To(Equal("192.168.0.1"))
421431
Expect(config.GetRequireProxiedAppTraffic()).To(BeTrue())
432+
Expect(config.RunningOnK8s()).To(BeTrue(), "RunningOnK8s should be true")
422433
})
423434
})
424435

helpers/skip_messages/skip_messages.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,4 @@ const SkipNoAlternateStacksMessage = `Skipping this test because config.Stacks i
5050
const SkipVolumeServicesMessage = `Skipping this test because config.IncludeVolumeServices is set to 'false'.
5151
NOTE: Ensure that volume services are enabled on your platform and volume service broker is registered before running this test.`
5252
const SkipVolumeServicesDockerEnabledMessage = `Skipping this test because config.IncludeDocker is set to 'true'`
53+
const SkipK8sMessage = `Skipping this test because config.Infrastructure is set to 'kubernetes'`

security_groups/running_security_groups.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ var _ = SecurityGroupsDescribe("App Instance Networking", func() {
285285
Describe("Using staging security groups", func() {
286286
var testAppName, buildpack string
287287

288+
SkipOnK8s()
289+
288290
BeforeEach(func() {
289291
serverAppName, privateHost, privatePort = pushServerApp()
290292

v3/buildpacks.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ var _ = V3Describe("buildpack", func() {
4141
Version string `json:"version"`
4242
}
4343

44+
SkipOnK8s()
45+
4446
Context("With a single buildpack app", func() {
4547
BeforeEach(func() {
4648
appName = random_name.CATSRandomName("APP")

0 commit comments

Comments
 (0)