Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support running uptimer against an isolation segment #58

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Here is an example config `json`:
"app_domain": "my-cf.com",
"admin_user": "admin",
"admin_password": "PASS",
"isolation_segment": name-of-my-isolation-segment",
"tcp_domain": "tcp.my-cf.com",
"use_single_app_instance": false,
"available_port": 1025
Expand Down Expand Up @@ -106,6 +107,9 @@ The `tcp_domain` and `available_port` values
are not required
_unless_ you elect to run the `app_syslog_availability` test.

The `isolation_segment` value is not required _unless_
you wish to run uptimer against apps pushed to an isolation segment.

Uptimer by default pushes two instances of an app
for its uptime measurements,
but it can be configured to push only a single instance
Expand Down
17 changes: 17 additions & 0 deletions cfCmdGenerator/cfCmdGenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type CfCmdGenerator interface {
SetQuota(org, quota string) cmdStartWaiter.CmdStartWaiter
CreateOrg(org string) cmdStartWaiter.CmdStartWaiter
CreateSpace(org, space string) cmdStartWaiter.CmdStartWaiter
EnableOrgIsolation(org, isolationSegment string) cmdStartWaiter.CmdStartWaiter
SetOrgDefaultIsolationSegment(org, isolationSegment string) cmdStartWaiter.CmdStartWaiter
Target(org, space string) cmdStartWaiter.CmdStartWaiter
Push(name, path string, instances int, noRoute bool) cmdStartWaiter.CmdStartWaiter
Delete(name string) cmdStartWaiter.CmdStartWaiter
Expand Down Expand Up @@ -98,6 +100,21 @@ func (c *cfCmdGenerator) CreateOrg(org string) cmdStartWaiter.CmdStartWaiter {
)
}

func (c *cfCmdGenerator) EnableOrgIsolation(org, isolationSegment string) cmdStartWaiter.CmdStartWaiter {
return c.setCfHome(
exec.Command(
"cf", "enable-org-isolation", org, isolationSegment,
),
)
}
func (c *cfCmdGenerator) SetOrgDefaultIsolationSegment(org, isolationSegment string) cmdStartWaiter.CmdStartWaiter {
return c.setCfHome(
exec.Command(
"cf", "set-org-default-isolation-segment", org, isolationSegment,
),
)
}

func (c *cfCmdGenerator) CreateSpace(org string, space string) cmdStartWaiter.CmdStartWaiter {
return c.setCfHome(
exec.Command(
Expand Down
16 changes: 16 additions & 0 deletions cfCmdGenerator/cfCmdGenerator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,22 @@ var _ = Describe("CfCmdGenerator", func() {
expectCommandToBeEquivalent(cmd, expectedCmd, cfHomeEnvVar)
})
})

Describe("EnableOrgIsolation", func() {
It("Generates the correct command", func() {
expectedCmd := exec.Command("cf", "enable-org-isolation", "someOrg", "someIsoSeg")
cmd := generator.EnableOrgIsolation("someOrg", "someIsoSeg")
expectCommandToBeEquivalent(cmd, expectedCmd, cfHomeEnvVar)
})
})

Describe("SetOrgDefaultIsolationSegment", func() {
It("Generates the correct command", func() {
expectedCmd := exec.Command("cf", "set-org-default-isolation-segment", "someOrg", "someIsoSeg")
cmd := generator.SetOrgDefaultIsolationSegment("someOrg", "someIsoSeg")
expectCommandToBeEquivalent(cmd, expectedCmd, cfHomeEnvVar)
})
})
})

func expectCommandToBeEquivalent(cmd cmdStartWaiter.CmdStartWaiter, expectedCmd *exec.Cmd, envIncludes ...string) {
Expand Down
152 changes: 152 additions & 0 deletions cfCmdGenerator/cfCmdGeneratorfakes/fake_cf_cmd_generator.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion cfWorkflow/cfWorkflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,16 @@ func (c *cfWorkflow) Setup(ccg cfCmdGenerator.CfCmdGenerator) []cmdStartWaiter.C
ccg.Api(c.cf.API),
ccg.Auth(c.cf.AdminUser, c.cf.AdminPassword),
ccg.CreateOrg(c.org),
ccg.CreateSpace(c.org, c.space),
}

if c.cf.IsolationSegment != "" {
ret = append(ret,
ccg.EnableOrgIsolation(c.org, c.cf.IsolationSegment),
ccg.SetOrgDefaultIsolationSegment(c.org, c.cf.IsolationSegment),
)
}
ret = append(ret, ccg.CreateSpace(c.org, c.space))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the space need to be created after the org has been designated for an isolation segment? Like, if the flow was create org -> create space -> designate org for an isolation segment, would the space still be designated for an isolation segment? Just curious.


if c.quota != "" {
ret = append(ret, ccg.CreateQuota(c.quota), ccg.SetQuota(c.org, c.quota))
}
Expand Down
19 changes: 19 additions & 0 deletions cfWorkflow/cfWorkflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,25 @@ var _ = Describe("CfWorkflow", func() {
))
})
})
When("Isolation Segments are provided", func() {
BeforeEach(func() { cfc.IsolationSegment = "someIsoSeg" })
It("returns a series of commands including setting up the isolation segment for the org/space", func() {
cmds := cw.Setup(ccg)

Expect(cmds).To(Equal(
[]cmdStartWaiter.CmdStartWaiter{
ccg.Api("jigglypuff.cf-app.com"),
ccg.Auth("pika", "chu"),
ccg.CreateOrg("someOrg"),
ccg.EnableOrgIsolation("someOrg", "someIsoSeg"),
ccg.SetOrgDefaultIsolationSegment("someOrg", "someIsoSeg"),
ccg.CreateSpace("someOrg", "someSpace"),
ccg.CreateQuota("someQuota"),
ccg.SetQuota("someOrg", "someQuota"),
},
))
})
})
})

Describe("TearDown", func() {
Expand Down
9 changes: 5 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ type Command struct {
}

type Cf struct {
API string `json:"api"`
AppDomain string `json:"app_domain"`
AdminUser string `json:"admin_user"`
AdminPassword string `json:"admin_password"`
API string `json:"api"`
AppDomain string `json:"app_domain"`
AdminUser string `json:"admin_user"`
AdminPassword string `json:"admin_password"`
IsolationSegment string `json:"isolation_segment"`

TCPDomain string `json:"tcp_domain"`
TCPPort int `json:"tcp_port"`
Expand Down