Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Foord committed Jan 29, 2016
2 parents 5be5e2c + 1cb8f03 commit c6487b9
Show file tree
Hide file tree
Showing 334 changed files with 12,330 additions and 5,023 deletions.
13 changes: 7 additions & 6 deletions api/addresser/addresser.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (
"github.com/juju/loggo"

"github.com/juju/juju/api/base"
"github.com/juju/juju/api/watcher"
apiwatcher "github.com/juju/juju/api/watcher"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/watcher"
)

var logger = loggo.GetLogger("juju.api.addresser")
Expand Down Expand Up @@ -58,20 +59,20 @@ func (api *API) CleanupIPAddresses() error {
return errors.Trace(result.Error)
}

var newEntityWatcher = watcher.NewEntityWatcher
var newEntitiesWatcher = apiwatcher.NewEntitiesWatcher

// WatchIPAddresses returns a EntityWatcher for observing the
// WatchIPAddresses returns a EntitiesWatcher for observing the
// tags of IP addresses with changes in life cycle.
// The initial event will contain the tags of any IP addresses
// which are no longer Alive.
func (api *API) WatchIPAddresses() (watcher.EntityWatcher, error) {
var result params.EntityWatchResult
func (api *API) WatchIPAddresses() (watcher.EntitiesWatcher, error) {
var result params.EntitiesWatchResult
err := api.facade.FacadeCall("WatchIPAddresses", nil, &result)
if err != nil {
return nil, errors.Trace(err)
}
if result.Error == nil {
w := newEntityWatcher(api.facade.RawAPICaller(), result)
w := newEntitiesWatcher(api.facade.RawAPICaller(), result)
return w, nil
}
return nil, errors.Trace(result.Error)
Expand Down
12 changes: 6 additions & 6 deletions api/addresser/addresser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
"github.com/juju/juju/api/addresser"
"github.com/juju/juju/api/base"
apitesting "github.com/juju/juju/api/base/testing"
"github.com/juju/juju/api/watcher"
"github.com/juju/juju/apiserver/params"
apiservertesting "github.com/juju/juju/apiserver/testing"
coretesting "github.com/juju/juju/testing"
"github.com/juju/juju/watcher"
)

type AddresserSuite struct {
Expand Down Expand Up @@ -97,20 +97,20 @@ func (s *AddresserSuite) TestCleanupIPAddressesServerError(c *gc.C) {
func (s *AddresserSuite) TestWatchIPAddressesSuccess(c *gc.C) {
var numFacadeCalls int
var numWatcherCalls int
expectedResult := params.EntityWatchResult{
EntityWatcherId: "42",
expectedResult := params.EntitiesWatchResult{
EntitiesWatcherId: "42",
Changes: []string{
"ipaddress-11111111-0000-0000-0000-000000000000",
"ipaddress-22222222-0000-0000-0000-000000000000",
},
}
watcherFunc := func(caller base.APICaller, result params.EntityWatchResult) watcher.EntityWatcher {
watcherFunc := func(caller base.APICaller, result params.EntitiesWatchResult) watcher.EntitiesWatcher {
numWatcherCalls++
c.Check(caller, gc.NotNil)
c.Check(result, jc.DeepEquals, expectedResult)
return nil
}
s.PatchValue(addresser.NewEntityWatcher, watcherFunc)
s.PatchValue(addresser.NewEntitiesWatcher, watcherFunc)

apiCaller := successAPICaller(c, "WatchIPAddresses", nil, expectedResult, &numFacadeCalls)
api := addresser.NewAPI(apiCaller)
Expand All @@ -136,7 +136,7 @@ func (s *AddresserSuite) TestWatchIPAddressesClientError(c *gc.C) {

func (s *AddresserSuite) TestWatchIPAddressesServerError(c *gc.C) {
var called int
expectedResult := params.EntityWatchResult{
expectedResult := params.EntitiesWatchResult{
Error: apiservertesting.ServerError("server boom!"),
}
apiCaller := successAPICaller(c, "WatchIPAddresses", nil, expectedResult, &called)
Expand Down
2 changes: 1 addition & 1 deletion api/addresser/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

package addresser

var NewEntityWatcher = &newEntityWatcher
var NewEntitiesWatcher = &newEntitiesWatcher
3 changes: 2 additions & 1 deletion api/base/testing/apicaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
gc "gopkg.in/check.v1"

"github.com/juju/juju/api/base"
coretesting "github.com/juju/juju/testing"
)

// APICallerFunc is a function type that implements APICaller.
Expand All @@ -30,7 +31,7 @@ func (APICallerFunc) BestFacadeVersion(facade string) int {
}

func (APICallerFunc) EnvironTag() (names.EnvironTag, error) {
return names.NewEnvironTag(""), nil
return coretesting.EnvironmentTag, nil
}

func (APICallerFunc) Close() error {
Expand Down
5 changes: 3 additions & 2 deletions api/cleaner/cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ package cleaner

import (
"github.com/juju/juju/api/base"
"github.com/juju/juju/api/watcher"
apiwatcher "github.com/juju/juju/api/watcher"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/watcher"
)

const cleanerFacade = "Cleaner"
Expand Down Expand Up @@ -37,6 +38,6 @@ func (api *API) WatchCleanups() (watcher.NotifyWatcher, error) {
if err := result.Error; err != nil {
return nil, result.Error
}
w := watcher.NewNotifyWatcher(api.facade.RawAPICaller(), result)
w := apiwatcher.NewNotifyWatcher(api.facade.RawAPICaller(), result)
return w, nil
}
5 changes: 3 additions & 2 deletions api/common/apiaddresser.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ package common

import (
"github.com/juju/juju/api/base"
"github.com/juju/juju/api/watcher"
apiwatcher "github.com/juju/juju/api/watcher"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/network"
"github.com/juju/juju/watcher"
)

// APIAddresser provides common client-side API
Expand Down Expand Up @@ -76,5 +77,5 @@ func (a *APIAddresser) WatchAPIHostPorts() (watcher.NotifyWatcher, error) {
if err != nil {
return nil, err
}
return watcher.NewNotifyWatcher(a.facade.RawAPICaller(), result), nil
return apiwatcher.NewNotifyWatcher(a.facade.RawAPICaller(), result), nil
}
5 changes: 3 additions & 2 deletions api/common/environwatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ package common

import (
"github.com/juju/juju/api/base"
"github.com/juju/juju/api/watcher"
apiwatcher "github.com/juju/juju/api/watcher"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/environs/config"
"github.com/juju/juju/watcher"
)

// EnvironWatcher provides common client-side API functions
Expand All @@ -30,7 +31,7 @@ func (e *EnvironWatcher) WatchForEnvironConfigChanges() (watcher.NotifyWatcher,
if err != nil {
return nil, err
}
return watcher.NewNotifyWatcher(e.facade.RawAPICaller(), result), nil
return apiwatcher.NewNotifyWatcher(e.facade.RawAPICaller(), result), nil
}

// EnvironConfig returns the current environment configuration.
Expand Down
5 changes: 3 additions & 2 deletions api/common/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import (
"github.com/juju/names"

"github.com/juju/juju/api/base"
"github.com/juju/juju/api/watcher"
apiwatcher "github.com/juju/juju/api/watcher"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/watcher"
)

// Watch starts a NotifyWatcher for the entity with the specified tag.
Expand All @@ -30,5 +31,5 @@ func Watch(facade base.FacadeCaller, tag names.Tag) (watcher.NotifyWatcher, erro
if result.Error != nil {
return nil, result.Error
}
return watcher.NewNotifyWatcher(facade.RawAPICaller(), result), nil
return apiwatcher.NewNotifyWatcher(facade.RawAPICaller(), result), nil
}
9 changes: 3 additions & 6 deletions api/deployer/deployer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"github.com/juju/juju/juju/testing"
"github.com/juju/juju/network"
"github.com/juju/juju/state"
statetesting "github.com/juju/juju/state/testing"
coretesting "github.com/juju/juju/testing"
"github.com/juju/juju/watcher/watchertest"
)

func TestAll(t *stdtesting.T) {
Expand Down Expand Up @@ -104,8 +104,8 @@ func (s *deployerSuite) TestWatchUnits(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
w, err := machine.WatchUnits()
c.Assert(err, jc.ErrorIsNil)
defer statetesting.AssertStop(c, w)
wc := statetesting.NewStringsWatcherC(c, s.BackingState, w)
wc := watchertest.NewStringsWatcherC(c, w, s.BackingState.StartSync)
defer wc.AssertStops()

// Initial event.
wc.AssertChange("mysql/0", "logging/0")
Expand All @@ -126,9 +126,6 @@ func (s *deployerSuite) TestWatchUnits(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
wc.AssertChange("logging/0")
wc.AssertNoChange()

statetesting.AssertStop(c, w)
wc.AssertClosed()
}

func (s *deployerSuite) TestUnit(c *gc.C) {
Expand Down
5 changes: 3 additions & 2 deletions api/deployer/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (

"github.com/juju/names"

"github.com/juju/juju/api/watcher"
apiwatcher "github.com/juju/juju/api/watcher"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/watcher"
)

// Machine represents a juju machine as seen by the deployer worker.
Expand Down Expand Up @@ -37,6 +38,6 @@ func (m *Machine) WatchUnits() (watcher.StringsWatcher, error) {
if result.Error != nil {
return nil, result.Error
}
w := watcher.NewStringsWatcher(m.st.facade.RawAPICaller(), result)
w := apiwatcher.NewStringsWatcher(m.st.facade.RawAPICaller(), result)
return w, nil
}
7 changes: 4 additions & 3 deletions api/firewaller/firewaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import (

"github.com/juju/juju/api/base"
"github.com/juju/juju/api/common"
"github.com/juju/juju/api/watcher"
apiwatcher "github.com/juju/juju/api/watcher"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/watcher"
)

const firewallerFacade = "Firewaller"
Expand Down Expand Up @@ -85,7 +86,7 @@ func (st *State) WatchEnvironMachines() (watcher.StringsWatcher, error) {
if err := result.Error; err != nil {
return nil, result.Error
}
w := watcher.NewStringsWatcher(st.facade.RawAPICaller(), result)
w := apiwatcher.NewStringsWatcher(st.facade.RawAPICaller(), result)
return w, nil
}

Expand All @@ -111,6 +112,6 @@ func (st *State) WatchOpenedPorts() (watcher.StringsWatcher, error) {
if err := result.Error; err != nil {
return nil, result.Error
}
w := watcher.NewStringsWatcher(st.facade.RawAPICaller(), result)
w := apiwatcher.NewStringsWatcher(st.facade.RawAPICaller(), result)
return w, nil
}
5 changes: 3 additions & 2 deletions api/firewaller/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (

"github.com/juju/names"

"github.com/juju/juju/api/watcher"
apiwatcher "github.com/juju/juju/api/watcher"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/instance"
"github.com/juju/juju/network"
"github.com/juju/juju/watcher"
)

// Machine represents a juju machine as seen by the firewaller worker.
Expand Down Expand Up @@ -43,7 +44,7 @@ func (m *Machine) WatchUnits() (watcher.StringsWatcher, error) {
if result.Error != nil {
return nil, result.Error
}
w := watcher.NewStringsWatcher(m.st.facade.RawAPICaller(), result)
w := apiwatcher.NewStringsWatcher(m.st.facade.RawAPICaller(), result)
return w, nil
}

Expand Down
9 changes: 3 additions & 6 deletions api/firewaller/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/juju/juju/instance"
"github.com/juju/juju/network"
"github.com/juju/juju/state"
statetesting "github.com/juju/juju/state/testing"
"github.com/juju/juju/watcher/watchertest"
)

type machineSuite struct {
Expand Down Expand Up @@ -70,8 +70,8 @@ func (s *machineSuite) TestInstanceId(c *gc.C) {
func (s *machineSuite) TestWatchUnits(c *gc.C) {
w, err := s.apiMachine.WatchUnits()
c.Assert(err, jc.ErrorIsNil)
defer statetesting.AssertStop(c, w)
wc := statetesting.NewStringsWatcherC(c, s.BackingState, w)
wc := watchertest.NewStringsWatcherC(c, w, s.BackingState.StartSync)
defer wc.AssertStops()

// Initial event.
wc.AssertChange("wordpress/0")
Expand All @@ -92,9 +92,6 @@ func (s *machineSuite) TestWatchUnits(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
wc.AssertChange("wordpress/0")
wc.AssertNoChange()

statetesting.AssertStop(c, w)
wc.AssertClosed()
}

func (s *machineSuite) TestActiveNetworks(c *gc.C) {
Expand Down
2 changes: 1 addition & 1 deletion api/firewaller/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/juju/names"

"github.com/juju/juju/api/common"
"github.com/juju/juju/api/watcher"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/watcher"
)

// Service represents the state of a service.
Expand Down
9 changes: 3 additions & 6 deletions api/firewaller/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/juju/juju/api/firewaller"
"github.com/juju/juju/apiserver/params"
statetesting "github.com/juju/juju/state/testing"
"github.com/juju/juju/watcher/watchertest"
)

type serviceSuite struct {
Expand Down Expand Up @@ -47,8 +47,8 @@ func (s *serviceSuite) TestWatch(c *gc.C) {

w, err := s.apiService.Watch()
c.Assert(err, jc.ErrorIsNil)
defer statetesting.AssertStop(c, w)
wc := statetesting.NewNotifyWatcherC(c, s.BackingState, w)
wc := watchertest.NewNotifyWatcherC(c, w, s.BackingState.StartSync)
defer wc.AssertStops()

// Initial event.
wc.AssertOneChange()
Expand All @@ -62,9 +62,6 @@ func (s *serviceSuite) TestWatch(c *gc.C) {
err = s.service.Destroy()
c.Assert(err, jc.ErrorIsNil)
wc.AssertOneChange()

statetesting.AssertStop(c, w)
wc.AssertClosed()
}

func (s *serviceSuite) TestRefresh(c *gc.C) {
Expand Down
Loading

0 comments on commit c6487b9

Please sign in to comment.