Skip to content

Commit

Permalink
Merge pull request #650 from cloudfoundry/r_and_nginx_bp_tests
Browse files Browse the repository at this point in the history
Additional tests for r_buildpack and nginx_buildpack
  • Loading branch information
jochenehret authored Dec 1, 2022
2 parents ac7eda3 + 04b31a5 commit c7ece41
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,12 @@ include_v3
* `staticfile_buildpack_name` [See below](#buildpack-names)
* `java_buildpack_name` [See below](#buildpack-names)
* `ruby_buildpack_name` [See below](#buildpack-names)
* `nginx_buildpack_name` [See below](#buildpack-names)
* `nodejs_buildpack_name` [See below](#buildpack-names)
* `go_buildpack_name` [See below](#buildpack-names)
* `python_buildpack_name` [See below](#buildpack-names)
* `php_buildpack_name` [See below](#buildpack-names)
* `r_buildpack_name` [See below](#buildpack-names)
* `binary_buildpack_name` [See below](#buildpack-names)

* `include_windows`: Flag to include the tests that run against Windows cells.
Expand All @@ -202,10 +204,12 @@ Many tests specify a buildpack when pushing an app, so that on diego the app sta
* `staticfile_buildpack_name: staticfile_buildpack`
* `java_buildpack_name: java_buildpack`
* `ruby_buildpack_name: ruby_buildpack`
* `nginx_buildpack_name: nginx_buildpack`
* `nodejs_buildpack_name: nodejs_buildpack`
* `go_buildpack_name: go_buildpack`
* `python_buildpack_name: python_buildpack`
* `php_buildpack_name: php_buildpack`
* `r_buildpack_name: r_buildpack`
* `binary_buildpack_name: binary_buildpack`
* `hwc_buildpack_name: hwc_buildpack`

Expand Down
13 changes: 13 additions & 0 deletions assets/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
events {
worker_connections 1024;
}

http {
server {
listen {{port}};

location = / {
return 200 "Hello NGINX!";
}
}
}
1 change: 1 addition & 0 deletions assets/r/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: R -f simple.r
Empty file added assets/r/r.yml
Empty file.
14 changes: 14 additions & 0 deletions assets/r/simple.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
library(shiny)

# Define the UI
ui <- fluidPage(
titlePanel("Hello R!")
)

# Define the server code
server <- function(input, output) {
}

# Return a Shiny app object
options(shiny.port = strtoi(Sys.getenv("PORT")), shiny.host = "0.0.0.0")
shinyApp(ui = ui, server = server)
46 changes: 46 additions & 0 deletions detect/buildpacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var _ = DetectDescribe("Buildpacks", func() {

Describe("ruby", func() {
for _, stack := range Config.GetStacks() {
stack := stack
Context(fmt.Sprintf("when using %s stack", stack), func() {
It("makes the app reachable via its bound route", func() {
Expect(cf.Cf("push",
Expand All @@ -52,6 +53,7 @@ var _ = DetectDescribe("Buildpacks", func() {

Describe("node", func() {
for _, stack := range Config.GetStacks() {
stack := stack
Context(fmt.Sprintf("when using %s stack", stack), func() {
It("makes the app reachable via its bound route", func() {
Expect(cf.Cf("push",
Expand All @@ -71,6 +73,7 @@ var _ = DetectDescribe("Buildpacks", func() {

Describe("java", func() {
for _, stack := range Config.GetStacks() {
stack := stack
Context(fmt.Sprintf("when using %s stack", stack), func() {
It("makes the app reachable via its bound route", func() {
Expect(cf.Cf("push", appName,
Expand All @@ -90,6 +93,7 @@ var _ = DetectDescribe("Buildpacks", func() {

Describe("golang", func() {
for _, stack := range Config.GetStacks() {
stack := stack
Context(fmt.Sprintf("when using %s stack", stack), func() {
It("makes the app reachable via its bound route", func() {
Expect(cf.Cf("push", appName,
Expand All @@ -109,6 +113,7 @@ var _ = DetectDescribe("Buildpacks", func() {

Describe("python", func() {
for _, stack := range Config.GetStacks() {
stack := stack
Context(fmt.Sprintf("when using %s stack", stack), func() {
It("makes the app reachable via its bound route", func() {
Expect(cf.Cf("push", appName,
Expand All @@ -134,6 +139,7 @@ var _ = DetectDescribe("Buildpacks", func() {
})

for _, stack := range Config.GetStacks() {
stack := stack
Context(fmt.Sprintf("when using %s stack", stack), func() {
It("makes the app reachable via its bound route", func() {
Expect(cf.Cf("push", appName,
Expand Down Expand Up @@ -170,6 +176,7 @@ var _ = DetectDescribe("Buildpacks", func() {
Describe("staticfile", func() {
SkipOnK8s("staticfile not yet supported, as currently structured in CATS")
for _, stack := range Config.GetStacks() {
stack := stack
Context(fmt.Sprintf("when using %s stack", stack), func() {
It("makes the app reachable via its bound route", func() {
Expect(cf.Cf("push", appName,
Expand All @@ -188,6 +195,7 @@ var _ = DetectDescribe("Buildpacks", func() {

Describe("binary", func() {
for _, stack := range Config.GetStacks() {
stack := stack
Context(fmt.Sprintf("when using %s stack", stack), func() {
It("makes the app reachable via its bound route", func() {
Expect(cf.Cf("push", appName,
Expand All @@ -204,4 +212,42 @@ var _ = DetectDescribe("Buildpacks", func() {
})
}
})

Describe("nginx", func() {
for _, stack := range Config.GetStacks() {
stack := stack
Context(fmt.Sprintf("when using %s stack", stack), func() {
It("makes the app reachable via its bound route", func() {
Expect(cf.Cf("push", appName,
"-m", DEFAULT_MEMORY_LIMIT,
"-p", assets.NewAssets().Nginx,
"-s", stack,
).Wait(Config.DetectTimeoutDuration())).To(Exit(0))

Eventually(func() string {
return helpers.CurlAppRoot(Config, appName)
}).Should(ContainSubstring("Hello NGINX!"))
})
})
}
})

Describe("r", func() {
for _, stack := range Config.GetStacks() {
stack := stack
Context(fmt.Sprintf("when using %s stack", stack), func() {
It("makes the app reachable via its bound route", func() {
Expect(cf.Cf("push", appName,
"-m", DEFAULT_MEMORY_LIMIT,
"-p", assets.NewAssets().R,
"-s", stack,
).Wait(Config.DetectTimeoutDuration())).To(Exit(0))

Eventually(func() string {
return helpers.CurlAppRoot(Config, appName)
}).Should(ContainSubstring("Hello R!"))
})
})
}
})
})
4 changes: 4 additions & 0 deletions helpers/assets/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ type Assets struct {
LoggregatorLoadGenerator string
LoggregatorLoadGeneratorGo string
Python string
Nginx string
Node string
NodeWithProcfile string
Nora string
Pora string
Php string
Proxy string
R string
RubySimple string
SecurityGroupBuildpack string
ServiceBroker string
Expand Down Expand Up @@ -67,13 +69,15 @@ func NewAssets() Assets {
JavaUnwriteableZip: "assets/java-unwriteable-dir/java-unwriteable-dir.jar",
LoggregatorLoadGenerator: "assets/loggregator-load-generator",
LoggregatorLoadGeneratorGo: "assets/loggregator-load-generator-go",
Nginx: "assets/nginx",
Node: "assets/node",
NodeWithProcfile: "assets/node-with-procfile",
Nora: "assets/nora/NoraPublished",
Pora: "assets/pora",
Php: "assets/php",
Proxy: "assets/proxy",
Python: "assets/python",
R: "assets/r",
RubySimple: "assets/ruby_simple",
SecurityGroupBuildpack: "assets/security_group_buildpack.zip",
ServiceBroker: "assets/service_broker",
Expand Down
2 changes: 2 additions & 0 deletions helpers/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ type CatsConfig interface {
GetIsolationSegmentDomain() string
GetJavaBuildpackName() string
GetNamePrefix() string
GetNginxBuildpackName() string
GetNodejsBuildpackName() string
GetPrivateDockerRegistryImage() string
GetPrivateDockerRegistryUsername() string
GetPrivateDockerRegistryPassword() string
GetRBuildpackName() string
GetRubyBuildpackName() string
GetUnallocatedIPForSecurityGroup() string
GetRequireProxiedAppTraffic() bool
Expand Down
18 changes: 18 additions & 0 deletions helpers/config/config_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ type config struct {
GoBuildpackName *string `json:"go_buildpack_name"`
HwcBuildpackName *string `json:"hwc_buildpack_name"`
JavaBuildpackName *string `json:"java_buildpack_name"`
NginxBuildpackName *string `json:"nginx_buildpack_name"`
NodejsBuildpackName *string `json:"nodejs_buildpack_name"`
PhpBuildpackName *string `json:"php_buildpack_name"`
PythonBuildpackName *string `json:"python_buildpack_name"`
RBuildpackName *string `json:"r_buildpack_name"`
RubyBuildpackName *string `json:"ruby_buildpack_name"`
StaticFileBuildpackName *string `json:"staticfile_buildpack_name"`

Expand Down Expand Up @@ -151,9 +153,11 @@ func getDefaults() config {
defaults.GoBuildpackName = ptrToString("go_buildpack")
defaults.HwcBuildpackName = ptrToString("hwc_buildpack")
defaults.JavaBuildpackName = ptrToString("java_buildpack")
defaults.NginxBuildpackName = ptrToString("nginx_buildpack")
defaults.NodejsBuildpackName = ptrToString("nodejs_buildpack")
defaults.PhpBuildpackName = ptrToString("php_buildpack")
defaults.PythonBuildpackName = ptrToString("python_buildpack")
defaults.RBuildpackName = ptrToString("r_buildpack")
defaults.RubyBuildpackName = ptrToString("ruby_buildpack")
defaults.StaticFileBuildpackName = ptrToString("staticfile_buildpack")

Expand Down Expand Up @@ -375,6 +379,9 @@ func validateConfig(config *config) Errors {
if config.JavaBuildpackName == nil {
errs.Add(fmt.Errorf("* 'java_buildpack_name' must not be null"))
}
if config.NginxBuildpackName == nil {
errs.Add(fmt.Errorf("* 'nginx_buildpack_name' must not be null"))
}
if config.NodejsBuildpackName == nil {
errs.Add(fmt.Errorf("* 'nodejs_buildpack_name' must not be null"))
}
Expand All @@ -384,6 +391,9 @@ func validateConfig(config *config) Errors {
if config.PythonBuildpackName == nil {
errs.Add(fmt.Errorf("* 'python_buildpack_name' must not be null"))
}
if config.RBuildpackName == nil {
errs.Add(fmt.Errorf("* 'r_buildpack_name' must not be null"))
}
if config.RubyBuildpackName == nil {
errs.Add(fmt.Errorf("* 'ruby_buildpack_name' must not be null"))
}
Expand Down Expand Up @@ -991,6 +1001,10 @@ func (c *config) GetIncludeVolumeServices() bool {
return *c.IncludeVolumeServices
}

func (c *config) GetRBuildpackName() string {
return *c.RBuildpackName
}

func (c *config) GetRubyBuildpackName() string {
return *c.RubyBuildpackName
}
Expand All @@ -1007,6 +1021,10 @@ func (c *config) GetJavaBuildpackName() string {
return *c.JavaBuildpackName
}

func (c *config) GetNginxBuildpackName() string {
return *c.NginxBuildpackName
}

func (c *config) GetNodejsBuildpackName() string {
return *c.NodejsBuildpackName
}
Expand Down
2 changes: 2 additions & 0 deletions helpers/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,11 @@ type allConfig struct {
GoBuildpackName *string `json:"go_buildpack_name"`
HwcBuildpackName *string `json:"hwc_buildpack_name"`
JavaBuildpackName *string `json:"java_buildpack_name"`
NginxBuildpackName *string `json:"nginx_buildpack_name"`
NodejsBuildpackName *string `json:"nodejs_buildpack_name"`
PhpBuildpackName *string `json:"php_buildpack_name"`
PythonBuildpackName *string `json:"python_buildpack_name"`
RBuildpackName *string `json:"r_buildpack_name"`
RubyBuildpackName *string `json:"ruby_buildpack_name"`
StaticFileBuildpackName *string `json:"staticfile_buildpack_name"`

Expand Down

0 comments on commit c7ece41

Please sign in to comment.