Skip to content

Commit

Permalink
Update facade shims and relevant tests to use the new SetExposed sign…
Browse files Browse the repository at this point in the history
…ature
  • Loading branch information
achilleasa committed Sep 3, 2020
1 parent e56d091 commit eef923b
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 32 deletions.
4 changes: 2 additions & 2 deletions api/firewaller/application_test.go
Expand Up @@ -53,7 +53,7 @@ func (s *applicationSuite) TestWatch(c *gc.C) {
wc.AssertOneChange()

// Change something and check it's detected.
err = s.application.SetExposed()
err = s.application.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)
wc.AssertOneChange()

Expand All @@ -64,7 +64,7 @@ func (s *applicationSuite) TestWatch(c *gc.C) {
}

func (s *applicationSuite) TestIsExposed(c *gc.C) {
err := s.application.SetExposed()
err := s.application.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)

isExposed, err := s.apiApplication.IsExposed()
Expand Down
8 changes: 4 additions & 4 deletions apiserver/facades/client/application/application_test.go
Expand Up @@ -2467,7 +2467,7 @@ func (s *applicationSuite) TestApplicationExpose(c *gc.C) {
apps[i] = s.AddTestingApplication(c, name, charm)
c.Assert(apps[i].IsExposed(), jc.IsFalse)
}
err = apps[1].SetExposed()
err = apps[1].SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)
c.Assert(apps[1].IsExposed(), jc.IsTrue)
for i, t := range applicationExposeTests {
Expand All @@ -2493,7 +2493,7 @@ func (s *applicationSuite) setupApplicationExpose(c *gc.C) {
apps[i] = s.AddTestingApplication(c, name, charm)
c.Assert(apps[i].IsExposed(), jc.IsFalse)
}
err = apps[1].SetExposed()
err = apps[1].SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)
c.Assert(apps[1].IsExposed(), jc.IsTrue)
}
Expand Down Expand Up @@ -2594,7 +2594,7 @@ func (s *applicationSuite) TestApplicationUnexpose(c *gc.C) {
c.Logf("test %d. %s", i, t.about)
app := s.AddTestingApplication(c, "dummy-application", charm)
if t.initial {
app.SetExposed()
app.SetExposed(nil, nil, nil)
}
c.Assert(app.IsExposed(), gc.Equals, t.initial)
err := s.applicationAPI.Unexpose(params.ApplicationUnexpose{t.application})
Expand All @@ -2613,7 +2613,7 @@ func (s *applicationSuite) TestApplicationUnexpose(c *gc.C) {
func (s *applicationSuite) setupApplicationUnexpose(c *gc.C) *state.Application {
charm := s.AddTestingCharm(c, "dummy")
app := s.AddTestingApplication(c, "dummy-application", charm)
app.SetExposed()
app.SetExposed(nil, nil, nil)
c.Assert(app.IsExposed(), gc.Equals, true)
return app
}
Expand Down
6 changes: 6 additions & 0 deletions apiserver/facades/client/application/backend.go
Expand Up @@ -445,6 +445,12 @@ func (a stateApplicationShim) EndpointBindings() (Bindings, error) {
return a.Application.EndpointBindings()
}

func (a stateApplicationShim) SetExposed() error {
// TODO(achilleas): Remove this method once the required API changes
// for working with the additional expose parameters land.
return a.Application.SetExposed(nil, nil, nil)
}

type stateCharmShim struct {
*state.Charm
}
Expand Down
Expand Up @@ -343,7 +343,7 @@ func (s *firewallerBaseSuite) testGetExposed(
},
) {
// Set the application to exposed first.
err := s.application.SetExposed()
err := s.application.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)

args := addFakeEntities(params.Entities{Entities: []params.Entity{
Expand Down
2 changes: 1 addition & 1 deletion cmd/juju/status/status_internal_test.go
Expand Up @@ -4133,7 +4133,7 @@ func (sse setApplicationExposed) step(c *gc.C, ctx *context) {
err = s.ClearExposed()
c.Assert(err, jc.ErrorIsNil)
if sse.exposed {
err = s.SetExposed()
err = s.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)
}
}
Expand Down
48 changes: 24 additions & 24 deletions worker/firewaller/firewaller_test.go
Expand Up @@ -268,7 +268,7 @@ func (s *InstanceModeSuite) TestExposedApplication(c *gc.C) {

app := s.AddTestingApplication(c, "wordpress", s.charm)

err := app.SetExposed()
err := app.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)
u, m := s.addUnit(c, app)
inst := s.startInstance(c, m)
Expand Down Expand Up @@ -297,7 +297,7 @@ func (s *InstanceModeSuite) TestMultipleExposedApplications(c *gc.C) {
defer statetesting.AssertKillAndWait(c, fw)

app1 := s.AddTestingApplication(c, "wordpress", s.charm)
err := app1.SetExposed()
err := app1.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)

u1, m1 := s.addUnit(c, app1)
Expand All @@ -309,7 +309,7 @@ func (s *InstanceModeSuite) TestMultipleExposedApplications(c *gc.C) {

app2 := s.AddTestingApplication(c, "mysql", s.charm)
c.Assert(err, jc.ErrorIsNil)
err = app2.SetExposed()
err = app2.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)

u2, m2 := s.addUnit(c, app2)
Expand Down Expand Up @@ -344,7 +344,7 @@ func (s *InstanceModeSuite) TestMachineWithoutInstanceId(c *gc.C) {
defer statetesting.AssertKillAndWait(c, fw)

app := s.AddTestingApplication(c, "wordpress", s.charm)
err := app.SetExposed()
err := app.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)
// add a unit but don't start its instance yet.
u1, m1 := s.addUnit(c, app)
Expand Down Expand Up @@ -374,7 +374,7 @@ func (s *InstanceModeSuite) TestMultipleUnits(c *gc.C) {
defer statetesting.AssertKillAndWait(c, fw)

app := s.AddTestingApplication(c, "wordpress", s.charm)
err := app.SetExposed()
err := app.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)

u1, m1 := s.addUnit(c, app)
Expand Down Expand Up @@ -409,7 +409,7 @@ func (s *InstanceModeSuite) TestMultipleUnits(c *gc.C) {

func (s *InstanceModeSuite) TestStartWithState(c *gc.C) {
app := s.AddTestingApplication(c, "wordpress", s.charm)
err := app.SetExposed()
err := app.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)
u, m := s.addUnit(c, app)
inst := s.startInstance(c, m)
Expand All @@ -431,7 +431,7 @@ func (s *InstanceModeSuite) TestStartWithState(c *gc.C) {
firewall.NewIngressRule(network.MustParsePortRange("8080/tcp"), firewall.AllNetworksIPV4CIDR),
})

err = app.SetExposed()
err = app.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)
}

Expand All @@ -441,7 +441,7 @@ func (s *InstanceModeSuite) TestStartWithPartialState(c *gc.C) {
inst := s.startInstance(c, m)

app := s.AddTestingApplication(c, "wordpress", s.charm)
err = app.SetExposed()
err = app.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)

// Starting the firewaller, no open ports.
Expand Down Expand Up @@ -485,7 +485,7 @@ func (s *InstanceModeSuite) TestStartWithUnexposedApplication(c *gc.C) {
s.assertPorts(c, inst, m.Id(), nil)

// Expose service.
err = app.SetExposed()
err = app.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)
s.assertPorts(c, inst, m.Id(), firewall.IngressRules{
firewall.NewIngressRule(network.MustParsePortRange("80/tcp"), firewall.AllNetworksIPV4CIDR),
Expand Down Expand Up @@ -540,7 +540,7 @@ func (s *InstanceModeSuite) TestSetClearExposedApplication(c *gc.C) {
s.assertPorts(c, inst, m.Id(), nil)

// SeExposed opens the ports.
err := app.SetExposed()
err := app.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)

s.assertPorts(c, inst, m.Id(), firewall.IngressRules{
Expand All @@ -560,7 +560,7 @@ func (s *InstanceModeSuite) TestRemoveUnit(c *gc.C) {
defer statetesting.AssertKillAndWait(c, fw)

app := s.AddTestingApplication(c, "wordpress", s.charm)
err := app.SetExposed()
err := app.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)

u1, m1 := s.addUnit(c, app)
Expand Down Expand Up @@ -599,7 +599,7 @@ func (s *InstanceModeSuite) TestRemoveApplication(c *gc.C) {
defer statetesting.AssertKillAndWait(c, fw)

app := s.AddTestingApplication(c, "wordpress", s.charm)
err := app.SetExposed()
err := app.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)

u, m := s.addUnit(c, app)
Expand Down Expand Up @@ -627,7 +627,7 @@ func (s *InstanceModeSuite) TestRemoveMultipleApplications(c *gc.C) {
defer statetesting.AssertKillAndWait(c, fw)

app1 := s.AddTestingApplication(c, "wordpress", s.charm)
err := app1.SetExposed()
err := app1.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)

u1, m1 := s.addUnit(c, app1)
Expand All @@ -637,7 +637,7 @@ func (s *InstanceModeSuite) TestRemoveMultipleApplications(c *gc.C) {
})

app2 := s.AddTestingApplication(c, "mysql", s.charm)
err = app2.SetExposed()
err = app2.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)

u2, m2 := s.addUnit(c, app2)
Expand Down Expand Up @@ -677,7 +677,7 @@ func (s *InstanceModeSuite) TestDeadMachine(c *gc.C) {
defer statetesting.AssertKillAndWait(c, fw)

app := s.AddTestingApplication(c, "wordpress", s.charm)
err := app.SetExposed()
err := app.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)

u, m := s.addUnit(c, app)
Expand Down Expand Up @@ -711,7 +711,7 @@ func (s *InstanceModeSuite) TestRemoveMachine(c *gc.C) {
fw := s.newFirewaller(c)

app := s.AddTestingApplication(c, "wordpress", s.charm)
err := app.SetExposed()
err := app.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)

u, m := s.addUnit(c, app)
Expand Down Expand Up @@ -752,7 +752,7 @@ func (s *InstanceModeSuite) TestRemoveMachine(c *gc.C) {

func (s *InstanceModeSuite) TestStartWithStateOpenPortsBroken(c *gc.C) {
app := s.AddTestingApplication(c, "wordpress", s.charm)
err := app.SetExposed()
err := app.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)
u, m := s.addUnit(c, app)
inst := s.startInstance(c, m)
Expand Down Expand Up @@ -1332,7 +1332,7 @@ func (s *GlobalModeSuite) TestGlobalMode(c *gc.C) {
defer statetesting.AssertKillAndWait(c, fw)

app1 := s.AddTestingApplication(c, "wordpress", s.charm)
err := app1.SetExposed()
err := app1.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)

u1, m1 := s.addUnit(c, app1)
Expand All @@ -1344,7 +1344,7 @@ func (s *GlobalModeSuite) TestGlobalMode(c *gc.C) {

app2 := s.AddTestingApplication(c, "moinmoin", s.charm)
c.Assert(err, jc.ErrorIsNil)
err = app2.SetExposed()
err = app2.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)

u2, m2 := s.addUnit(c, app2)
Expand Down Expand Up @@ -1403,7 +1403,7 @@ func (s *GlobalModeSuite) TestStartWithUnexposedApplication(c *gc.C) {
s.assertEnvironPorts(c, nil)

// Expose application.
err = app.SetExposed()
err = app.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)
s.assertEnvironPorts(c, firewall.IngressRules{
firewall.NewIngressRule(network.MustParsePortRange("80/tcp"), firewall.AllNetworksIPV4CIDR),
Expand All @@ -1415,7 +1415,7 @@ func (s *GlobalModeSuite) TestRestart(c *gc.C) {
fw := s.newFirewaller(c)

app := s.AddTestingApplication(c, "wordpress", s.charm)
err := app.SetExposed()
err := app.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)

u, m := s.addUnit(c, app)
Expand Down Expand Up @@ -1457,7 +1457,7 @@ func (s *GlobalModeSuite) TestRestartUnexposedApplication(c *gc.C) {
fw := s.newFirewaller(c)

app := s.AddTestingApplication(c, "wordpress", s.charm)
err := app.SetExposed()
err := app.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)

u, m := s.addUnit(c, app)
Expand Down Expand Up @@ -1491,7 +1491,7 @@ func (s *GlobalModeSuite) TestRestartPortCount(c *gc.C) {
fw := s.newFirewaller(c)

app1 := s.AddTestingApplication(c, "wordpress", s.charm)
err := app1.SetExposed()
err := app1.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)

u1, m1 := s.addUnit(c, app1)
Expand All @@ -1511,7 +1511,7 @@ func (s *GlobalModeSuite) TestRestartPortCount(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)

app2 := s.AddTestingApplication(c, "moinmoin", s.charm)
err = app2.SetExposed()
err = app2.SetExposed(nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)

u2, m2 := s.addUnit(c, app2)
Expand Down

0 comments on commit eef923b

Please sign in to comment.