Skip to content

Commit

Permalink
Fix failing tests by fixing places that still used series not os type
Browse files Browse the repository at this point in the history
  • Loading branch information
wallyworld committed Mar 20, 2021
1 parent b7002c6 commit 4abe064
Show file tree
Hide file tree
Showing 55 changed files with 241 additions and 183 deletions.
4 changes: 2 additions & 2 deletions api/charms/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (c *Client) AddCharm(curl *charm.URL, origin apicharm.Origin, force bool) (
URL: curl.String(),
Origin: origin.ParamsCharmOrigin(),
Force: force,
// Deprecated: Series is used here to communicate with older
// Deprecated: Release is used here to communicate with older
// controllers and instead we use Origin to describe the platform.
Series: origin.Series,
}
Expand Down Expand Up @@ -174,7 +174,7 @@ func (c *Client) AddCharmWithAuthorization(curl *charm.URL, origin apicharm.Orig
Origin: origin.ParamsCharmOrigin(),
CharmStoreMacaroon: csMac,
Force: force,
// Deprecated: Series is used here to communicate with older
// Deprecated: Release is used here to communicate with older
// controllers and instead we use Origin to describe the platform.
Series: origin.Series,
}
Expand Down
4 changes: 2 additions & 2 deletions api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func (c *Client) AbortCurrentUpgrade() error {
}

