Skip to content

Commit

Permalink
Bump all facade versions and consolidate old facades
Browse files Browse the repository at this point in the history
  • Loading branch information
wallyworld committed Jan 22, 2016
1 parent 02efef0 commit b79335e
Show file tree
Hide file tree
Showing 85 changed files with 1,278 additions and 2,588 deletions.
15 changes: 0 additions & 15 deletions api/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,21 +469,6 @@ func (s *clientSuite) TestWatchDebugLogParamsEncoded(c *gc.C) {
})
}

func (s *clientSuite) TestConnectStreamRootPath(c *gc.C) {
s.PatchValue(api.WebsocketDialConfig, echoURL(c))

// If the server is old, we connect to /path.
info := s.APIInfo(c)
info.EnvironTag = names.NewEnvironTag("")
apistate, err := api.OpenWithVersion(info, api.DialOpts{}, 1)
c.Assert(err, jc.ErrorIsNil)
defer apistate.Close()
reader, err := apistate.ConnectStream("/path", nil)
c.Assert(err, jc.ErrorIsNil)
connectURL := connectURLFromReader(c, reader)
c.Assert(connectURL.Path, gc.Matches, "/path")
}

func (s *clientSuite) TestConnectStreamAtUUIDPath(c *gc.C) {
s.PatchValue(api.WebsocketDialConfig, echoURL(c))
// If the server supports it, we should log at "/environment/UUID/log"
Expand Down
106 changes: 53 additions & 53 deletions api/facadeversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,59 +11,59 @@ package api
// New facades should start at 1.
// Facades that existed before versioning start at 0.
var facadeVersions = map[string]int{
"Action": 0,
"Addresser": 1,
"Agent": 1,
"AllWatcher": 0,
"AllEnvWatcher": 1,
"Annotations": 1,
"Backups": 0,
"Block": 1,
"Charms": 1,
"CharmRevisionUpdater": 0,
"Client": 0,
"Cleaner": 1,
"Controller": 1,
"Deployer": 0,
"DiskManager": 1,
"EntityWatcher": 1,
"Environment": 0,
"EnvironmentManager": 1,
"FilesystemAttachmentsWatcher": 1,
"Firewaller": 1,
"HighAvailability": 1,
"ImageManager": 1,
"ImageMetadata": 1,
"InstancePoller": 1,
"KeyManager": 0,
"KeyUpdater": 0,
"LeadershipService": 1,
"Logger": 0,
"MachineManager": 1,
"Machiner": 0,
"MetricsManager": 0,
"MeterStatus": 1,
"MetricsAdder": 1,
"Networker": 0,
"NotifyWatcher": 0,
"Pinger": 0,
"Provisioner": 1,
"Reboot": 1,
"RelationUnitsWatcher": 0,
"Resumer": 1,
"Service": 2,
"Storage": 1,
"Spaces": 1,
"Subnets": 1,
"StatusHistory": 1,
"StorageProvisioner": 1,
"StringsWatcher": 0,
"Upgrader": 0,
"UnitAssigner": 1,
"Uniter": 2,
"UserManager": 0,
"VolumeAttachmentsWatcher": 1,
"Undertaker": 1,
"Action": 1,
"Addresser": 2,
"Agent": 2,
"AllWatcher": 1,
"AllEnvWatcher": 2,
"Annotations": 2,
"Backups": 1,
"Block": 2,
"Charms": 2,
"CharmRevisionUpdater": 1,
"Client": 1,
"Cleaner": 2,
"Controller": 2,
"Deployer": 1,
"DiskManager": 2,
"EntityWatcher": 2,
"Environment": 1,
"EnvironmentManager": 2,
"FilesystemAttachmentsWatcher": 2,
"Firewaller": 2,
"HighAvailability": 2,
"ImageManager": 2,
"ImageMetadata": 2,
"InstancePoller": 2,
"KeyManager": 1,
"KeyUpdater": 1,
"LeadershipService": 2,
"Logger": 1,
"MachineManager": 2,
"Machiner": 1,
"MetricsManager": 1,
"MeterStatus": 2,
"MetricsAdder": 2,
"Networker": 1,
"NotifyWatcher": 1,
"Pinger": 1,
"Provisioner": 2,
"Reboot": 2,
"RelationUnitsWatcher": 1,
"Resumer": 2,
"Service": 3,
"Storage": 2,
"Spaces": 2,
"Subnets": 2,
"StatusHistory": 2,
"StorageProvisioner": 2,
"StringsWatcher": 1,
"Upgrader": 1,
"UnitAssigner": 2,
"Uniter": 3,
"UserManager": 1,
"VolumeAttachmentsWatcher": 2,
"Undertaker": 2,
}

// bestVersion tries to find the newest version in the version list that we can
Expand Down
4 changes: 2 additions & 2 deletions api/highavailability/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (s *clientSuite) TestClientEnsureAvailability(c *gc.C) {

func (s *clientSuite) TestClientEnsureAvailabilityVersion(c *gc.C) {
client := highavailability.NewClient(s.APIState)
c.Assert(client.BestAPIVersion(), gc.Equals, 1)
c.Assert(client.BestAPIVersion(), gc.Equals, 2)
}

type clientLegacySuite struct {
Expand All @@ -88,7 +88,7 @@ type clientLegacySuite struct {
var _ = gc.Suite(&clientLegacySuite{})

func (s *clientLegacySuite) SetUpTest(c *gc.C) {
common.Facades.Discard("HighAvailability", 1)
common.Facades.Discard("HighAvailability", 2)
s.JujuConnSuite.SetUpTest(c)
}

Expand Down
2 changes: 1 addition & 1 deletion api/keymanager/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,5 @@ func (s *keymanagerSuite) TestImportKeysInvalidUser(c *gc.C) {
}

func (s *keymanagerSuite) TestExposesBestAPIVersion(c *gc.C) {
c.Check(s.keymanager.BestAPIVersion(), gc.Equals, 0)
c.Check(s.keymanager.BestAPIVersion(), gc.Equals, 1)
}
4 changes: 2 additions & 2 deletions api/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (s *stateSuite) TestLoginTracksFacadeVersions(c *gc.C) {
c.Check(allVersions, gc.Not(gc.HasLen), 0)
// For sanity checking, ensure that we have a v2 of the Client facade
c.Assert(allVersions["Client"], gc.Not(gc.HasLen), 0)
c.Check(allVersions["Client"][0], gc.Equals, 0)
c.Check(allVersions["Client"][0], gc.Equals, 1)
}

func (s *stateSuite) TestAllFacadeVersionsSafeFromMutation(c *gc.C) {
Expand All @@ -124,7 +124,7 @@ func (s *stateSuite) TestAllFacadeVersionsSafeFromMutation(c *gc.C) {
}

func (s *stateSuite) TestBestFacadeVersion(c *gc.C) {
c.Check(s.APIState.BestFacadeVersion("Client"), gc.Equals, 0)
c.Check(s.APIState.BestFacadeVersion("Client"), gc.Equals, 1)
}

func (s *stateSuite) TestAPIHostPortsMovesConnectedValueFirst(c *gc.C) {
Expand Down
5 changes: 2 additions & 3 deletions api/uniter/export_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright 2013 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package uniter

import (
Expand All @@ -13,11 +14,9 @@ import (

var (
NewSettings = newSettings
NewStateV0 = newStateV0
NewStateV1 = newStateV1
)

// PatchResponses changes the internal FacadeCaller to one that lets you return
// PatchUnitResponse changes the internal FacadeCaller to one that lets you return
// canned results. The responseFunc will get the 'response' interface object,
// and can set attributes of it to fix the response to the caller.
// It can also return an error to have the FacadeCall return an error. The expected
Expand Down
23 changes: 1 addition & 22 deletions api/uniter/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"

"github.com/juju/juju/api/base"
"github.com/juju/juju/api/uniter"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/state"
Expand Down Expand Up @@ -121,32 +120,12 @@ func (s *serviceSuite) TestCharmURL(c *gc.C) {
c.Assert(force, jc.IsFalse)
}

func (s *serviceSuite) TestOwnerTagV0(c *gc.C) {
s.patchNewState(c, uniter.NewStateV0)

tag, err := s.apiService.OwnerTag()
c.Assert(err, jc.ErrorIsNil)
c.Assert(tag, gc.Equals, s.AdminUserTag(c))
}

func (s *serviceSuite) TestOwnerTagV1(c *gc.C) {
s.patchNewState(c, uniter.NewStateV1)

func (s *serviceSuite) TestOwnerTag(c *gc.C) {
tag, err := s.apiService.OwnerTag()
c.Assert(err, jc.ErrorIsNil)
c.Assert(tag, gc.Equals, s.AdminUserTag(c))
}

func (s *serviceSuite) patchNewState(
c *gc.C,
patchFunc func(_ base.APICaller, _ names.UnitTag) *uniter.State,
) {
s.uniterSuite.patchNewState(c, patchFunc)
var err error
s.apiService, err = s.uniter.Service(s.wordpressService.Tag().(names.ServiceTag))
c.Assert(err, jc.ErrorIsNil)
}

func (s *serviceSuite) TestSetServiceStatus(c *gc.C) {
message := "a test message"
stat, err := s.wordpressService.Status()
Expand Down
15 changes: 1 addition & 14 deletions api/uniter/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
package uniter_test

import (
"github.com/juju/errors"
"github.com/juju/names"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"

apitesting "github.com/juju/juju/api/testing"
"github.com/juju/juju/api/uniter"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/network"
)
Expand Down Expand Up @@ -38,18 +36,7 @@ func (s *stateSuite) TestProviderType(c *gc.C) {
c.Assert(providerType, gc.DeepEquals, cfg.Type())
}

func (s *stateSuite) TestAllMachinePortsV0NotImplemented(c *gc.C) {
s.patchNewState(c, uniter.NewStateV0)

ports, err := s.uniter.AllMachinePorts(s.wordpressMachine.Tag().(names.MachineTag))
c.Assert(err, jc.Satisfies, errors.IsNotImplemented)
c.Assert(err.Error(), gc.Equals, "AllMachinePorts() (need V1+) not implemented")
c.Assert(ports, gc.IsNil)
}

func (s *stateSuite) TestAllMachinePortsV1(c *gc.C) {
s.patchNewState(c, uniter.NewStateV1)

func (s *stateSuite) TestAllMachinePorts(c *gc.C) {
// Verify no ports are opened yet on the machine or unit.
machinePorts, err := s.wordpressMachine.AllPorts()
c.Assert(err, jc.ErrorIsNil)
Expand Down
14 changes: 7 additions & 7 deletions api/uniter/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (s *storageSuite) TestUnitStorageAttachments(c *gc.C) {
var called bool
apiCaller := testing.APICallerFunc(func(objType string, version int, id, request string, arg, result interface{}) error {
c.Check(objType, gc.Equals, "Uniter")
c.Check(version, gc.Equals, 2)
c.Check(version, gc.Equals, 3)
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, "UnitStorageAttachments")
c.Check(arg, gc.DeepEquals, params.Entities{
Expand All @@ -57,7 +57,7 @@ func (s *storageSuite) TestDestroyUnitStorageAttachments(c *gc.C) {
var called bool
apiCaller := testing.APICallerFunc(func(objType string, version int, id, request string, arg, result interface{}) error {
c.Check(objType, gc.Equals, "Uniter")
c.Check(version, gc.Equals, 2)
c.Check(version, gc.Equals, 3)
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, "DestroyUnitStorageAttachments")
c.Check(arg, gc.DeepEquals, params.Entities{
Expand Down Expand Up @@ -103,7 +103,7 @@ func (s *storageSuite) TestWatchUnitStorageAttachments(c *gc.C) {
var called bool
apiCaller := testing.APICallerFunc(func(objType string, version int, id, request string, arg, result interface{}) error {
c.Check(objType, gc.Equals, "Uniter")
c.Check(version, gc.Equals, 2)
c.Check(version, gc.Equals, 3)
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, "WatchUnitStorageAttachments")
c.Check(arg, gc.DeepEquals, params.Entities{
Expand All @@ -129,7 +129,7 @@ func (s *storageSuite) TestWatchStorageAttachments(c *gc.C) {
var called bool
apiCaller := testing.APICallerFunc(func(objType string, version int, id, request string, arg, result interface{}) error {
c.Check(objType, gc.Equals, "Uniter")
c.Check(version, gc.Equals, 2)
c.Check(version, gc.Equals, 3)
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, "WatchStorageAttachments")
c.Check(arg, gc.DeepEquals, params.StorageAttachmentIds{
Expand Down Expand Up @@ -166,7 +166,7 @@ func (s *storageSuite) TestStorageAttachments(c *gc.C) {
var called bool
apiCaller := testing.APICallerFunc(func(objType string, version int, id, request string, arg, result interface{}) error {
c.Check(objType, gc.Equals, "Uniter")
c.Check(version, gc.Equals, 2)
c.Check(version, gc.Equals, 3)
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, "StorageAttachments")
c.Check(arg, gc.DeepEquals, params.StorageAttachmentIds{
Expand Down Expand Up @@ -195,7 +195,7 @@ func (s *storageSuite) TestStorageAttachments(c *gc.C) {
func (s *storageSuite) TestStorageAttachmentLife(c *gc.C) {
apiCaller := testing.APICallerFunc(func(objType string, version int, id, request string, arg, result interface{}) error {
c.Check(objType, gc.Equals, "Uniter")
c.Check(version, gc.Equals, 2)
c.Check(version, gc.Equals, 3)
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, "StorageAttachmentLife")
c.Check(arg, gc.DeepEquals, params.StorageAttachmentIds{
Expand Down Expand Up @@ -225,7 +225,7 @@ func (s *storageSuite) TestStorageAttachmentLife(c *gc.C) {
func (s *storageSuite) TestRemoveStorageAttachment(c *gc.C) {
apiCaller := testing.APICallerFunc(func(objType string, version int, id, request string, arg, result interface{}) error {
c.Check(objType, gc.Equals, "Uniter")
c.Check(version, gc.Equals, 2)
c.Check(version, gc.Equals, 3)
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, "RemoveStorageAttachments")
c.Check(arg, gc.DeepEquals, params.StorageAttachmentIds{
Expand Down
39 changes: 1 addition & 38 deletions api/uniter/unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,33 +121,6 @@ func (s *unitSuite) TestSetUnitStatus(c *gc.C) {
c.Assert(agentStatusInfo.Data, gc.HasLen, 0)
}

func (s *unitSuite) TestSetUnitStatusOldServer(c *gc.C) {
s.patchNewState(c, uniter.NewStateV1)

err := s.apiUnit.SetUnitStatus(params.StatusActive, "blah", nil)
c.Assert(err, jc.Satisfies, errors.IsNotImplemented)
c.Assert(err.Error(), gc.Equals, "SetUnitStatus not implemented")
}

func (s *unitSuite) TestSetAgentStatusOldServer(c *gc.C) {
s.patchNewState(c, uniter.NewStateV1)

statusInfo, err := s.wordpressUnit.Status()
c.Assert(err, jc.ErrorIsNil)
c.Assert(statusInfo.Status, gc.Equals, state.StatusUnknown)
c.Assert(statusInfo.Message, gc.Equals, "Waiting for agent initialization to finish")
c.Assert(statusInfo.Data, gc.HasLen, 0)

err = s.apiUnit.SetAgentStatus(params.StatusIdle, "blah", nil)
c.Assert(err, jc.ErrorIsNil)

statusInfo, err = s.wordpressUnit.AgentStatus()
c.Assert(err, jc.ErrorIsNil)
c.Assert(statusInfo.Status, gc.Equals, state.StatusIdle)
c.Assert(statusInfo.Message, gc.Equals, "blah")
c.Assert(statusInfo.Data, gc.HasLen, 0)
}

func (s *unitSuite) TestUnitStatus(c *gc.C) {
err := s.wordpressUnit.SetStatus(state.StatusMaintenance, "blah", nil)
c.Assert(err, jc.ErrorIsNil)
Expand Down Expand Up @@ -278,17 +251,7 @@ func (s *unitSuite) TestResolve(c *gc.C) {
c.Assert(mode, gc.Equals, params.ResolvedNone)
}

func (s *unitSuite) TestAssignedMachineV0NotImplemented(c *gc.C) {
s.patchNewState(c, uniter.NewStateV0)

_, err := s.apiUnit.AssignedMachine()
c.Assert(err, jc.Satisfies, errors.IsNotImplemented)
c.Assert(err.Error(), gc.Equals, "unit.AssignedMachine() (need V1+) not implemented")
}

func (s *unitSuite) TestAssignedMachineV1(c *gc.C) {
s.patchNewState(c, uniter.NewStateV1)

func (s *unitSuite) TestAssignedMachine(c *gc.C) {
machineTag, err := s.apiUnit.AssignedMachine()
c.Assert(err, jc.ErrorIsNil)
c.Assert(machineTag, gc.Equals, s.wordpressMachine.Tag())
Expand Down
Loading

0 comments on commit b79335e

Please sign in to comment.