// FindTools returns a List containing all tools matching the specified parameters.
func (c *Client) FindTools(majorVersion, minorVersion int, series, arch, agentStream string) (result params.FindToolsResult, err error) {
func (c *Client) FindTools(majorVersion, minorVersion int, osType, arch, agentStream string) (result params.FindToolsResult, err error) {
if c.facade.BestAPIVersion() == 1 && agentStream != "" {
return params.FindToolsResult{}, errors.New(
"passing agent-stream not supported by the controller")
Expand All @@ -301,7 +301,7 @@ func (c *Client) FindTools(majorVersion, minorVersion int, series, arch, agentSt
MajorVersion: majorVersion,
MinorVersion: minorVersion,
Arch: arch,
Series: series,
OSType: osType,
AgentStream: agentStream,
}
err = c.facade.FacadeCall("FindTools", args, &result)
Expand Down
3 changes: 2 additions & 1 deletion api/provisioner/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/life"
corenetwork "github.com/juju/juju/core/network"
coreseries "github.com/juju/juju/core/series"
"github.com/juju/juju/core/watcher"
"github.com/juju/juju/network"
"github.com/juju/juju/tools"
Expand Down Expand Up @@ -202,7 +203,7 @@ func (st *State) MachinesWithTransientErrors() ([]MachineStatusResult, error) {
func (st *State) FindTools(v version.Number, series string, arch string) (tools.List, error) {
args := params.FindToolsParams{
Number: v,
Series: series,
OSType: coreseries.DefaultOSTypeNameFromSeries(series),
MajorVersion: -1,
MinorVersion: -1,
}
Expand Down
4 changes: 2 additions & 2 deletions api/provisioner/provisioner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ func (s *provisionerSuite) testFindTools(c *gc.C, matchArch bool, apiError, logi
c.Assert(request, gc.Equals, "FindTools")
expected := params.FindToolsParams{
Number: jujuversion.Current,
Series: current.Release,
OSType: "ubuntu",
Arch: a,
MinorVersion: -1,
MajorVersion: -1,
Expand All @@ -800,7 +800,7 @@ func (s *provisionerSuite) testFindTools(c *gc.C, matchArch bool, apiError, logi
}
return apiError
})
apiList, err := s.provisioner.FindTools(jujuversion.Current, current.Release, a)
apiList, err := s.provisioner.FindTools(jujuversion.Current, "xenial", a)
c.Assert(called, jc.IsTrue)
if apiError != nil {
c.Assert(err, gc.Equals, apiError)
Expand Down
4 changes: 2 additions & 2 deletions apiserver/common/mocks/upgradeseries.go

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

14 changes: 11 additions & 3 deletions apiserver/common/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
apiservererrors "github.com/juju/juju/apiserver/errors"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/network"
coreseries "github.com/juju/juju/core/series"
"github.com/juju/juju/environs"
envtools "github.com/juju/juju/environs/tools"
"github.com/juju/juju/state"
Expand Down Expand Up @@ -148,7 +149,7 @@ func (t *ToolsGetter) oneAgentTools(canRead AuthFunc, tag names.Tag, agentVersio
Number: agentVersion,
MajorVersion: -1,
MinorVersion: -1,
Series: existingTools.Version.Release,
OSType: existingTools.Version.Release,
Arch: existingTools.Version.Arch,
})
if err != nil {
Expand Down Expand Up @@ -266,7 +267,7 @@ func (f *ToolsFinder) findTools(args params.FindToolsParams) (coretools.List, er
// given parameters. If an exact match is specified (number, series and arch)
// and is found in tools storage, then simplestreams will not be searched.
func (f *ToolsFinder) findMatchingTools(args params.FindToolsParams) (coretools.List, error) {
exactMatch := args.Number != version.Zero && args.Series != "" && args.Arch != ""
exactMatch := args.Number != version.Zero && (args.OSType != "" || args.Series != "") && args.Arch != ""
storageList, err := f.matchingStorageTools(args)
if err == nil && exactMatch {
return storageList, nil
Expand Down Expand Up @@ -353,10 +354,17 @@ func (f *ToolsFinder) matchingStorageTools(args params.FindToolsParams) (coretoo
}

func toolsFilter(args params.FindToolsParams) coretools.Filter {
var release string
if args.Series != "" {
release = coreseries.DefaultOSTypeNameFromSeries(args.Series)
}
if args.OSType != "" {
release = args.OSType
}
return coretools.Filter{
Number: args.Number,
Arch: args.Arch,
OSType: args.OSType,
OSType: release,
}
}

Expand Down
6 changes: 3 additions & 3 deletions apiserver/common/tools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (s *toolsSuite) TestFindTools(c *gc.C) {
result, err := toolsFinder.FindTools(params.FindToolsParams{
MajorVersion: 123,
MinorVersion: 456,
Series: "windows",
OSType: "windows",
Arch: "alpha",
AgentStream: test.agentStreamRequested,
})
Expand Down Expand Up @@ -268,7 +268,7 @@ func (s *toolsSuite) testFindToolsExact(c *gc.C, t common.ToolsStorageGetter, in
s.PatchValue(common.EnvtoolsFindTools, func(e environs.BootstrapEnviron, major, minor int, stream []string, filter coretools.Filter) (list coretools.List, err error) {
called = true
c.Assert(filter.Number, gc.Equals, jujuversion.Current)
c.Assert(filter.OSType, gc.Equals, current.OSType)
c.Assert(filter.OSType, gc.Equals, current.Release)
c.Assert(filter.Arch, gc.Equals, arch.HostArch())
if develVersion {
c.Assert(stream, gc.DeepEquals, []string{"devel", "proposed", "released"})
Expand All @@ -285,7 +285,7 @@ func (s *toolsSuite) testFindToolsExact(c *gc.C, t common.ToolsStorageGetter, in
Number: jujuversion.Current,
MajorVersion: -1,
MinorVersion: -1,
Series: current.OSType,
OSType: current.Release,
Arch: arch.HostArch(),
})
c.Assert(err, jc.ErrorIsNil)
Expand Down
16 changes: 8 additions & 8 deletions apiserver/facades/client/application/application_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ func (s *ApplicationSuite) SetUpTest(c *gc.C) {
agentTools := &tools.Tools{
Version: version.Binary{
Number: version.Number{Major: 2, Minor: 6, Patch: 0},
OSType: "Bionic",
Release: "ubuntu",
Arch: "x86",
},
}
olderAgentTools := &tools.Tools{
Version: version.Binary{
Number: version.Number{Major: 2, Minor: 5, Patch: 1},
OSType: "Bionic",
Release: "ubuntu",
Arch: "x86",
},
}
Expand Down Expand Up @@ -1126,7 +1126,7 @@ func (s *ApplicationSuite) TestDeployCAASModelCharmNeedsNoOperatorStorage(c *gc.
s.PatchValue(&jujuversion.Current, version.MustParse("2.8-beta1"))
s.backend.charm = &mockCharm{
meta: &charm.Meta{
MinJujuVersion: version.MustParse("2.8.0"),
MinJujuVersion: jujuversion.ToVersion1(version.MustParse("2.8.0")),
},
}

Expand Down Expand Up @@ -1783,10 +1783,10 @@ func (s *ApplicationSuite) TestApplicationUpdateSeries(c *gc.C) {

app := s.backend.applications["postgresql"]
app.CheckCall(c, 0, "IsPrincipal")
app.CheckCall(c, 1, "OSType")
app.CheckCall(c, 1, "Series")
app.CheckCall(c, 2, "UpdateApplicationSeries", "trusty", false)
app.CheckCall(c, 3, "IsPrincipal")
app.CheckCall(c, 4, "OSType")
app.CheckCall(c, 4, "Series")
// ensure that app.UpdateApplicationSeries wasn't called a 2nd time.
c.Assert(len(app.Calls()), gc.Equals, 5)
}
Expand Down Expand Up @@ -2161,7 +2161,7 @@ func (s *ApplicationSuite) TestApplicationsInfoOne(c *gc.C) {
},
})
app := s.backend.applications["test-app-info"]
app.CheckCallNames(c, "CharmConfig", "Charm", "ApplicationConfig", "IsPrincipal", "Constraints", "EndpointBindings", "OSType", "Channel", "EndpointBindings", "ExposedEndpoints", "CharmOrigin", "IsPrincipal", "IsExposed", "IsRemote")
app.CheckCallNames(c, "CharmConfig", "Charm", "ApplicationConfig", "IsPrincipal", "Constraints", "EndpointBindings", "Series", "Channel", "EndpointBindings", "ExposedEndpoints", "CharmOrigin", "IsPrincipal", "IsExposed", "IsRemote")
}

func (s *ApplicationSuite) TestApplicationsInfoOneWithExposedEndpoints(c *gc.C) {
Expand Down Expand Up @@ -2200,7 +2200,7 @@ func (s *ApplicationSuite) TestApplicationsInfoOneWithExposedEndpoints(c *gc.C)
},
},
})
app.CheckCallNames(c, "CharmConfig", "Charm", "ApplicationConfig", "IsPrincipal", "Constraints", "EndpointBindings", "OSType", "Channel", "EndpointBindings", "ExposedEndpoints", "CharmOrigin", "IsPrincipal", "IsExposed", "IsRemote")
app.CheckCallNames(c, "CharmConfig", "Charm", "ApplicationConfig", "IsPrincipal", "Constraints", "EndpointBindings", "Series", "Channel", "EndpointBindings", "ExposedEndpoints", "CharmOrigin", "IsPrincipal", "IsExposed", "IsRemote")
}

func (s *ApplicationSuite) TestApplicationsInfoDetailsErr(c *gc.C) {
Expand Down Expand Up @@ -2251,7 +2251,7 @@ func (s *ApplicationSuite) TestApplicationsInfoMany(c *gc.C) {
c.Assert(result.Results[1].Error, gc.ErrorMatches, `application "wordpress" not found`)
c.Assert(result.Results[2].Error, gc.ErrorMatches, `"unit-postgresql-0" is not a valid application tag`)
app := s.backend.applications["postgresql"]
app.CheckCallNames(c, "CharmConfig", "Charm", "ApplicationConfig", "IsPrincipal", "Constraints", "EndpointBindings", "OSType", "Channel", "EndpointBindings", "ExposedEndpoints", "CharmOrigin", "IsPrincipal", "IsExposed", "IsRemote")
app.CheckCallNames(c, "CharmConfig", "Charm", "ApplicationConfig", "IsPrincipal", "Constraints", "EndpointBindings", "Series", "Channel", "EndpointBindings", "ExposedEndpoints", "CharmOrigin", "IsPrincipal", "IsExposed", "IsRemote")
}

func (s *ApplicationSuite) TestApplicationMergeBindingsErr(c *gc.C) {
Expand Down
2 changes: 1 addition & 1 deletion apiserver/facades/client/application/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (a *mockApplication) UpdateApplicationSeries(series string, force bool) err
}

func (a *mockApplication) Series() string {
a.MethodCall(a, "OSType")
a.MethodCall(a, "Series")
a.PopNoErr()
return a.series
}
Expand Down
2 changes: 1 addition & 1 deletion apiserver/facades/client/charms/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func normalizeCharmOrigin(origin params.CharmOrigin, fallbackArch string) (param
var os string
var oSeries string
if origin.Series == "all" {
logger.Warningf("Series all detected, removing all from the origin. %s", origin.ID)
logger.Warningf("Release all detected, removing all from the origin. %s", origin.ID)
} else if origin.Series != "" {
// Always set the os from the series, so we know it's correctly
// normalized for the rest of Juju.
Expand Down
3 changes: 2 additions & 1 deletion apiserver/facades/client/client/instanceconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/juju/juju/cloudconfig/instancecfg"
"github.com/juju/juju/controller/authentication"
"github.com/juju/juju/core/network"
coreseries "github.com/juju/juju/core/series"
"github.com/juju/juju/environs"
"github.com/juju/juju/state"
"github.com/juju/juju/state/stateenvirons"
Expand Down Expand Up @@ -64,7 +65,7 @@ func InstanceConfig(ctrlSt *state.State, st *state.State, machineId, nonce, data
Number: agentVersion,
MajorVersion: -1,
MinorVersion: -1,
Series: machine.Series(),
OSType: coreseries.DefaultOSTypeNameFromSeries(machine.Series()),
Arch: *hc.Arch,
})
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ func (s *MachineManagerSuite) TestUpgradeSeriesPrepare(c *gc.C) {

mach := s.st.machines["0"]
c.Assert(len(mach.Calls()), gc.Equals, 9)
mach.CheckCallNames(c, "IsManager", "IsLockedForSeriesUpgrade", "Units", "CreateUpgradeSeriesLock", "Series", "Tag", "ApplicationNames", "Series", "SetUpgradeSeriesStatus")
mach.CheckCallNames(c, "IsManager", "IsLockedForSeriesUpgrade", "Units", "CreateUpgradeSeriesLock", "Release", "Tag", "ApplicationNames", "Release", "SetUpgradeSeriesStatus")
mach.CheckCall(c, 3, "CreateUpgradeSeriesLock", []string{"foo/0", "foo/1", "foo/2"}, "xenial")
}

Expand Down Expand Up @@ -1151,7 +1151,7 @@ func (m *mockMachine) SetKeepInstance(keep bool) error {
}

func (m *mockMachine) Series() string {
m.MethodCall(m, "Series")
m.MethodCall(m, "Release")
return m.series
}

Expand Down
4 changes: 2 additions & 2 deletions apiserver/facades/client/machinemanager/types_mock_test.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func (a *mockApplication) Name() string {
}

func (a *mockApplication) Series() string {
a.MethodCall(a, "OSType")
a.MethodCall(a, "Series")
return a.series
}

Expand Down
2 changes: 2 additions & 0 deletions apiserver/params/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,8 @@ type FindToolsParams struct {
// Arch will be used to match tools by architecture if non-empty.
Arch string `json:"arch"`

// TODO(juju3) - remove series
// Kept foe compatibility with older clients.
// Series will be used to match tools by series if non-empty.
Series string `json:"series"`

Expand Down
6 changes: 3 additions & 3 deletions charmhub/refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const (
)

const (
// NotAvailable is used a placeholder for OS and Series for a refresh
// platform request, if the OS and Series is not known.
// NotAvailable is used a placeholder for OS and Release for a refresh
// platform request, if the OS and Release is not known.
NotAvailable = "NA"
)

Expand Down Expand Up @@ -484,7 +484,7 @@ func validatePlatform(rp RefreshPlatform) error {
msg = append(msg, fmt.Sprintf("OS %q", rp.OS))
}
if rp.Series == "all" {
msg = append(msg, fmt.Sprintf("Series %q", rp.Series))
msg = append(msg, fmt.Sprintf("Release %q", rp.Series))
}
if len(msg) > 0 {
err := errors.Trace(errors.NotValidf(strings.Join(msg, ", ")))
Expand Down
4 changes: 2 additions & 2 deletions charmhub/refresh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (s *RefreshSuite) TestRefeshConfigValidateSeries(c *gc.C) {
Series: "all",
Architecture: arch.DefaultArchitecture,
})
c.Assert(err, gc.ErrorMatches, "Series.*")
c.Assert(err, gc.ErrorMatches, "Release.*")
}

func (s *RefreshSuite) TestRefeshConfigValidateOS(c *gc.C) {
Expand All @@ -106,7 +106,7 @@ func (s *RefreshSuite) TestRefeshConfigValidate(c *gc.C) {
Series: "all",
Architecture: "all",
})
c.Assert(err, gc.ErrorMatches, "Architecture.*, OS.*, Series.*")
c.Assert(err, gc.ErrorMatches, "Architecture.*, OS.*, Release.*")
}

func (s *RefreshSuite) testRefeshConfigValidate(c *gc.C, rp RefreshPlatform) error {
Expand Down
2 changes: 1 addition & 1 deletion cloudconfig/userdatacfg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (cfg *testInstanceConfig) setEnableOSUpdateAndUpgrade(updateEnabled, upgrad
return cfg
}

// setSeries sets the series-specific fields (Tools, Series, DataDir,
// setSeries sets the series-specific fields (Tools, Release, DataDir,
// LogDir, and CloudInitOutputLog) to match the given series.
func (cfg *testInstanceConfig) setSeries(series string, build int) *testInstanceConfig {
osType := coreseries.DefaultOSTypeNameFromSeries(series)
Expand Down
2 changes: 1 addition & 1 deletion cmd/juju/backups/backups.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const backupMetadataTemplate = `
backup ID: {{.BackupID}}
backup format version: {{.FormatVersion}}
juju version: {{.JujuVersion}}
series: {{.Series}}
series: {{.Release}}
controller UUID: {{.ControllerUUID}}{{if (gt .HANodes 1)}}
controllers in HA: {{.HANodes}}{{end}}
Expand Down
2 changes: 1 addition & 1 deletion cmd/juju/cachedimages/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ List cached os images in the Juju model.
Images can be filtered on:
Kind eg "lxd"
Series eg "xenial"
Release eg "xenial"
Architecture eg "amd64"
The filter attributes are optional.
Expand Down
2 changes: 1 addition & 1 deletion cmd/juju/cachedimages/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Remove cached os images in the Juju model.
Images are identified by:
Kind eg "lxd"
Series eg "xenial"
Release eg "xenial"
Architecture eg "amd64"
Examples:
Expand Down
2 changes: 1 addition & 1 deletion cmd/juju/commands/synctools.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (c *syncToolsCommand) Init(args []string) error {
// syncToolsAPI provides an interface with a subset of the
// api.Client API. This exists to enable mocking.
type syncToolsAPI interface {
FindTools(majorVersion, minorVersion int, series, arch, agentStream string) (params.FindToolsResult, error)
FindTools(majorVersion, minorVersion int, osType, arch, agentStream string) (params.FindToolsResult, error)
UploadTools(r io.ReadSeeker, v version.Binary) (coretools.List, error)
Close() error
}
Expand Down
Loading

0 comments on commit 4abe064

Please sign in to comment.