Merge lp:~wwitzel3/juju-core/009-ha-rsyslog-api into lp:~go-bot/juju-core/trunk

Proposed by Wayne Witzel III
Status: Rejected
Rejected by: William Reade
Proposed branch: lp:~wwitzel3/juju-core/009-ha-rsyslog-api
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 11321 lines (+1960/-2544)
251 files modified
agent/agent_test.go (+2/-2)
agent/bootstrap_test.go (+6/-5)
agent/format-1.16_whitebox_test.go (+2/-2)
agent/format-1.18_whitebox_test.go (+2/-2)
agent/format_whitebox_test.go (+2/-2)
agent/identity_test.go (+2/-2)
agent/mongo/export_test.go (+0/-18)
agent/mongo/mongo.go (+0/-2)
agent/mongo/mongo_test.go (+29/-53)
agent/mongo/upgrade.go (+0/-5)
agent/mongo/upgrade_test.go (+11/-57)
agent/tools/diskmanager_test.go (+3/-2)
agent/tools/tools_test.go (+2/-2)
bzr/bzr_test.go (+5/-5)
charm/dir_test.go (+2/-1)
cloudinit/cloudinit_test.go (+2/-2)
cloudinit/sshinit/configure_test.go (+2/-1)
cmd/charm-admin/config_test.go (+4/-3)
cmd/charm-admin/deletecharm_test.go (+4/-3)
cmd/envcmd/environmentcommand_test.go (+13/-11)
cmd/filevar_test.go (+1/-2)
cmd/juju/authorizedkeys_test.go (+13/-1)
cmd/juju/bootstrap_test.go (+31/-23)
cmd/juju/cmd_test.go (+3/-1)
cmd/juju/debuglog_test.go (+1/-1)
cmd/juju/deploy.go (+9/-26)
cmd/juju/help_topics.go (+8/-9)
cmd/juju/helptool_test.go (+9/-1)
cmd/juju/init_test.go (+5/-11)
cmd/juju/main.go (+0/-3)
cmd/juju/main_test.go (+4/-2)
cmd/juju/plugin_test.go (+7/-3)
cmd/juju/publish_test.go (+9/-6)
cmd/juju/run_test.go (+1/-1)
cmd/juju/switch_test.go (+20/-21)
cmd/juju/synctools_test.go (+7/-4)
cmd/juju/user.go (+0/-35)
cmd/juju/user_test.go (+0/-42)
cmd/jujud/agent_test.go (+3/-2)
cmd/jujud/bootstrap_test.go (+6/-5)
cmd/jujud/machine.go (+3/-5)
cmd/jujud/machine_test.go (+22/-45)
cmd/jujud/run_test.go (+2/-1)
cmd/jujud/upgrade_test.go (+2/-2)
cmd/plugins/juju-metadata/imagemetadata_test.go (+18/-7)
cmd/plugins/juju-metadata/metadataplugin_test.go (+9/-1)
cmd/plugins/juju-metadata/toolsmetadata_test.go (+6/-2)
cmd/plugins/juju-metadata/validateimagemetadata_test.go (+10/-3)
cmd/plugins/juju-metadata/validatetoolsmetadata_test.go (+10/-3)
cmd/plugins/local/main_test.go (+2/-1)
constraints/validation_test.go (+1/-1)
container/directory_test.go (+3/-3)
container/factory/factory_test.go (+2/-2)
container/kvm/kvm_test.go (+2/-2)
container/kvm/live_test.go (+3/-2)
container/kvm/mock/mock-kvm_test.go (+2/-2)
container/kvm/testing/test.go (+3/-3)
container/lxc/export_test.go (+0/-8)
container/lxc/initialisation_test.go (+2/-2)
container/lxc/lxc.go (+4/-30)
container/lxc/lxc_test.go (+5/-67)
container/lxc/testing/test.go (+3/-3)
doc.go (+0/-10)
doc/how-to-write-tests.txt (+19/-26)
downloader/downloader_test.go (+6/-5)
environs/bootstrap/bootstrap_test.go (+7/-3)
environs/bootstrap/interruptiblestorage_test.go (+2/-2)
environs/bootstrap/state_test.go (+2/-2)
environs/cloudinit/cloudinit_test.go (+2/-1)
environs/cloudinit_test.go (+2/-1)
environs/config.go (+0/-8)
environs/config/authkeys_test.go (+4/-4)
environs/config/config.go (+11/-33)
environs/config/config_test.go (+58/-97)
environs/config_test.go (+16/-16)
environs/configstore/disk_test.go (+2/-2)
environs/configstore/interface_test.go (+2/-2)
environs/emptystorage_test.go (+8/-8)
environs/httpstorage/backend_test.go (+2/-1)
environs/imagemetadata/generate_test.go (+2/-2)
environs/imagemetadata/marshal_test.go (+2/-2)
environs/imagemetadata/upload_test.go (+2/-2)
environs/imagemetadata/urls_test.go (+6/-3)
environs/imagemetadata/validation_test.go (+3/-3)
environs/instances/image.go (+19/-44)
environs/instances/image_test.go (+49/-96)
environs/instances/instancetype_test.go (+2/-2)
environs/jujutest/livetests.go (+18/-4)
environs/jujutest/tests.go (+8/-4)
environs/manual/addresses_test.go (+2/-2)
environs/manual/init_test.go (+2/-2)
environs/open_test.go (+20/-19)
environs/simplestreams/testing/testing.go (+4/-4)
environs/sshstorage/storage_test.go (+3/-3)
environs/storage/storage_test.go (+3/-4)
environs/sync/sync_test.go (+9/-9)
environs/testing/tools.go (+0/-25)
environs/tools/build_test.go (+4/-4)
environs/tools/storage_test.go (+4/-4)
environs/tools/tools_test.go (+5/-5)
environs/tools/urls_test.go (+6/-3)
environs/tools/validation_test.go (+3/-3)
instance/address_test.go (+2/-2)
juju/apiconn_test.go (+26/-19)
juju/arch/arch.go (+0/-15)
juju/arch/arch_test.go (+2/-9)
juju/conn_test.go (+69/-14)
juju/osenv/export_test.go (+0/-7)
juju/osenv/proxy_test.go (+2/-2)
juju/osenv/vars_test.go (+17/-18)
juju/testing/conn.go (+7/-6)
provider/azure/azure_test.go (+6/-6)
provider/azure/config_test.go (+2/-1)
provider/azure/customdata_test.go (+2/-1)
provider/azure/instance_test.go (+2/-2)
provider/common/bootstrap_test.go (+3/-3)
provider/common/destroy_test.go (+2/-2)
provider/common/state_test.go (+2/-1)
provider/common/supportedarchitectures_test.go (+1/-1)
provider/dummy/config_test.go (+3/-2)
provider/dummy/environs.go (+1/-1)
provider/dummy/environs_test.go (+4/-38)
provider/ec2/config_test.go (+4/-3)
provider/ec2/image_test.go (+23/-7)
provider/ec2/live_test.go (+7/-6)
provider/ec2/local_test.go (+9/-11)
provider/joyent/config_test.go (+3/-3)
provider/joyent/export_test.go (+0/-1)
provider/joyent/joyent_test.go (+6/-5)
provider/joyent/live_test.go (+94/-0)
provider/joyent/local_test.go (+29/-22)
provider/joyent/provider_test.go (+6/-0)
provider/local/config.go (+14/-0)
provider/local/environ.go (+3/-6)
provider/local/environ_test.go (+0/-4)
provider/local/environprovider.go (+7/-0)
provider/local/environprovider_test.go (+88/-2)
provider/local/export_test.go (+2/-0)
provider/local/local_test.go (+2/-2)
provider/local/lxc.go (+30/-0)
provider/local/lxc_test.go (+53/-0)
provider/local/prereqs_test.go (+3/-3)
provider/maas/config_test.go (+2/-1)
provider/maas/environ_test.go (+6/-5)
provider/maas/environ_whitebox_test.go (+0/-8)
provider/maas/export_test.go (+0/-64)
provider/maas/maas_test.go (+6/-5)
provider/manual/config_test.go (+1/-1)
provider/manual/environ_test.go (+2/-2)
provider/manual/provider_test.go (+2/-2)
provider/openstack/config_test.go (+8/-4)
provider/openstack/export_test.go (+0/-21)
provider/openstack/live_test.go (+6/-5)
provider/openstack/storage.go (+4/-3)
replicaset/replicaset.go (+3/-29)
rpc/jsoncodec/codec_test.go (+2/-2)
rpc/reflect_test.go (+2/-2)
rpc/rpc_test.go (+2/-2)
state/api/params/params.go (+7/-0)
state/api/provisioner/provisioner_test.go (+13/-31)
state/api/rsyslog/rsyslog.go (+51/-6)
state/api/rsyslog/rsyslog_test.go (+57/-13)
state/api/state_test.go (+2/-1)
state/apiserver/admin.go (+1/-2)
state/apiserver/client/client.go (+3/-1)
state/apiserver/client/run.go (+2/-11)
state/apiserver/common/environwatcher_test.go (+3/-2)
state/apiserver/common/errors_test.go (+2/-2)
state/apiserver/common/resource.go (+0/-33)
state/apiserver/common/resource_test.go (+0/-59)
state/apiserver/debuglog_internal_test.go (+2/-1)
state/apiserver/pinger_test.go (+0/-19)
state/apiserver/provisioner/provisioner.go (+1/-6)
state/apiserver/root.go (+13/-11)
state/apiserver/root_test.go (+1/-16)
state/apiserver/rsyslog/config.go (+34/-0)
state/apiserver/rsyslog/rsyslog.go (+60/-2)
state/apiserver/rsyslog/rsyslog_test.go (+48/-11)
state/apiserver/upgrader/unitupgrader.go (+3/-0)
state/apiserver/upgrader/unitupgrader_test.go (+6/-6)
state/compat_test.go (+6/-5)
state/conn_test.go (+6/-5)
state/initialize_test.go (+6/-5)
state/megawatcher_internal_test.go (+6/-5)
state/multiwatcher/multiwatcher_internal_test.go (+3/-3)
state/presence/presence_test.go (+6/-5)
state/settings_test.go (+6/-5)
state/watcher/watcher_test.go (+6/-5)
store/config_test.go (+4/-4)
testing/base.go (+0/-126)
testing/base_test.go (+0/-40)
testing/environ.go (+155/-44)
testing/environ_test.go (+0/-54)
testing/filetesting/filetesting_test.go (+3/-3)
testing/git.go (+3/-2)
testing/mgo_test.go (+6/-5)
upgrades/deprecatedenvsettings.go (+0/-1)
upgrades/dotprofile_test.go (+2/-2)
upgrades/lockdirectory_test.go (+2/-2)
upgrades/steps118_test.go (+2/-2)
upgrades/upgrade_test.go (+2/-1)
upstart/upstart_test.go (+2/-2)
utils/apt_test.go (+2/-2)
utils/command_test.go (+2/-2)
utils/exec/exec_test.go (+2/-2)
utils/export_test.go (+0/-2)
utils/fslock/fslock_test.go (+3/-2)
utils/gomaxprocs_test.go (+3/-3)
utils/http.go (+0/-27)
utils/http_test.go (+6/-53)
utils/registry/export_test.go (+0/-8)
utils/registry/package_test.go (+0/-14)
utils/registry/registry.go (+0/-105)
utils/registry/registry_test.go (+0/-151)
utils/shell/script_test.go (+2/-2)
utils/ssh/authorisedkeys_test.go (+9/-2)
utils/ssh/clientkeys_test.go (+5/-2)
utils/ssh/fingerprint_test.go (+2/-2)
utils/ssh/generate_test.go (+2/-2)
utils/ssh/run_test.go (+3/-2)
utils/ssh/ssh_gocrypto_test.go (+3/-3)
utils/ssh/ssh_test.go (+3/-3)
utils/tailer/tailer_test.go (+2/-1)
utils/voyeur/value_test.go (+4/-4)
utils/zip/zip_test.go (+2/-2)
version/osversion_darwin_test.go (+2/-2)
version/osversion_test.go (+3/-3)
version/ubuntu/supportedseries_test.go (+2/-2)
version/version_test.go (+4/-4)
worker/deployer/simple_test.go (+4/-3)
worker/instancepoller/aggregate_test.go (+26/-48)
worker/instancepoller/machine_test.go (+2/-1)
worker/instancepoller/updater_test.go (+2/-1)
worker/notifyworker_test.go (+4/-3)
worker/peergrouper/desired_test.go (+2/-2)
worker/peergrouper/initiate_test.go (+2/-1)
worker/peergrouper/worker_test.go (+3/-2)
worker/provisioner/lxc-broker_test.go (+2/-2)
worker/rsyslog/rsyslog_test.go (+24/-47)
worker/rsyslog/worker.go (+9/-13)
worker/runner_test.go (+4/-4)
worker/simpleworker_test.go (+2/-2)
worker/singular/mongo_test.go (+2/-1)
worker/singular/singular_test.go (+2/-1)
worker/stringsworker_test.go (+4/-3)
worker/terminationworker/worker_test.go (+4/-4)
worker/uniter/charm/manifest_deployer_test.go (+3/-3)
worker/uniter/debug/server_test.go (+2/-2)
worker/uniter/jujuc/server_test.go (+4/-3)
worker/uniter/jujuc/util_test.go (+5/-5)
worker/uniter/runlistener_test.go (+2/-2)
To merge this branch: bzr merge lp:~wwitzel3/juju-core/009-ha-rsyslog-api
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+219703@code.launchpad.net

Commit message

rsyslog: ensure logs accumulate on state machines

Added a WatchForRsyslogChanges watcher and extended the API with
GetRsyslogConfig. Changed the rsyslog worker to use these additions.

https://codereview.appspot.com/94510043/

Description of the change

rsyslog: ensure logs accumulate on state machines

Added a WatchForRsyslogChanges watcher and extended the API with
GetRsyslogConfig. Changed the rsyslog worker to use these additions.

https://codereview.appspot.com/94510043/

To post a comment you must log in.
Revision history for this message
Wayne Witzel III (wwitzel3) wrote :

Reviewers: mp+219703_code.launchpad.net,

Message:
Please take a look.

Description:
rsyslog: ensure logs accumulate on state machines

Added a WatchForRsyslogChanges watcher and extended the API with
GetRsyslongConfig. Changed the rsyslog worker to use these additions.

https://code.launchpad.net/~wwitzel3/juju-core/009-ha-rsyslog-api/+merge/219703

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/94510043/

Affected files (+272, -49 lines):
   A [revision details]
   M state/api/params/params.go
   M state/api/rsyslog/rsyslog.go
   M state/api/rsyslog/rsyslog_test.go
   A state/apiserver/rsyslog/config.go
   M state/apiserver/rsyslog/rsyslog.go
   M state/apiserver/rsyslog/rsyslog_test.go
   M worker/rsyslog/rsyslog_test.go
   M worker/rsyslog/worker.go

Revision history for this message
Wayne Witzel III (wwitzel3) wrote :

https://codereview.appspot.com/94510043/diff/1/state/api/params/params.go
File state/api/params/params.go (right):

https://codereview.appspot.com/94510043/diff/1/state/api/params/params.go#newcode684
state/api/params/params.go:684: // RsyslogConfigResult holds the result
of an GetRsyslogConfig
s/an/a

https://codereview.appspot.com/94510043/

Revision history for this message
Michael Foord (mfoord) wrote :

https://codereview.appspot.com/94510043/diff/1/state/api/rsyslog/rsyslog.go
File state/api/rsyslog/rsyslog.go (right):

https://codereview.appspot.com/94510043/diff/1/state/api/rsyslog/rsyslog.go#newcode58
state/api/rsyslog/rsyslog.go:58: fmt.Printf("tag: %s", agentTag)
That's a debugging Printf I guess...

https://codereview.appspot.com/94510043/

Revision history for this message
Wayne Witzel III (wwitzel3) wrote :
Revision history for this message
Wayne Witzel III (wwitzel3) wrote :

Manually tested many scenarios against virtual maas and ec2. Including
going from non-HA to HA with units deployed and not deployed.

https://codereview.appspot.com/94510043/

Revision history for this message
William Reade (fwereade) wrote :

I think this is generally solid but I have a few questions.

https://codereview.appspot.com/94510043/diff/20001/state/api/params/params.go
File state/api/params/params.go (right):

https://codereview.appspot.com/94510043/diff/20001/state/api/params/params.go#newcode687
state/api/params/params.go:687: Port int
/eyebrow

Why do we need both port and hostports?

https://codereview.appspot.com/94510043/diff/20001/state/apiserver/rsyslog/rsyslog.go
File state/apiserver/rsyslog/rsyslog.go (right):

https://codereview.appspot.com/94510043/diff/20001/state/apiserver/rsyslog/rsyslog.go#newcode90
state/apiserver/rsyslog/rsyslog.go:90: watch :=
api.st.WatchAPIHostPorts()
ISTM that this won't trigger on rsyslog-ca-cert changes.

I guess I'm out of date re: rsyslog-ca-cert -- would you ping me when
you're online so we can discuss?

https://codereview.appspot.com/94510043/diff/20001/worker/rsyslog/worker.go
File worker/rsyslog/worker.go (right):

https://codereview.appspot.com/94510043/diff/20001/worker/rsyslog/worker.go#newcode129
worker/rsyslog/worker.go:129: return h.st.WatchForRsyslogChanges(h.tag)
Do we need tag? I *think* it's implicit in the connection. Probably I'm
wrong?

https://codereview.appspot.com/94510043/

Revision history for this message
Michael Foord (mfoord) wrote :

On 2014/05/16 09:21:24, fwereade wrote:
> I think this is generally solid but I have a few questions.

https://codereview.appspot.com/94510043/diff/20001/state/api/params/params.go
> File state/api/params/params.go (right):

https://codereview.appspot.com/94510043/diff/20001/state/api/params/params.go#newcode687
> state/api/params/params.go:687: Port int
> /eyebrow

> Why do we need both port and hostports?

We could lose Port, we kept it mainly because that's how the *existing*
system works.

https://codereview.appspot.com/94510043/diff/20001/state/apiserver/rsyslog/rsyslog.go
> File state/apiserver/rsyslog/rsyslog.go (right):

https://codereview.appspot.com/94510043/diff/20001/state/apiserver/rsyslog/rsyslog.go#newcode90
> state/apiserver/rsyslog/rsyslog.go:90: watch :=
api.st.WatchAPIHostPorts()
> ISTM that this won't trigger on rsyslog-ca-cert changes.

> I guess I'm out of date re: rsyslog-ca-cert -- would you ping me when
you're
> online so we can discuss?

So we had a big discussion about this issue (is watching APIHostPorts
alone sufficient or not)?
No-one wanted to commit to an answer, but the consensus seemed to be if
we're treating the rsyslog config entries as "immutable once set" then
watching APIHostPorts alone to trigger rsyslog config rewriting should
be enough. And it works for the scenarios we've manually tested:

* non-HA with unit deployed
* HA without units
* HA then units deployed
* non-HA with units deployed then ensure-availability

rsyslog config is rewritten in all these cases and logging happens
correctly, so the only wrinkle would be if the rsyslog config can be
written out *before* the certificate is set for the first time on
bootstrap - in which case it wouldn't be rewritten. When we asked nobody
thought that was likely, but no-one would *commit* to it being
impossible, however "they" (jam and natefinch) did think that if we're
treating the rsyslog config as "immutable once set" then watching just
APIHostPorts *should* be sufficient. So that's what we did.

https://codereview.appspot.com/94510043/diff/20001/worker/rsyslog/worker.go
> File worker/rsyslog/worker.go (right):

https://codereview.appspot.com/94510043/diff/20001/worker/rsyslog/worker.go#newcode129
> worker/rsyslog/worker.go:129: return
h.st.WatchForRsyslogChanges(h.tag)
> Do we need tag? I *think* it's implicit in the connection. Probably
I'm wrong?

It is sent by other code, so we sent it. We don't need it in our API
endpoint itself.

https://codereview.appspot.com/94510043/

Revision history for this message
Michael Foord (mfoord) wrote :

On 2014/05/16 10:34:34, mfoord wrote:
> On 2014/05/16 09:21:24, fwereade wrote:
> > I think this is generally solid but I have a few questions.
> >
> >
https://codereview.appspot.com/94510043/diff/20001/state/api/params/params.go
> > File state/api/params/params.go (right):
> >
> >

https://codereview.appspot.com/94510043/diff/20001/state/api/params/params.go#newcode687
> > state/api/params/params.go:687: Port int
> > /eyebrow
> >
> > Why do we need both port and hostports?
> >

> We could lose Port, we kept it mainly because that's how the
*existing* system
> works.

And in fact we store the rsyslogPort in the EnvironConfig, so we
probably still need it for backwards compatibility without a bigger
refactor than *strictly* necessary at this stage. If you'd like us to do
that refactor now we can.

We probably should still use the HostPorts for the template rendering
which we haven't yet done.

https://codereview.appspot.com/94510043/

Revision history for this message
Michael Foord (mfoord) wrote :

https://codereview.appspot.com/94510043/diff/20001/worker/rsyslog/worker.go
File worker/rsyslog/worker.go (right):

https://codereview.appspot.com/94510043/diff/20001/worker/rsyslog/worker.go#newcode152
worker/rsyslog/worker.go:152: if cfg.Port == h.syslogPort &&
rsyslogCACert == h.rsyslogCACert {
This will actually screw us over. If APIHosts changes, but not the port
nor the cert, then the conf won't get rewritten. So this needs to
change.

https://codereview.appspot.com/94510043/

Revision history for this message
Michael Foord (mfoord) wrote :

On 2014/05/19 10:02:47, mfoord wrote:

https://codereview.appspot.com/94510043/diff/20001/worker/rsyslog/worker.go
> File worker/rsyslog/worker.go (right):

https://codereview.appspot.com/94510043/diff/20001/worker/rsyslog/worker.go#newcode152
> worker/rsyslog/worker.go:152: if cfg.Port == h.syslogPort &&
rsyslogCACert ==
> h.rsyslogCACert {
> This will actually screw us over. If APIHosts changes, but not the
port nor the
> cert, then the conf won't get rewritten. So this needs to change.

Note that I've removed this in a separate branch, along with an obsolete
test that now fails, in the following branch:

https://code.launchpad.net/~mfoord/juju-core/ha-rsyslog-shortcut-removal/+merge/220105

Andrew Wilkins (axw) is fairly certain that by the time the
rsyslogworker is created the port is in the environment, and starting
the rsyslog worker already ensures the ca-cert will be available, so
just watching APIHostPorts should be safe (regarding rsyslog config
writing and restarting).

https://codereview.appspot.com/94510043/

Revision history for this message
Wayne Witzel III (wwitzel3) wrote :
Revision history for this message
William Reade (fwereade) wrote :

Last few changes, otherwise looking good. Thanks.

https://codereview.appspot.com/94510043/diff/40001/state/api/params/params.go
File state/api/params/params.go (right):

https://codereview.appspot.com/94510043/diff/40001/state/api/params/params.go#newcode687
state/api/params/params.go:687: Port int
please document that Port is just there for compatibility, and capable
clients should trust the HostPorts.

https://codereview.appspot.com/94510043/diff/40001/state/api/rsyslog/rsyslog.go
File state/api/rsyslog/rsyslog.go (right):

https://codereview.appspot.com/94510043/diff/40001/state/api/rsyslog/rsyslog.go#newcode20
state/api/rsyslog/rsyslog.go:20: Port int
I think you can completely drop Port from this one, right?

https://codereview.appspot.com/94510043/diff/40001/state/apiserver/rsyslog/rsyslog.go
File state/apiserver/rsyslog/rsyslog.go (left):

https://codereview.appspot.com/94510043/diff/40001/state/apiserver/rsyslog/rsyslog.go#oldcode33
state/apiserver/rsyslog/rsyslog.go:33: func (api *RsyslogAPI)
SetRsyslogCert(args params.SetRsyslogCertParams) (params.ErrorResult,
error) {
This still bugs me but it's not actionable right now.

https://codereview.appspot.com/94510043/diff/40001/state/apiserver/rsyslog/rsyslog.go
File state/apiserver/rsyslog/rsyslog.go (right):

https://codereview.appspot.com/94510043/diff/40001/state/apiserver/rsyslog/rsyslog.go#newcode27
state/apiserver/rsyslog/rsyslog.go:27: if !authorizer.AuthMachineAgent()
&& !authorizer.AuthUnitAgent() {
do we have an AuthAgent? maybe we should

https://codereview.appspot.com/94510043/diff/40001/state/apiserver/rsyslog/rsyslog.go#newcode63
state/apiserver/rsyslog/rsyslog.go:63: func (api *RsyslogAPI)
GetRsyslogConfig() (params.RsyslogConfigResult, error) {
Heh, almost missed this. Please make it bulky, like
WatchForRsyslogChanges below; I can't see when we'll need it but I'd
prefer to remain consistent.

https://codereview.appspot.com/94510043/

Revision history for this message
Michael Foord (mfoord) wrote :

On 2014/05/21 08:06:30, fwereade wrote:
> Last few changes, otherwise looking good. Thanks.

https://codereview.appspot.com/94510043/diff/40001/state/api/params/params.go
> File state/api/params/params.go (right):

https://codereview.appspot.com/94510043/diff/40001/state/api/params/params.go#newcode687
> state/api/params/params.go:687: Port int
> please document that Port is just there for compatibility, and capable
clients
> should trust the HostPorts.

The Port is there for state servers to know which port to listen on. It
isn't used by units. I've added a note to this effect.

https://codereview.appspot.com/94510043/diff/40001/state/api/rsyslog/rsyslog.go
> File state/api/rsyslog/rsyslog.go (right):

https://codereview.appspot.com/94510043/diff/40001/state/api/rsyslog/rsyslog.go#newcode20
> state/api/rsyslog/rsyslog.go:20: Port int
> I think you can completely drop Port from this one, right?

As discussed we can't drop this until state servers have a mechanism for
picking a port and storing it in the state, so that GetRsyslogConfig can
then return the right information in HostPorts. I've added a note that
the Port is only for state servers to know which port to listen on.

https://codereview.appspot.com/94510043/diff/40001/state/apiserver/rsyslog/rsyslog.go
> File state/apiserver/rsyslog/rsyslog.go (left):

https://codereview.appspot.com/94510043/diff/40001/state/apiserver/rsyslog/rsyslog.go#oldcode33
> state/apiserver/rsyslog/rsyslog.go:33: func (api *RsyslogAPI)
> SetRsyslogCert(args params.SetRsyslogCertParams) (params.ErrorResult,
error) {
> This still bugs me but it's not actionable right now.

Right.

https://codereview.appspot.com/94510043/diff/40001/state/apiserver/rsyslog/rsyslog.go
> File state/apiserver/rsyslog/rsyslog.go (right):

https://codereview.appspot.com/94510043/diff/40001/state/apiserver/rsyslog/rsyslog.go#newcode27
> state/apiserver/rsyslog/rsyslog.go:27: if
!authorizer.AuthMachineAgent() &&
> !authorizer.AuthUnitAgent() {
> do we have an AuthAgent? maybe we should

We don't. Adding it was more trouble that it was worth for a single use
case. John is working on making srvRoot more testable, so if we see
another use case for this method it can be added then.

https://codereview.appspot.com/94510043/diff/40001/state/apiserver/rsyslog/rsyslog.go#newcode63
> state/apiserver/rsyslog/rsyslog.go:63: func (api *RsyslogAPI)
GetRsyslogConfig()
> (params.RsyslogConfigResult, error) {
> Heh, almost missed this. Please make it bulky, like
WatchForRsyslogChanges
> below; I can't see when we'll need it but I'd prefer to remain
consistent.

Ok, working on this. Also some test failures I see with the current
state of this branch.

https://codereview.appspot.com/94510043/

2747. By Wayne Witzel III

merge mfoord

2748. By Wayne Witzel III

revert merge

2749. By Wayne Witzel III

merge mfoord

2750. By Wayne Witzel III

merge trunk

Revision history for this message
Michael Foord (mfoord) wrote :
Revision history for this message
Michael Foord (mfoord) wrote :

On 2014/05/22 15:25:43, mfoord wrote:
> Unfortunately we mangled this branch, so will repropose from this
branch:

https://code.launchpad.net/~mfoord/juju-core/ha-rsyslog-good/+merge/220669

Superseded by: https://codereview.appspot.com/91630045/

https://codereview.appspot.com/94510043/

Revision history for this message
William Reade (fwereade) wrote :

Rejecting because dead.

Unmerged revisions

2750. By Wayne Witzel III

merge trunk

2749. By Wayne Witzel III

merge mfoord

2748. By Wayne Witzel III

revert merge

2747. By Wayne Witzel III

merge mfoord

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'agent/agent_test.go'
--- agent/agent_test.go 2014-05-20 04:27:02 +0000
+++ agent/agent_test.go 2014-05-22 14:33:28 +0000
@@ -15,12 +15,12 @@
15 "launchpad.net/juju-core/state"15 "launchpad.net/juju-core/state"
16 "launchpad.net/juju-core/state/api"16 "launchpad.net/juju-core/state/api"
17 "launchpad.net/juju-core/state/api/params"17 "launchpad.net/juju-core/state/api/params"
18 "launchpad.net/juju-core/testing"18 "launchpad.net/juju-core/testing/testbase"
19 "launchpad.net/juju-core/version"19 "launchpad.net/juju-core/version"
20)20)
2121
22type suite struct {22type suite struct {
23 testing.BaseSuite23 testbase.LoggingSuite
24}24}
2525
26var _ = gc.Suite(&suite{})26var _ = gc.Suite(&suite{})
2727
=== modified file 'agent/bootstrap_test.go'
--- agent/bootstrap_test.go 2014-05-20 04:27:02 +0000
+++ agent/bootstrap_test.go 2014-05-22 14:33:28 +0000
@@ -16,35 +16,36 @@
16 "launchpad.net/juju-core/state"16 "launchpad.net/juju-core/state"
17 "launchpad.net/juju-core/state/api/params"17 "launchpad.net/juju-core/state/api/params"
18 "launchpad.net/juju-core/testing"18 "launchpad.net/juju-core/testing"
19 "launchpad.net/juju-core/testing/testbase"
19 "launchpad.net/juju-core/utils"20 "launchpad.net/juju-core/utils"
20 "launchpad.net/juju-core/version"21 "launchpad.net/juju-core/version"
21)22)
2223
23type bootstrapSuite struct {24type bootstrapSuite struct {
24 testing.BaseSuite25 testbase.LoggingSuite
25 testing.MgoSuite26 testing.MgoSuite
26}27}
2728
28var _ = gc.Suite(&bootstrapSuite{})29var _ = gc.Suite(&bootstrapSuite{})
2930
30func (s *bootstrapSuite) SetUpSuite(c *gc.C) {31func (s *bootstrapSuite) SetUpSuite(c *gc.C) {
31 s.BaseSuite.SetUpSuite(c)32 s.LoggingSuite.SetUpSuite(c)
32 s.MgoSuite.SetUpSuite(c)33 s.MgoSuite.SetUpSuite(c)
33}34}
3435
35func (s *bootstrapSuite) TearDownSuite(c *gc.C) {36func (s *bootstrapSuite) TearDownSuite(c *gc.C) {
36 s.MgoSuite.TearDownSuite(c)37 s.MgoSuite.TearDownSuite(c)
37 s.BaseSuite.TearDownSuite(c)38 s.LoggingSuite.TearDownSuite(c)
38}39}
3940
40func (s *bootstrapSuite) SetUpTest(c *gc.C) {41func (s *bootstrapSuite) SetUpTest(c *gc.C) {
41 s.BaseSuite.SetUpTest(c)42 s.LoggingSuite.SetUpTest(c)
42 s.MgoSuite.SetUpTest(c)43 s.MgoSuite.SetUpTest(c)
43}44}
4445
45func (s *bootstrapSuite) TearDownTest(c *gc.C) {46func (s *bootstrapSuite) TearDownTest(c *gc.C) {
46 s.MgoSuite.TearDownTest(c)47 s.MgoSuite.TearDownTest(c)
47 s.BaseSuite.TearDownTest(c)48 s.LoggingSuite.TearDownTest(c)
48}49}
4950
50func (s *bootstrapSuite) TestInitializeState(c *gc.C) {51func (s *bootstrapSuite) TestInitializeState(c *gc.C) {
5152
=== modified file 'agent/format-1.16_whitebox_test.go'
--- agent/format-1.16_whitebox_test.go 2014-05-20 04:27:02 +0000
+++ agent/format-1.16_whitebox_test.go 2014-05-22 14:33:28 +0000
@@ -14,13 +14,13 @@
14 jc "github.com/juju/testing/checkers"14 jc "github.com/juju/testing/checkers"
1515
16 gc "launchpad.net/gocheck"16 gc "launchpad.net/gocheck"
17 "launchpad.net/juju-core/testing"17 "launchpad.net/juju-core/testing/testbase"
18 "launchpad.net/juju-core/utils"18 "launchpad.net/juju-core/utils"
19 "launchpad.net/juju-core/version"19 "launchpad.net/juju-core/version"
20)20)
2121
22type format_1_16Suite struct {22type format_1_16Suite struct {
23 testing.BaseSuite23 testbase.LoggingSuite
24}24}
2525
26var _ = gc.Suite(&format_1_16Suite{})26var _ = gc.Suite(&format_1_16Suite{})
2727
=== modified file 'agent/format-1.18_whitebox_test.go'
--- agent/format-1.18_whitebox_test.go 2014-05-20 04:27:02 +0000
+++ agent/format-1.18_whitebox_test.go 2014-05-22 14:33:28 +0000
@@ -14,13 +14,13 @@
1414
15 gc "launchpad.net/gocheck"15 gc "launchpad.net/gocheck"
16 "launchpad.net/juju-core/state/api/params"16 "launchpad.net/juju-core/state/api/params"
17 "launchpad.net/juju-core/testing"17 "launchpad.net/juju-core/testing/testbase"
18 "launchpad.net/juju-core/utils"18 "launchpad.net/juju-core/utils"
19 "launchpad.net/juju-core/version"19 "launchpad.net/juju-core/version"
20)20)
2121
22type format_1_18Suite struct {22type format_1_18Suite struct {
23 testing.BaseSuite23 testbase.LoggingSuite
24}24}
2525
26var _ = gc.Suite(&format_1_18Suite{})26var _ = gc.Suite(&format_1_18Suite{})
2727
=== modified file 'agent/format_whitebox_test.go'
--- agent/format_whitebox_test.go 2014-05-20 04:27:02 +0000
+++ agent/format_whitebox_test.go 2014-05-22 14:33:28 +0000
@@ -11,12 +11,12 @@
11 gc "launchpad.net/gocheck"11 gc "launchpad.net/gocheck"
1212
13 "launchpad.net/juju-core/state/api/params"13 "launchpad.net/juju-core/state/api/params"
14 "launchpad.net/juju-core/testing"14 "launchpad.net/juju-core/testing/testbase"
15 "launchpad.net/juju-core/version"15 "launchpad.net/juju-core/version"
16)16)
1717
18type formatSuite struct {18type formatSuite struct {
19 testing.BaseSuite19 testbase.LoggingSuite
20}20}
2121
22var _ = gc.Suite(&formatSuite{})22var _ = gc.Suite(&formatSuite{})
2323
=== modified file 'agent/identity_test.go'
--- agent/identity_test.go 2014-05-20 04:27:02 +0000
+++ agent/identity_test.go 2014-05-22 14:33:28 +0000
@@ -10,12 +10,12 @@
10 gc "launchpad.net/gocheck"10 gc "launchpad.net/gocheck"
1111
12 "launchpad.net/juju-core/state/api/params"12 "launchpad.net/juju-core/state/api/params"
13 "launchpad.net/juju-core/testing"13 "launchpad.net/juju-core/testing/testbase"
14 "launchpad.net/juju-core/version"14 "launchpad.net/juju-core/version"
15)15)
1616
17type identitySuite struct {17type identitySuite struct {
18 testing.BaseSuite18 testbase.LoggingSuite
19 mongodConfigPath string19 mongodConfigPath string
20 mongodPath string20 mongodPath string
21}21}
2222
=== removed file 'agent/mongo/export_test.go'
--- agent/mongo/export_test.go 2014-05-20 08:29:58 +0000
+++ agent/mongo/export_test.go 1970-01-01 00:00:00 +0000
@@ -1,18 +0,0 @@
1// Copyright 2014 Canonical Ltd.
2// Licensed under the AGPLv3, see LICENCE file for details.
3
4package mongo
5
6var (
7 MakeJournalDirs = makeJournalDirs
8 MongoConfigPath = &mongoConfigPath
9 NoauthCommand = noauthCommand
10 ProcessSignal = &processSignal
11 SharedSecretPath = sharedSecretPath
12 SSLKeyPath = sslKeyPath
13 UpstartConfInstall = &upstartConfInstall
14 UpstartService = upstartService
15 UpstartServiceStopAndRemove = &upstartServiceStopAndRemove
16 UpstartServiceStop = &upstartServiceStop
17 UpstartServiceStart = &upstartServiceStart
18)
190
=== modified file 'agent/mongo/mongo.go'
--- agent/mongo/mongo.go 2014-05-14 11:38:13 +0000
+++ agent/mongo/mongo.go 2014-05-22 14:33:28 +0000
@@ -285,7 +285,6 @@
285 " --noprealloc" +285 " --noprealloc" +
286 " --syslog" +286 " --syslog" +
287 " --smallfiles" +287 " --smallfiles" +
288 " --journal" +
289 " --keyFile " + utils.ShQuote(sharedSecretPath(dataDir))288 " --keyFile " + utils.ShQuote(sharedSecretPath(dataDir))
290 if withHA {289 if withHA {
291 mongoCmd += " --replSet " + ReplicaSetName290 mongoCmd += " --replSet " + ReplicaSetName
@@ -374,7 +373,6 @@
374 "--noprealloc",373 "--noprealloc",
375 "--syslog",374 "--syslog",
376 "--smallfiles",375 "--smallfiles",
377 "--journal",
378 )376 )
379 return cmd, nil377 return cmd, nil
380}378}
381379
=== modified file 'agent/mongo/mongo_test.go'
--- agent/mongo/mongo_test.go 2014-05-20 08:29:58 +0000
+++ agent/mongo/mongo_test.go 2014-05-22 14:33:28 +0000
@@ -1,7 +1,7 @@
1// Copyright 2014 Canonical Ltd.1// Copyright 2014 Canonical Ltd.
2// Licensed under the AGPLv3, see LICENCE file for details.2// Licensed under the AGPLv3, see LICENCE file for details.
33
4package mongo_test4package mongo
55
6import (6import (
7 "encoding/base64"7 "encoding/base64"
@@ -18,10 +18,9 @@
18 jc "github.com/juju/testing/checkers"18 jc "github.com/juju/testing/checkers"
19 gc "launchpad.net/gocheck"19 gc "launchpad.net/gocheck"
2020
21 "launchpad.net/juju-core/agent/mongo"
22 "launchpad.net/juju-core/instance"21 "launchpad.net/juju-core/instance"
23 "launchpad.net/juju-core/state/api/params"22 "launchpad.net/juju-core/state/api/params"
24 coretesting "launchpad.net/juju-core/testing"23 "launchpad.net/juju-core/testing/testbase"
25 "launchpad.net/juju-core/upstart"24 "launchpad.net/juju-core/upstart"
26 "launchpad.net/juju-core/utils"25 "launchpad.net/juju-core/utils"
27 "launchpad.net/juju-core/version"26 "launchpad.net/juju-core/version"
@@ -30,7 +29,7 @@
30func Test(t *stdtesting.T) { gc.TestingT(t) }29func Test(t *stdtesting.T) { gc.TestingT(t) }
3130
32type MongoSuite struct {31type MongoSuite struct {
33 coretesting.BaseSuite32 testbase.LoggingSuite
34 mongodConfigPath string33 mongodConfigPath string
35 mongodPath string34 mongodPath string
3635
@@ -51,24 +50,24 @@
51}50}
5251
53func (s *MongoSuite) SetUpTest(c *gc.C) {52func (s *MongoSuite) SetUpTest(c *gc.C) {
54 s.BaseSuite.SetUpTest(c)53 s.LoggingSuite.SetUpTest(c)
55 // Try to make sure we don't execute any commands accidentally.54 // Try to make sure we don't execute any commands accidentally.
56 s.PatchEnvironment("PATH", "")55 s.PatchEnvironment("PATH", "")
5756
58 s.mongodPath = filepath.Join(c.MkDir(), "mongod")57 s.mongodPath = filepath.Join(c.MkDir(), "mongod")
59 err := ioutil.WriteFile(s.mongodPath, []byte("#!/bin/bash\n\nprintf %s 'db version v2.4.9'\n"), 0755)58 err := ioutil.WriteFile(s.mongodPath, []byte("#!/bin/bash\n\nprintf %s 'db version v2.4.9'\n"), 0755)
60 c.Assert(err, gc.IsNil)59 c.Assert(err, gc.IsNil)
61 s.PatchValue(&mongo.JujuMongodPath, s.mongodPath)60 s.PatchValue(&JujuMongodPath, s.mongodPath)
6261
63 testPath := c.MkDir()62 testPath := c.MkDir()
64 s.mongodConfigPath = filepath.Join(testPath, "mongodConfig")63 s.mongodConfigPath = filepath.Join(testPath, "mongodConfig")
65 s.PatchValue(mongo.MongoConfigPath, s.mongodConfigPath)64 s.PatchValue(&mongoConfigPath, s.mongodConfigPath)
6665
67 s.PatchValue(mongo.UpstartConfInstall, func(conf *upstart.Conf) error {66 s.PatchValue(&upstartConfInstall, func(conf *upstart.Conf) error {
68 s.installed = append(s.installed, *conf)67 s.installed = append(s.installed, *conf)
69 return s.installError68 return s.installError
70 })69 })
71 s.PatchValue(mongo.UpstartServiceStopAndRemove, func(svc *upstart.Service) error {70 s.PatchValue(&upstartServiceStopAndRemove, func(svc *upstart.Service) error {
72 s.removed = append(s.removed, *svc)71 s.removed = append(s.removed, *svc)
73 return s.removeError72 return s.removeError
74 })73 })
@@ -80,23 +79,23 @@
80}79}
8180
82func (s *MongoSuite) TestJujuMongodPath(c *gc.C) {81func (s *MongoSuite) TestJujuMongodPath(c *gc.C) {
83 obtained, err := mongo.Path()82 obtained, err := Path()
84 c.Check(err, gc.IsNil)83 c.Check(err, gc.IsNil)
85 c.Check(obtained, gc.Equals, s.mongodPath)84 c.Check(obtained, gc.Equals, s.mongodPath)
86}85}
8786
88func (s *MongoSuite) TestDefaultMongodPath(c *gc.C) {87func (s *MongoSuite) TestDefaultMongodPath(c *gc.C) {
89 s.PatchValue(&mongo.JujuMongodPath, "/not/going/to/exist/mongod")88 s.PatchValue(&JujuMongodPath, "/not/going/to/exist/mongod")
90 s.PatchEnvPathPrepend(filepath.Dir(s.mongodPath))89 s.PatchEnvPathPrepend(filepath.Dir(s.mongodPath))
9190
92 obtained, err := mongo.Path()91 obtained, err := Path()
93 c.Check(err, gc.IsNil)92 c.Check(err, gc.IsNil)
94 c.Check(obtained, gc.Equals, s.mongodPath)93 c.Check(obtained, gc.Equals, s.mongodPath)
95}94}
9695
97func (s *MongoSuite) TestMakeJournalDirs(c *gc.C) {96func (s *MongoSuite) TestMakeJournalDirs(c *gc.C) {
98 dir := c.MkDir()97 dir := c.MkDir()
99 err := mongo.MakeJournalDirs(dir)98 err := makeJournalDirs(dir)
100 c.Assert(err, gc.IsNil)99 c.Assert(err, gc.IsNil)
101100
102 testJournalDirs(dir, c)101 testJournalDirs(dir, c)
@@ -127,7 +126,7 @@
127126
128 mockShellCommand(c, &s.CleanupSuite, "apt-get")127 mockShellCommand(c, &s.CleanupSuite, "apt-get")
129128
130 err := mongo.EnsureServer(dataDir, namespace, testInfo, mongo.WithHA)129 err := EnsureServer(dataDir, namespace, testInfo, WithHA)
131 c.Assert(err, gc.IsNil)130 c.Assert(err, gc.IsNil)
132131
133 testJournalDirs(dbDir, c)132 testJournalDirs(dbDir, c)
@@ -148,17 +147,17 @@
148 c.Assert(err, gc.IsNil)147 c.Assert(err, gc.IsNil)
149 c.Assert(contents, jc.DeepEquals, []byte("ENABLE_MONGODB=no"))148 c.Assert(contents, jc.DeepEquals, []byte("ENABLE_MONGODB=no"))
150149
151 contents, err = ioutil.ReadFile(mongo.SSLKeyPath(dataDir))150 contents, err = ioutil.ReadFile(sslKeyPath(dataDir))
152 c.Assert(err, gc.IsNil)151 c.Assert(err, gc.IsNil)
153 c.Assert(string(contents), gc.Equals, testInfo.Cert+"\n"+testInfo.PrivateKey)152 c.Assert(string(contents), gc.Equals, testInfo.Cert+"\n"+testInfo.PrivateKey)
154153
155 contents, err = ioutil.ReadFile(mongo.SharedSecretPath(dataDir))154 contents, err = ioutil.ReadFile(sharedSecretPath(dataDir))
156 c.Assert(err, gc.IsNil)155 c.Assert(err, gc.IsNil)
157 c.Assert(string(contents), gc.Equals, testInfo.SharedSecret)156 c.Assert(string(contents), gc.Equals, testInfo.SharedSecret)
158157
159 s.installed = nil158 s.installed = nil
160 // now check we can call it multiple times without error159 // now check we can call it multiple times without error
161 err = mongo.EnsureServer(dataDir, namespace, testInfo, mongo.WithHA)160 err = EnsureServer(dataDir, namespace, testInfo, WithHA)
162 c.Assert(err, gc.IsNil)161 c.Assert(err, gc.IsNil)
163 assertInstalled()162 assertInstalled()
164163
@@ -194,7 +193,7 @@
194193
195 s.PatchValue(&version.Current.Series, test.series)194 s.PatchValue(&version.Current.Series, test.series)
196195
197 err := mongo.EnsureServer(dataDir, namespace, testInfo, mongo.WithHA)196 err := EnsureServer(dataDir, namespace, testInfo, WithHA)
198 c.Assert(err, gc.IsNil)197 c.Assert(err, gc.IsNil)
199198
200 cmds := getMockShellCalls(c, output)199 cmds := getMockShellCalls(c, output)
@@ -215,40 +214,17 @@
215func (s *MongoSuite) TestUpstartServiceWithHA(c *gc.C) {214func (s *MongoSuite) TestUpstartServiceWithHA(c *gc.C) {
216 dataDir := c.MkDir()215 dataDir := c.MkDir()
217216
218 svc, _, err := mongo.UpstartService("", dataDir, dataDir, 1234, mongo.WithHA)217 svc, _, err := upstartService("", dataDir, dataDir, 1234, WithHA)
219 c.Assert(err, gc.IsNil)218 c.Assert(err, gc.IsNil)
220 c.Assert(strings.Contains(svc.Cmd, "--replSet"), jc.IsTrue)219 c.Assert(strings.Contains(svc.Cmd, "--replSet"), jc.IsTrue)
221220
222 svc, _, err = mongo.UpstartService("", dataDir, dataDir, 1234, mongo.WithoutHA)221 svc, _, err = upstartService("", dataDir, dataDir, 1234, WithoutHA)
223 c.Assert(err, gc.IsNil)222 c.Assert(err, gc.IsNil)
224 c.Assert(strings.Contains(svc.Cmd, "--replSet"), jc.IsFalse)223 c.Assert(strings.Contains(svc.Cmd, "--replSet"), jc.IsFalse)
225}224}
226225
227func (s *MongoSuite) TestUpstartServiceWithJournal(c *gc.C) {
228 dataDir := c.MkDir()
229
230 svc, _, err := mongo.UpstartService("", dataDir, dataDir, 1234, mongo.WithHA)
231 c.Assert(err, gc.IsNil)
232 journalPresent := strings.Contains(svc.Cmd, " --journal ") || strings.HasSuffix(svc.Cmd, " --journal")
233 c.Assert(journalPresent, jc.IsTrue)
234}
235
236func (s *MongoSuite) TestNoAuthCommandWithJournal(c *gc.C) {
237 dataDir := c.MkDir()
238
239 cmd, err := mongo.NoauthCommand(dataDir, 1234)
240 c.Assert(err, gc.IsNil)
241 var isJournalPresent bool
242 for _, value := range cmd.Args {
243 if value == "--journal" {
244 isJournalPresent = true
245 }
246 }
247 c.Assert(isJournalPresent, jc.IsTrue)
248}
249
250func (s *MongoSuite) TestRemoveService(c *gc.C) {226func (s *MongoSuite) TestRemoveService(c *gc.C) {
251 err := mongo.RemoveService("namespace")227 err := RemoveService("namespace")
252 c.Assert(err, gc.IsNil)228 c.Assert(err, gc.IsNil)
253 c.Assert(s.removed, jc.DeepEquals, []upstart.Service{{229 c.Assert(s.removed, jc.DeepEquals, []upstart.Service{{
254 Name: "juju-db-namespace",230 Name: "juju-db-namespace",
@@ -265,11 +241,11 @@
265 // test that we call add-apt-repository only for quantal (and that if it241 // test that we call add-apt-repository only for quantal (and that if it
266 // fails, we return the error)242 // fails, we return the error)
267 s.PatchValue(&version.Current.Series, "quantal")243 s.PatchValue(&version.Current.Series, "quantal")
268 err := mongo.EnsureServer(dir, "", testInfo, mongo.WithHA)244 err := EnsureServer(dir, "", testInfo, WithHA)
269 c.Assert(err, gc.ErrorMatches, "cannot install mongod: cannot add apt repository: exit status 1.*")245 c.Assert(err, gc.ErrorMatches, "cannot install mongod: cannot add apt repository: exit status 1.*")
270246
271 s.PatchValue(&version.Current.Series, "trusty")247 s.PatchValue(&version.Current.Series, "trusty")
272 err = mongo.EnsureServer(dir, "", testInfo, mongo.WithHA)248 err = EnsureServer(dir, "", testInfo, WithHA)
273 c.Assert(err, gc.IsNil)249 c.Assert(err, gc.IsNil)
274}250}
275251
@@ -278,7 +254,7 @@
278 // created.254 // created.
279 mockShellCommand(c, &s.CleanupSuite, "apt-get")255 mockShellCommand(c, &s.CleanupSuite, "apt-get")
280 dataDir := filepath.Join(c.MkDir(), "dir", "data")256 dataDir := filepath.Join(c.MkDir(), "dir", "data")
281 err := mongo.EnsureServer(dataDir, "", testInfo, mongo.WithHA)257 err := EnsureServer(dataDir, "", testInfo, WithHA)
282 c.Check(err, gc.IsNil)258 c.Check(err, gc.IsNil)
283259
284 _, err = os.Stat(filepath.Join(dataDir, "db"))260 _, err = os.Stat(filepath.Join(dataDir, "db"))
@@ -286,9 +262,9 @@
286}262}
287263
288func (s *MongoSuite) TestServiceName(c *gc.C) {264func (s *MongoSuite) TestServiceName(c *gc.C) {
289 name := mongo.ServiceName("foo")265 name := ServiceName("foo")
290 c.Assert(name, gc.Equals, "juju-db-foo")266 c.Assert(name, gc.Equals, "juju-db-foo")
291 name = mongo.ServiceName("")267 name = ServiceName("")
292 c.Assert(name, gc.Equals, "juju-db")268 c.Assert(name, gc.Equals, "juju-db")
293}269}
294270
@@ -303,7 +279,7 @@
303 NetworkName: "public",279 NetworkName: "public",
304 NetworkScope: instance.NetworkPublic}}280 NetworkScope: instance.NetworkPublic}}
305281
306 address := mongo.SelectPeerAddress(addresses)282 address := SelectPeerAddress(addresses)
307 c.Assert(address, gc.Equals, "10.0.0.1")283 c.Assert(address, gc.Equals, "10.0.0.1")
308}284}
309285
@@ -325,12 +301,12 @@
325 },301 },
326 Port: 37017}}302 Port: 37017}}
327303
328 address := mongo.SelectPeerHostPort(hostPorts)304 address := SelectPeerHostPort(hostPorts)
329 c.Assert(address, gc.Equals, "10.0.0.1:37017")305 c.Assert(address, gc.Equals, "10.0.0.1:37017")
330}306}
331307
332func (s *MongoSuite) TestGenerateSharedSecret(c *gc.C) {308func (s *MongoSuite) TestGenerateSharedSecret(c *gc.C) {
333 secret, err := mongo.GenerateSharedSecret()309 secret, err := GenerateSharedSecret()
334 c.Assert(err, gc.IsNil)310 c.Assert(err, gc.IsNil)
335 c.Assert(secret, gc.HasLen, 1024)311 c.Assert(secret, gc.HasLen, 1024)
336 _, err = base64.StdEncoding.DecodeString(secret)312 _, err = base64.StdEncoding.DecodeString(secret)
@@ -344,7 +320,7 @@
344 s.PatchValue(&version.Current.Series, "quantal")320 s.PatchValue(&version.Current.Series, "quantal")
345321
346 dataDir := c.MkDir()322 dataDir := c.MkDir()
347 err := mongo.EnsureServer(dataDir, "", testInfo, mongo.WithHA)323 err := EnsureServer(dataDir, "", testInfo, WithHA)
348 c.Assert(err, gc.IsNil)324 c.Assert(err, gc.IsNil)
349325
350 c.Assert(getMockShellCalls(c, addAptRepoOut), gc.DeepEquals, [][]string{{326 c.Assert(getMockShellCalls(c, addAptRepoOut), gc.DeepEquals, [][]string{{
351327
=== modified file 'agent/mongo/upgrade.go'
--- agent/mongo/upgrade.go 2014-05-22 00:56:59 +0000
+++ agent/mongo/upgrade.go 2014-05-22 14:33:28 +0000
@@ -8,15 +8,12 @@
8 "os"8 "os"
9 "os/exec"9 "os/exec"
10 "syscall"10 "syscall"
11 "time"
1211
13 "labix.org/v2/mgo"12 "labix.org/v2/mgo"
1413
15 "launchpad.net/juju-core/upstart"14 "launchpad.net/juju-core/upstart"
16)15)
1716
18const mongoSocketTimeout = 10 * time.Second
19
20var (17var (
21 processSignal = (*os.Process).Signal18 processSignal = (*os.Process).Signal
22)19)
@@ -54,13 +51,11 @@
54 if err != nil {51 if err != nil {
55 return false, fmt.Errorf("can't dial mongo to ensure admin user: %v", err)52 return false, fmt.Errorf("can't dial mongo to ensure admin user: %v", err)
56 }53 }
57 session.SetSocketTimeout(mongoSocketTimeout)
58 err = session.DB("admin").Login(p.User, p.Password)54 err = session.DB("admin").Login(p.User, p.Password)
59 session.Close()55 session.Close()
60 if err == nil {56 if err == nil {
61 return false, nil57 return false, nil
62 }58 }
63 logger.Debugf("admin login failed: %v", err)
6459
65 // Login failed, so we need to add the user.60 // Login failed, so we need to add the user.
66 // Stop mongo, so we can start it in --noauth mode.61 // Stop mongo, so we can start it in --noauth mode.
6762
=== modified file 'agent/mongo/upgrade_test.go'
--- agent/mongo/upgrade_test.go 2014-05-22 09:52:11 +0000
+++ agent/mongo/upgrade_test.go 2014-05-22 14:33:28 +0000
@@ -1,45 +1,35 @@
1// Copyright 2014 Canonical Ltd.1// Copyright 2014 Canonical Ltd.
2// Licensed under the AGPLv3, see LICENCE file for details.2// Licensed under the AGPLv3, see LICENCE file for details.
33
4package mongo_test4package mongo
55
6import (6import (
7 "net"7 "net"
8 "os"
9 "path/filepath"
10 "strconv"8 "strconv"
119
12 jujutesting "github.com/juju/testing"
13 jc "github.com/juju/testing/checkers"10 jc "github.com/juju/testing/checkers"
14 "labix.org/v2/mgo"11 "labix.org/v2/mgo"
15 gc "launchpad.net/gocheck"12 gc "launchpad.net/gocheck"
1613
17 "launchpad.net/juju-core/agent/mongo"
18 coretesting "launchpad.net/juju-core/testing"14 coretesting "launchpad.net/juju-core/testing"
15 "launchpad.net/juju-core/testing/testbase"
19 "launchpad.net/juju-core/upstart"16 "launchpad.net/juju-core/upstart"
20)17)
2118
22type EnsureAdminSuite struct {19type EnsureAdminSuite struct {
23 coretesting.BaseSuite20 testbase.LoggingSuite
24 serviceStarts int
25 serviceStops int
26}21}
2722
28var _ = gc.Suite(&EnsureAdminSuite{})23var _ = gc.Suite(&EnsureAdminSuite{})
2924
30func (s *EnsureAdminSuite) SetUpTest(c *gc.C) {25func (s *EnsureAdminSuite) SetUpTest(c *gc.C) {
31 s.BaseSuite.SetUpTest(c)26 s.PatchValue(&upstartConfInstall, func(conf *upstart.Conf) error {
32 s.serviceStarts = 027 return nil
33 s.serviceStops = 028 })
34 s.PatchValue(mongo.UpstartConfInstall, func(conf *upstart.Conf) error {29 s.PatchValue(&upstartServiceStart, func(svc *upstart.Service) error {
35 return nil30 return nil
36 })31 })
37 s.PatchValue(mongo.UpstartServiceStart, func(svc *upstart.Service) error {32 s.PatchValue(&upstartServiceStop, func(svc *upstart.Service) error {
38 s.serviceStarts++
39 return nil
40 })
41 s.PatchValue(mongo.UpstartServiceStop, func(svc *upstart.Service) error {
42 s.serviceStops++
43 return nil33 return nil
44 })34 })
45}35}
@@ -50,50 +40,14 @@
50 c.Assert(err, gc.IsNil)40 c.Assert(err, gc.IsNil)
51 defer inst.DestroyWithLog()41 defer inst.DestroyWithLog()
52 dialInfo := inst.DialInfo()42 dialInfo := inst.DialInfo()
53
54 // Mock out mongod, so the --noauth execution doesn't
55 // do anything nasty. Also mock out the Signal method.
56 jujutesting.PatchExecutableAsEchoArgs(c, s, "mongod")
57 mongodDir := filepath.SplitList(os.Getenv("PATH"))[0]
58 s.PatchValue(&mongo.JujuMongodPath, filepath.Join(mongodDir, "mongod"))
59 s.PatchValue(mongo.ProcessSignal, func(*os.Process, os.Signal) error {
60 return nil
61 })
62
63 // First call succeeds, as there are no users yet.43 // First call succeeds, as there are no users yet.
64 added, err := s.ensureAdminUser(c, dialInfo, "whomever", "whatever")44 added, err := s.ensureAdminUser(c, dialInfo, "whomever", "whatever")
65 c.Assert(err, gc.IsNil)45 c.Assert(err, gc.IsNil)
66 c.Assert(added, jc.IsTrue)46 c.Assert(added, jc.IsTrue)
67
68 // EnsureAdminUser should have stopped the mongo service,
69 // started a new mongod with --noauth, and then finally
70 // started the service back up.
71 c.Assert(s.serviceStarts, gc.Equals, 1)
72 c.Assert(s.serviceStops, gc.Equals, 1)
73 _, portString, err := net.SplitHostPort(dialInfo.Addrs[0])
74 c.Assert(err, gc.IsNil)
75 jujutesting.AssertEchoArgs(c, "mongod",
76 "--noauth",
77 "--dbpath", "db",
78 "--sslOnNormalPorts",
79 "--sslPEMKeyFile", "server.pem",
80 "--sslPEMKeyPassword", "ignored",
81 "--bind_ip", "127.0.0.1",
82 "--port", portString,
83 "--noprealloc",
84 "--syslog",
85 "--smallfiles",
86 "--journal",
87 )
88
89 // Second call succeeds, as the admin user is already there.47 // Second call succeeds, as the admin user is already there.
90 added, err = s.ensureAdminUser(c, dialInfo, "whomever", "whatever")48 added, err = s.ensureAdminUser(c, dialInfo, "whomever", "whatever")
91 c.Assert(err, gc.IsNil)49 c.Assert(err, gc.IsNil)
92 c.Assert(added, jc.IsFalse)50 c.Assert(added, jc.IsFalse)
93
94 // There should have been no additional start/stop.
95 c.Assert(s.serviceStarts, gc.Equals, 1)
96 c.Assert(s.serviceStops, gc.Equals, 1)
97}51}
9852
99func (s *EnsureAdminSuite) TestEnsureAdminUserError(c *gc.C) {53func (s *EnsureAdminSuite) TestEnsureAdminUserError(c *gc.C) {
@@ -119,7 +73,7 @@
119 c.Assert(err, gc.IsNil)73 c.Assert(err, gc.IsNil)
120 port, err := strconv.Atoi(portString)74 port, err := strconv.Atoi(portString)
121 c.Assert(err, gc.IsNil)75 c.Assert(err, gc.IsNil)
122 return mongo.EnsureAdminUser(mongo.EnsureAdminUserParams{76 return EnsureAdminUser(EnsureAdminUserParams{
123 DialInfo: dialInfo,77 DialInfo: dialInfo,
124 Port: port,78 Port: port,
125 User: user,79 User: user,
12680
=== modified file 'agent/tools/diskmanager_test.go'
--- agent/tools/diskmanager_test.go 2014-05-20 04:27:02 +0000
+++ agent/tools/diskmanager_test.go 2014-05-22 14:33:28 +0000
@@ -13,6 +13,7 @@
1313
14 agenttools "launchpad.net/juju-core/agent/tools"14 agenttools "launchpad.net/juju-core/agent/tools"
15 coretesting "launchpad.net/juju-core/testing"15 coretesting "launchpad.net/juju-core/testing"
16 "launchpad.net/juju-core/testing/testbase"
16 coretools "launchpad.net/juju-core/tools"17 coretools "launchpad.net/juju-core/tools"
17 "launchpad.net/juju-core/version"18 "launchpad.net/juju-core/version"
18)19)
@@ -22,13 +23,13 @@
22var _ agenttools.ToolsManager = (*agenttools.DiskManager)(nil)23var _ agenttools.ToolsManager = (*agenttools.DiskManager)(nil)
2324
24type DiskManagerSuite struct {25type DiskManagerSuite struct {
25 coretesting.BaseSuite26 testbase.LoggingSuite
26 dataDir string27 dataDir string
27 manager agenttools.ToolsManager28 manager agenttools.ToolsManager
28}29}
2930
30func (s *DiskManagerSuite) SetUpTest(c *gc.C) {31func (s *DiskManagerSuite) SetUpTest(c *gc.C) {
31 s.BaseSuite.SetUpTest(c)32 s.LoggingSuite.SetUpTest(c)
32 s.dataDir = c.MkDir()33 s.dataDir = c.MkDir()
33 s.manager = agenttools.NewDiskManager(s.dataDir)34 s.manager = agenttools.NewDiskManager(s.dataDir)
34}35}
3536
=== modified file 'agent/tools/tools_test.go'
--- agent/tools/tools_test.go 2014-05-20 04:27:02 +0000
+++ agent/tools/tools_test.go 2014-05-22 14:33:28 +0000
@@ -21,14 +21,14 @@
21)21)
2222
23type ToolsSuite struct {23type ToolsSuite struct {
24 testing.BaseSuite24 testbase.LoggingSuite
25 dataDir string25 dataDir string
26}26}
2727
28var _ = gc.Suite(&ToolsSuite{})28var _ = gc.Suite(&ToolsSuite{})
2929
30func (t *ToolsSuite) SetUpTest(c *gc.C) {30func (t *ToolsSuite) SetUpTest(c *gc.C) {
31 t.BaseSuite.SetUpTest(c)31 t.LoggingSuite.SetUpTest(c)
32 t.dataDir = c.MkDir()32 t.dataDir = c.MkDir()
33}33}
3434
3535
=== modified file 'bzr/bzr_test.go'
--- bzr/bzr_test.go 2014-05-20 04:27:02 +0000
+++ bzr/bzr_test.go 2014-05-22 14:33:28 +0000
@@ -8,22 +8,22 @@
8 "os"8 "os"
9 "os/exec"9 "os/exec"
10 "path/filepath"10 "path/filepath"
11 stdtesting "testing"11 "testing"
1212
13 gc "launchpad.net/gocheck"13 gc "launchpad.net/gocheck"
1414
15 "launchpad.net/juju-core/bzr"15 "launchpad.net/juju-core/bzr"
16 "launchpad.net/juju-core/testing"16 "launchpad.net/juju-core/testing/testbase"
17)17)
1818
19func Test(t *stdtesting.T) {19func Test(t *testing.T) {
20 gc.TestingT(t)20 gc.TestingT(t)
21}21}
2222
23var _ = gc.Suite(&BzrSuite{})23var _ = gc.Suite(&BzrSuite{})
2424
25type BzrSuite struct {25type BzrSuite struct {
26 testing.BaseSuite26 testbase.LoggingSuite
27 b *bzr.Branch27 b *bzr.Branch
28}28}
2929
@@ -32,7 +32,7 @@
32`32`
3333
34func (s *BzrSuite) SetUpTest(c *gc.C) {34func (s *BzrSuite) SetUpTest(c *gc.C) {
35 s.BaseSuite.SetUpTest(c)35 s.LoggingSuite.SetUpTest(c)
36 bzrdir := c.MkDir()36 bzrdir := c.MkDir()
37 s.PatchEnvironment("BZR_HOME", bzrdir)37 s.PatchEnvironment("BZR_HOME", bzrdir)
38 err := os.Mkdir(filepath.Join(bzrdir, ".bazaar"), 0755)38 err := os.Mkdir(filepath.Join(bzrdir, ".bazaar"), 0755)
3939
=== modified file 'charm/dir_test.go'
--- charm/dir_test.go 2014-05-20 04:27:02 +0000
+++ charm/dir_test.go 2014-05-22 14:33:28 +0000
@@ -17,10 +17,11 @@
1717
18 "launchpad.net/juju-core/charm"18 "launchpad.net/juju-core/charm"
19 "launchpad.net/juju-core/testing"19 "launchpad.net/juju-core/testing"
20 "launchpad.net/juju-core/testing/testbase"
20)21)
2122
22type DirSuite struct {23type DirSuite struct {
23 testing.BaseSuite24 testbase.LoggingSuite
24}25}
2526
26var _ = gc.Suite(&DirSuite{})27var _ = gc.Suite(&DirSuite{})
2728
=== modified file 'cloudinit/cloudinit_test.go'
--- cloudinit/cloudinit_test.go 2014-05-20 04:27:02 +0000
+++ cloudinit/cloudinit_test.go 2014-05-22 14:33:28 +0000
@@ -10,14 +10,14 @@
10 gc "launchpad.net/gocheck"10 gc "launchpad.net/gocheck"
1111
12 "launchpad.net/juju-core/cloudinit"12 "launchpad.net/juju-core/cloudinit"
13 coretesting "launchpad.net/juju-core/testing"13 "launchpad.net/juju-core/testing/testbase"
14 sshtesting "launchpad.net/juju-core/utils/ssh/testing"14 sshtesting "launchpad.net/juju-core/utils/ssh/testing"
15)15)
1616
17// TODO integration tests, but how?17// TODO integration tests, but how?
1818
19type S struct {19type S struct {
20 coretesting.BaseSuite20 testbase.LoggingSuite
21}21}
2222
23var _ = gc.Suite(S{})23var _ = gc.Suite(S{})
2424
=== modified file 'cloudinit/sshinit/configure_test.go'
--- cloudinit/sshinit/configure_test.go 2014-05-20 04:27:02 +0000
+++ cloudinit/sshinit/configure_test.go 2014-05-22 14:33:28 +0000
@@ -17,12 +17,13 @@
17 envtools "launchpad.net/juju-core/environs/tools"17 envtools "launchpad.net/juju-core/environs/tools"
18 "launchpad.net/juju-core/state/api/params"18 "launchpad.net/juju-core/state/api/params"
19 coretesting "launchpad.net/juju-core/testing"19 coretesting "launchpad.net/juju-core/testing"
20 "launchpad.net/juju-core/testing/testbase"
20 "launchpad.net/juju-core/tools"21 "launchpad.net/juju-core/tools"
21 "launchpad.net/juju-core/version"22 "launchpad.net/juju-core/version"
22)23)
2324
24type configureSuite struct {25type configureSuite struct {
25 coretesting.BaseSuite26 testbase.LoggingSuite
26}27}
2728
28var _ = gc.Suite(&configureSuite{})29var _ = gc.Suite(&configureSuite{})
2930
=== modified file 'cmd/charm-admin/config_test.go'
--- cmd/charm-admin/config_test.go 2014-05-20 04:27:02 +0000
+++ cmd/charm-admin/config_test.go 2014-05-22 14:33:28 +0000
@@ -12,10 +12,11 @@
1212
13 "launchpad.net/juju-core/cmd"13 "launchpad.net/juju-core/cmd"
14 "launchpad.net/juju-core/testing"14 "launchpad.net/juju-core/testing"
15 "launchpad.net/juju-core/testing/testbase"
15)16)
1617
17type ConfigSuite struct {18type ConfigSuite struct {
18 testing.BaseSuite19 testbase.LoggingSuite
19}20}
2021
21var _ = gc.Suite(&ConfigSuite{})22var _ = gc.Suite(&ConfigSuite{})
@@ -27,11 +28,11 @@
27`28`
2829
29func (s *ConfigSuite) SetUpSuite(c *gc.C) {30func (s *ConfigSuite) SetUpSuite(c *gc.C) {
30 s.BaseSuite.SetUpSuite(c)31 s.LoggingSuite.SetUpSuite(c)
31}32}
3233
33func (s *ConfigSuite) TearDownSuite(c *gc.C) {34func (s *ConfigSuite) TearDownSuite(c *gc.C) {
34 s.BaseSuite.TearDownSuite(c)35 s.LoggingSuite.TearDownSuite(c)
35}36}
3637
37type SomeConfigCommand struct {38type SomeConfigCommand struct {
3839
=== modified file 'cmd/charm-admin/deletecharm_test.go'
--- cmd/charm-admin/deletecharm_test.go 2014-05-20 04:27:02 +0000
+++ cmd/charm-admin/deletecharm_test.go 2014-05-22 14:33:28 +0000
@@ -13,10 +13,11 @@
13 "launchpad.net/juju-core/charm"13 "launchpad.net/juju-core/charm"
14 "launchpad.net/juju-core/store"14 "launchpad.net/juju-core/store"
15 "launchpad.net/juju-core/testing"15 "launchpad.net/juju-core/testing"
16 "launchpad.net/juju-core/testing/testbase"
16)17)
1718
18type DeleteCharmSuite struct {19type DeleteCharmSuite struct {
19 testing.BaseSuite20 testbase.LoggingSuite
20}21}
2122
22var _ = gc.Suite(&DeleteCharmSuite{})23var _ = gc.Suite(&DeleteCharmSuite{})
@@ -26,11 +27,11 @@
26`27`
2728
28func (s *DeleteCharmSuite) SetUpSuite(c *gc.C) {29func (s *DeleteCharmSuite) SetUpSuite(c *gc.C) {
29 s.BaseSuite.SetUpSuite(c)30 s.LoggingSuite.SetUpSuite(c)
30}31}
3132
32func (s *DeleteCharmSuite) TearDownSuite(c *gc.C) {33func (s *DeleteCharmSuite) TearDownSuite(c *gc.C) {
33 s.BaseSuite.TearDownSuite(c)34 s.LoggingSuite.TearDownSuite(c)
34}35}
3536
36func (s *DeleteCharmSuite) TestInit(c *gc.C) {37func (s *DeleteCharmSuite) TestInit(c *gc.C) {
3738
=== modified file 'cmd/envcmd/environmentcommand_test.go'
--- cmd/envcmd/environmentcommand_test.go 2014-05-16 01:33:13 +0000
+++ cmd/envcmd/environmentcommand_test.go 2014-05-22 14:33:28 +0000
@@ -20,13 +20,21 @@
20)20)
2121
22type EnvironmentCommandSuite struct {22type EnvironmentCommandSuite struct {
23 coretesting.FakeJujuHomeSuite23 home *coretesting.FakeHome
24}24}
2525
26var _ = gc.Suite(&EnvironmentCommandSuite{})26var _ = gc.Suite(&EnvironmentCommandSuite{})
2727
28func Test(t *testing.T) { gc.TestingT(t) }28func Test(t *testing.T) { gc.TestingT(t) }
2929
30func (s *EnvironmentCommandSuite) SetUpTest(c *gc.C) {
31 s.home = coretesting.MakeEmptyFakeHome(c)
32}
33
34func (s *EnvironmentCommandSuite) TearDownTest(c *gc.C) {
35 s.home.Restore()
36}
37
30func (s *EnvironmentCommandSuite) TestReadCurrentEnvironmentUnset(c *gc.C) {38func (s *EnvironmentCommandSuite) TestReadCurrentEnvironmentUnset(c *gc.C) {
31 env := envcmd.ReadCurrentEnvironment()39 env := envcmd.ReadCurrentEnvironment()
32 c.Assert(env, gc.Equals, "")40 c.Assert(env, gc.Equals, "")
@@ -40,9 +48,6 @@
40}48}
4149
42func (s *EnvironmentCommandSuite) TestGetDefaultEnvironmentNothingSet(c *gc.C) {50func (s *EnvironmentCommandSuite) TestGetDefaultEnvironmentNothingSet(c *gc.C) {
43 envPath := coretesting.HomePath(".juju", "environments.yaml")
44 err := os.Remove(envPath)
45 c.Assert(err, gc.IsNil)
46 env, err := envcmd.GetDefaultEnvironment()51 env, err := envcmd.GetDefaultEnvironment()
47 c.Assert(env, gc.Equals, "")52 c.Assert(env, gc.Equals, "")
48 c.Assert(err, jc.Satisfies, environs.IsNoEnv)53 c.Assert(err, jc.Satisfies, environs.IsNoEnv)
@@ -95,12 +100,12 @@
95 c.Assert(*envName, gc.Equals, "explicit")100 c.Assert(*envName, gc.Equals, "explicit")
96101
97 // Take environment name from the default.102 // Take environment name from the default.
98 coretesting.WriteEnvironments(c, coretesting.MultipleEnvConfig)103 defer coretesting.MakeFakeHome(c, coretesting.MultipleEnvConfig).Restore()
99 testEnsureEnvName(c, coretesting.SampleEnvName)104 testEnsureEnvName(c, coretesting.SampleEnvName)
100105
101 // Take environment name from the one and only environment,106 // Take environment name from the one and only environment,
102 // even if it is not explicitly marked as default.107 // even if it is not explicitly marked as default.
103 coretesting.WriteEnvironments(c, coretesting.SingleEnvConfigNoDefault)108 defer coretesting.MakeFakeHome(c, coretesting.SingleEnvConfigNoDefault).Restore()
104 testEnsureEnvName(c, coretesting.SampleEnvName)109 testEnsureEnvName(c, coretesting.SampleEnvName)
105110
106 // If there is a current-environment file, use that.111 // If there is a current-environment file, use that.
@@ -109,16 +114,13 @@
109}114}
110115
111func (s *EnvironmentCommandSuite) TestEnvironCommandInitErrors(c *gc.C) {116func (s *EnvironmentCommandSuite) TestEnvironCommandInitErrors(c *gc.C) {
112 envPath := coretesting.HomePath(".juju", "environments.yaml")
113 err := os.Remove(envPath)
114 c.Assert(err, gc.IsNil)
115 cmd, _ := prepareEnvCommand(c, "")117 cmd, _ := prepareEnvCommand(c, "")
116 err = cmd.Init(nil)118 err := cmd.Init(nil)
117 c.Assert(err, jc.Satisfies, environs.IsNoEnv)119 c.Assert(err, jc.Satisfies, environs.IsNoEnv)
118120
119 // If there are multiple environments but no default,121 // If there are multiple environments but no default,
120 // an error should be returned.122 // an error should be returned.
121 coretesting.WriteEnvironments(c, coretesting.MultipleEnvConfigNoDefault)123 defer coretesting.MakeFakeHome(c, coretesting.MultipleEnvConfigNoDefault).Restore()
122 cmd, _ = prepareEnvCommand(c, "")124 cmd, _ = prepareEnvCommand(c, "")
123 err = cmd.Init(nil)125 err = cmd.Init(nil)
124 c.Assert(err, gc.Equals, envcmd.ErrNoEnvironmentSpecified)126 c.Assert(err, gc.Equals, envcmd.ErrNoEnvironmentSpecified)
125127
=== modified file 'cmd/filevar_test.go'
--- cmd/filevar_test.go 2014-05-16 01:33:13 +0000
+++ cmd/filevar_test.go 2014-05-22 14:33:28 +0000
@@ -17,7 +17,6 @@
17)17)
1818
19type FileVarSuite struct {19type FileVarSuite struct {
20 testing.FakeHomeSuite
21 ctx *cmd.Context20 ctx *cmd.Context
22 ValidPath string21 ValidPath string
23 InvalidPath string // invalid path refers to a file which is not readable22 InvalidPath string // invalid path refers to a file which is not readable
@@ -26,7 +25,6 @@
26var _ = gc.Suite(&FileVarSuite{})25var _ = gc.Suite(&FileVarSuite{})
2726
28func (s *FileVarSuite) SetUpTest(c *gc.C) {27func (s *FileVarSuite) SetUpTest(c *gc.C) {
29 s.FakeHomeSuite.SetUpTest(c)
30 s.ctx = testing.Context(c)28 s.ctx = testing.Context(c)
31 s.ValidPath = s.ctx.AbsPath("valid.yaml")29 s.ValidPath = s.ctx.AbsPath("valid.yaml")
32 s.InvalidPath = s.ctx.AbsPath("invalid.yaml")30 s.InvalidPath = s.ctx.AbsPath("invalid.yaml")
@@ -41,6 +39,7 @@
41}39}
4240
43func (s *FileVarSuite) TestTildeFileVar(c *gc.C) {41func (s *FileVarSuite) TestTildeFileVar(c *gc.C) {
42 defer testing.MakeEmptyFakeHome(c).Restore()
44 path := filepath.Join(osenv.Home(), "config.yaml")43 path := filepath.Join(osenv.Home(), "config.yaml")
45 err := ioutil.WriteFile(path, []byte("abc"), 0644)44 err := ioutil.WriteFile(path, []byte("abc"), 0644)
46 c.Assert(err, gc.IsNil)45 c.Assert(err, gc.IsNil)
4746
=== renamed file 'cmd/juju/user_add.go' => 'cmd/juju/adduser.go'
=== renamed file 'cmd/juju/user_add_test.go' => 'cmd/juju/adduser_test.go'
=== modified file 'cmd/juju/authorizedkeys_test.go'
--- cmd/juju/authorizedkeys_test.go 2014-05-16 04:20:04 +0000
+++ cmd/juju/authorizedkeys_test.go 2014-05-22 14:33:28 +0000
@@ -15,11 +15,13 @@
15 keymanagerserver "launchpad.net/juju-core/state/apiserver/keymanager"15 keymanagerserver "launchpad.net/juju-core/state/apiserver/keymanager"
16 keymanagertesting "launchpad.net/juju-core/state/apiserver/keymanager/testing"16 keymanagertesting "launchpad.net/juju-core/state/apiserver/keymanager/testing"
17 coretesting "launchpad.net/juju-core/testing"17 coretesting "launchpad.net/juju-core/testing"
18 "launchpad.net/juju-core/testing/testbase"
18 sshtesting "launchpad.net/juju-core/utils/ssh/testing"19 sshtesting "launchpad.net/juju-core/utils/ssh/testing"
19)20)
2021
21type AuthorizedKeysSuite struct {22type AuthorizedKeysSuite struct {
22 coretesting.FakeJujuHomeSuite23 testbase.LoggingSuite
24 jujuHome *coretesting.FakeHome
23}25}
2426
25var _ = gc.Suite(&AuthorizedKeysSuite{})27var _ = gc.Suite(&AuthorizedKeysSuite{})
@@ -32,6 +34,16 @@
32 "list",34 "list",
33}35}
3436
37func (s *AuthorizedKeysSuite) SetUpTest(c *gc.C) {
38 s.LoggingSuite.SetUpTest(c)
39 s.jujuHome = coretesting.MakeEmptyFakeHome(c)
40}
41
42func (s *AuthorizedKeysSuite) TearDownTest(c *gc.C) {
43 s.jujuHome.Restore()
44 s.LoggingSuite.TearDownTest(c)
45}
46
35func (s *AuthorizedKeysSuite) TestHelpCommands(c *gc.C) {47func (s *AuthorizedKeysSuite) TestHelpCommands(c *gc.C) {
36 // Check that we have correctly registered all the sub commands48 // Check that we have correctly registered all the sub commands
37 // by checking the help output.49 // by checking the help output.
3850
=== modified file 'cmd/juju/bootstrap_test.go'
--- cmd/juju/bootstrap_test.go 2014-05-21 22:15:10 +0000
+++ cmd/juju/bootstrap_test.go 2014-05-22 14:33:28 +0000
@@ -5,7 +5,6 @@
55
6import (6import (
7 "fmt"7 "fmt"
8 "os"
9 "strings"8 "strings"
109
11 "github.com/juju/errors"10 "github.com/juju/errors"
@@ -31,12 +30,13 @@
31 "launchpad.net/juju-core/juju/arch"30 "launchpad.net/juju-core/juju/arch"
32 "launchpad.net/juju-core/provider/dummy"31 "launchpad.net/juju-core/provider/dummy"
33 coretesting "launchpad.net/juju-core/testing"32 coretesting "launchpad.net/juju-core/testing"
33 "launchpad.net/juju-core/testing/testbase"
34 coretools "launchpad.net/juju-core/tools"34 coretools "launchpad.net/juju-core/tools"
35 "launchpad.net/juju-core/version"35 "launchpad.net/juju-core/version"
36)36)
3737
38type BootstrapSuite struct {38type BootstrapSuite struct {
39 coretesting.FakeJujuHomeSuite39 testbase.LoggingSuite
40 coretesting.MgoSuite40 coretesting.MgoSuite
41 envtesting.ToolsFixture41 envtesting.ToolsFixture
42}42}
@@ -44,12 +44,12 @@
44var _ = gc.Suite(&BootstrapSuite{})44var _ = gc.Suite(&BootstrapSuite{})
4545
46func (s *BootstrapSuite) SetUpSuite(c *gc.C) {46func (s *BootstrapSuite) SetUpSuite(c *gc.C) {
47 s.FakeJujuHomeSuite.SetUpSuite(c)47 s.LoggingSuite.SetUpSuite(c)
48 s.MgoSuite.SetUpSuite(c)48 s.MgoSuite.SetUpSuite(c)
49}49}
5050
51func (s *BootstrapSuite) SetUpTest(c *gc.C) {51func (s *BootstrapSuite) SetUpTest(c *gc.C) {
52 s.FakeJujuHomeSuite.SetUpTest(c)52 s.LoggingSuite.SetUpTest(c)
53 s.MgoSuite.SetUpTest(c)53 s.MgoSuite.SetUpTest(c)
54 s.ToolsFixture.SetUpTest(c)54 s.ToolsFixture.SetUpTest(c)
5555
@@ -62,13 +62,13 @@
6262
63func (s *BootstrapSuite) TearDownSuite(c *gc.C) {63func (s *BootstrapSuite) TearDownSuite(c *gc.C) {
64 s.MgoSuite.TearDownSuite(c)64 s.MgoSuite.TearDownSuite(c)
65 s.FakeJujuHomeSuite.TearDownSuite(c)65 s.LoggingSuite.TearDownSuite(c)
66}66}
6767
68func (s *BootstrapSuite) TearDownTest(c *gc.C) {68func (s *BootstrapSuite) TearDownTest(c *gc.C) {
69 s.ToolsFixture.TearDownTest(c)69 s.ToolsFixture.TearDownTest(c)
70 s.MgoSuite.TearDownTest(c)70 s.MgoSuite.TearDownTest(c)
71 s.FakeJujuHomeSuite.TearDownTest(c)71 s.LoggingSuite.TearDownTest(c)
72 dummy.Reset()72 dummy.Reset()
73}73}
7474
@@ -130,7 +130,8 @@
130 toolsVersions = append(toolsVersions, testVersion)130 toolsVersions = append(toolsVersions, testVersion)
131 }131 }
132 }132 }
133 resetJujuHome(c)133 _, fake := makeEmptyFakeHome(c)
134 defer fake.Restore()
134 sourceDir := createToolsSource(c, toolsVersions)135 sourceDir := createToolsSource(c, toolsVersions)
135 s.PatchValue(&envtools.DefaultBaseURL, sourceDir)136 s.PatchValue(&envtools.DefaultBaseURL, sourceDir)
136137
@@ -176,7 +177,8 @@
176func (test bootstrapTest) run(c *gc.C) {177func (test bootstrapTest) run(c *gc.C) {
177 // Create home with dummy provider and remove all178 // Create home with dummy provider and remove all
178 // of its envtools.179 // of its envtools.
179 env := resetJujuHome(c)180 env, fake := makeEmptyFakeHome(c)
181 defer fake.Restore()
180182
181 if test.version != "" {183 if test.version != "" {
182 useVersion := strings.Replace(test.version, "%LTS%", config.LatestLtsSeries(), 1)184 useVersion := strings.Replace(test.version, "%LTS%", config.LatestLtsSeries(), 1)
@@ -368,7 +370,8 @@
368}}370}}
369371
370func (s *BootstrapSuite) TestBootstrapTwice(c *gc.C) {372func (s *BootstrapSuite) TestBootstrapTwice(c *gc.C) {
371 env := resetJujuHome(c)373 env, fake := makeEmptyFakeHome(c)
374 defer fake.Restore()
372 defaultSeriesVersion := version.Current375 defaultSeriesVersion := version.Current
373 defaultSeriesVersion.Series = config.PreferredSeries(env.Config())376 defaultSeriesVersion.Series = config.PreferredSeries(env.Config())
374 // Force a dev version by having an odd minor version number.377 // Force a dev version by having an odd minor version number.
@@ -400,7 +403,8 @@
400 s.PatchValue(&getBootstrapFuncs, func() BootstrapInterface {403 s.PatchValue(&getBootstrapFuncs, func() BootstrapInterface {
401 return _bootstrap404 return _bootstrap
402 })405 })
403 resetJujuHome(c)406 _, fake := makeEmptyFakeHome(c)
407 defer fake.Restore()
404408
405 ctx, err := coretesting.RunCommand(c, envcmd.Wrap(&BootstrapCommand{}),409 ctx, err := coretesting.RunCommand(c, envcmd.Wrap(&BootstrapCommand{}),
406 []string{"--upload-tools", argVariant, "foo,bar"})410 []string{"--upload-tools", argVariant, "foo,bar"})
@@ -411,7 +415,8 @@
411}415}
412416
413func (s *BootstrapSuite) TestBootstrapJenvWarning(c *gc.C) {417func (s *BootstrapSuite) TestBootstrapJenvWarning(c *gc.C) {
414 env := resetJujuHome(c)418 env, fake := makeEmptyFakeHome(c)
419 defer fake.Restore()
415 defaultSeriesVersion := version.Current420 defaultSeriesVersion := version.Current
416 defaultSeriesVersion.Series = config.PreferredSeries(env.Config())421 defaultSeriesVersion.Series = config.PreferredSeries(env.Config())
417 // Force a dev version by having an odd minor version number.422 // Force a dev version by having an odd minor version number.
@@ -437,7 +442,8 @@
437442
438func (s *BootstrapSuite) TestInvalidLocalSource(c *gc.C) {443func (s *BootstrapSuite) TestInvalidLocalSource(c *gc.C) {
439 s.PatchValue(&version.Current.Number, version.MustParse("1.2.0"))444 s.PatchValue(&version.Current.Number, version.MustParse("1.2.0"))
440 env := resetJujuHome(c)445 env, fake := makeEmptyFakeHome(c)
446 defer fake.Restore()
441447
442 // Bootstrap the environment with an invalid source.448 // Bootstrap the environment with an invalid source.
443 // The command returns with an error.449 // The command returns with an error.
@@ -485,7 +491,8 @@
485491
486func (s *BootstrapSuite) TestUploadLocalImageMetadata(c *gc.C) {492func (s *BootstrapSuite) TestUploadLocalImageMetadata(c *gc.C) {
487 sourceDir, expected := createImageMetadata(c)493 sourceDir, expected := createImageMetadata(c)
488 env := resetJujuHome(c)494 env, fake := makeEmptyFakeHome(c)
495 defer fake.Restore()
489496
490 // Bootstrap the environment with the valid source.497 // Bootstrap the environment with the valid source.
491 // Force a dev version by having an odd minor version number.498 // Force a dev version by having an odd minor version number.
@@ -506,7 +513,8 @@
506func (s *BootstrapSuite) TestAutoSyncLocalSource(c *gc.C) {513func (s *BootstrapSuite) TestAutoSyncLocalSource(c *gc.C) {
507 sourceDir := createToolsSource(c, vAll)514 sourceDir := createToolsSource(c, vAll)
508 s.PatchValue(&version.Current.Number, version.MustParse("1.2.0"))515 s.PatchValue(&version.Current.Number, version.MustParse("1.2.0"))
509 env := resetJujuHome(c)516 env, fake := makeEmptyFakeHome(c)
517 defer fake.Restore()
510518
511 // Bootstrap the environment with the valid source.519 // Bootstrap the environment with the valid source.
512 // The bootstrapping has to show no error, because the tools520 // The bootstrapping has to show no error, because the tools
@@ -534,7 +542,9 @@
534542
535 // Create home with dummy provider and remove all543 // Create home with dummy provider and remove all
536 // of its envtools.544 // of its envtools.
537 return resetJujuHome(c)545 env, fake := makeEmptyFakeHome(c)
546 s.AddCleanup(func(*gc.C) { fake.Restore() })
547 return env
538}548}
539549
540func (s *BootstrapSuite) TestAutoUploadAfterFailedSync(c *gc.C) {550func (s *BootstrapSuite) TestAutoUploadAfterFailedSync(c *gc.C) {
@@ -602,7 +612,8 @@
602}612}
603613
604func (s *BootstrapSuite) TestBootstrapDestroy(c *gc.C) {614func (s *BootstrapSuite) TestBootstrapDestroy(c *gc.C) {
605 resetJujuHome(c)615 _, fake := makeEmptyFakeHome(c)
616 defer fake.Restore()
606 devVersion := version.Current617 devVersion := version.Current
607 // Force a dev version by having an odd minor version number.618 // Force a dev version by having an odd minor version number.
608 // This is because we have not uploaded any tools and auto619 // This is because we have not uploaded any tools and auto
@@ -640,19 +651,16 @@
640 return source651 return source
641}652}
642653
643// resetJujuHome restores an new, clean Juju home environment without tools.654// makeEmptyFakeHome creates a faked home without envtools.
644func resetJujuHome(c *gc.C) environs.Environ {655func makeEmptyFakeHome(c *gc.C) (environs.Environ, *coretesting.FakeHome) {
645 jenvDir := coretesting.HomePath(".juju", "environments")656 fake := coretesting.MakeFakeHome(c, envConfig)
646 err := os.RemoveAll(jenvDir)
647 c.Assert(err, gc.IsNil)
648 coretesting.WriteEnvironments(c, envConfig)
649 dummy.Reset()657 dummy.Reset()
650 store, err := configstore.Default()658 store, err := configstore.Default()
651 c.Assert(err, gc.IsNil)659 c.Assert(err, gc.IsNil)
652 env, err := environs.PrepareFromName("peckham", nullContext(c), store)660 env, err := environs.PrepareFromName("peckham", nullContext(c), store)
653 c.Assert(err, gc.IsNil)661 c.Assert(err, gc.IsNil)
654 envtesting.RemoveAllTools(c, env)662 envtesting.RemoveAllTools(c, env)
655 return env663 return env, fake
656}664}
657665
658// checkTools check if the environment contains the passed envtools.666// checkTools check if the environment contains the passed envtools.
659667
=== modified file 'cmd/juju/cmd_test.go'
--- cmd/juju/cmd_test.go 2014-05-16 01:33:13 +0000
+++ cmd/juju/cmd_test.go 2014-05-22 14:33:28 +0000
@@ -22,6 +22,7 @@
2222
23type CmdSuite struct {23type CmdSuite struct {
24 testing.JujuConnSuite24 testing.JujuConnSuite
25 home *coretesting.FakeHome
25}26}
2627
27var _ = gc.Suite(&CmdSuite{})28var _ = gc.Suite(&CmdSuite{})
@@ -49,10 +50,11 @@
4950
50func (s *CmdSuite) SetUpTest(c *gc.C) {51func (s *CmdSuite) SetUpTest(c *gc.C) {
51 s.JujuConnSuite.SetUpTest(c)52 s.JujuConnSuite.SetUpTest(c)
52 coretesting.WriteEnvironments(c, envConfig, "peckham", "walthamstow", "brokenenv")53 s.home = coretesting.MakeFakeHome(c, envConfig, "peckham", "walthamstow", "brokenenv")
53}54}
5455
55func (s *CmdSuite) TearDownTest(c *gc.C) {56func (s *CmdSuite) TearDownTest(c *gc.C) {
57 s.home.Restore()
56 s.JujuConnSuite.TearDownTest(c)58 s.JujuConnSuite.TearDownTest(c)
57}59}
5860
5961
=== modified file 'cmd/juju/debuglog_test.go'
--- cmd/juju/debuglog_test.go 2014-05-15 05:14:01 +0000
+++ cmd/juju/debuglog_test.go 2014-05-22 14:33:28 +0000
@@ -21,7 +21,7 @@
21)21)
2222
23type DebugLogSuite struct {23type DebugLogSuite struct {
24 testing.FakeJujuHomeSuite24 testing.FakeHomeSuite
25}25}
2626
27var _ = gc.Suite(&DebugLogSuite{})27var _ = gc.Suite(&DebugLogSuite{})
2828
=== modified file 'cmd/juju/deploy.go'
--- cmd/juju/deploy.go 2014-05-15 10:12:36 +0000
+++ cmd/juju/deploy.go 2014-05-22 14:33:28 +0000
@@ -66,32 +66,6 @@
66by set-constraints).66by set-constraints).
6767
68Charms can be deployed to a specific machine using the --to argument.68Charms can be deployed to a specific machine using the --to argument.
69If the destination is an LXC container the default is to use lxc-clone
70to create the container where possible. For Ubuntu deployments, lxc-clone
71is supported for the trusty OS series and later. A 'template' container is
72created with the name
73 juju-<series>-template
74where <series> is the OS series, for example 'juju-trusty-template'.
75
76You can override the use of clone by changing the provider configuration:
77 lxc-clone: false
78
79If you have the main container directory mounted on a btrfs partition,
80then the clone will be using btrfs snapshots to create the containers.
81This means that clones use up much less disk space. If you do not have btrfs,
82lxc will attempt to use aufs (an overlay type filesystem). You can
83explicitly ask Juju to create full containers and not overlays by specifying
84the following in the provider configuration:
85 lxc-clone-aufs: false
86
87Examples:
88 juju deploy mysql --to 23 (deploy to machine 23)
89 juju deploy mysql --to 24/lxc/3 (deploy to lxc container 3 on host machine 24)
90 juju deploy mysql --to lxc:25 (deploy to a new lxc container on host machine 25)
91
92 juju deploy mysql -n 5 --constraints mem=8G (deploy 5 instances of mysql with at least 8 GB of RAM each)
93
94 juju deploy mysql --networks=storage,mynet --exclude-networks=logging
9569
96Like constraints, service-specific network requirements can be70Like constraints, service-specific network requirements can be
97specified with --networks and --exclude-networks arguments, both can71specified with --networks and --exclude-networks arguments, both can
@@ -101,6 +75,15 @@
101and to ensure none of the networks in --exclude-networks are added to75and to ensure none of the networks in --exclude-networks are added to
102the service's machines. Not supported on all providers.76the service's machines. Not supported on all providers.
10377
78Examples:
79 juju deploy mysql --to 23 (Deploy to machine 23)
80 juju deploy mysql --to 24/lxc/3 (Deploy to lxc container 3 on host machine 24)
81 juju deploy mysql --to lxc:25 (Deploy to a new lxc container on host machine 25)
82
83 juju deploy mysql -n 5 --constraints mem=8G (deploy 5 instances of mysql with at least 8 GB of RAM each)
84
85 juju deploy mysql --networks=storage,mynet --exclude-networks=logging
86
104See Also:87See Also:
105 juju help constraints88 juju help constraints
106 juju help set-constraints89 juju help set-constraints
10790
=== modified file 'cmd/juju/help_topics.go'
--- cmd/juju/help_topics.go 2014-05-15 10:12:36 +0000
+++ cmd/juju/help_topics.go 2014-05-22 14:33:28 +0000
@@ -79,23 +79,22 @@
79 juju deploy wordpress79 juju deploy wordpress
80 juju add-relation wordpress mysql80 juju add-relation wordpress mysql
8181
82For Ubuntu deployments, the local provider will prefer to use lxc-clone to create82As of trusty, the local provider will prefer to use lxc-clone to create
83the machines for the trusty OS series and later.83the machines. A 'template' container is created with the name
84A 'template' container is created with the name
85 juju-<series>-template84 juju-<series>-template
86where <series> is the OS series, for example 'juju-trusty-template'.85where <series> is the OS series, for example 'juju-precise-template'.
87You can override the use of clone by specifying86You can override the use of clone by specifying
88 lxc-clone: true87 use-clone: true
89or88or
90 lxc-clone: false89 use-clone: false
91in the configuration for your local provider. If you have the main container90in the configuration for your local provider. If you have the main container
92directory mounted on a btrfs partition, then the clone will be using btrfs91directory mounted on a btrfs partition, then the clone will be using btrfs
93snapshots to create the containers. This means that clones use up much92snapshots to create the containers. This means that the clones use up much
94less disk space. If you do not have btrfs, lxc will attempt to use aufs93less disk space. If you do not have btrfs, lxc will attempt to use aufs
95(an overlay type filesystem). You can explicitly ask Juju to create94(which is an overlay type filesystem). You can explicitly ask Juju to create
96full containers and not overlays by specifying the following in the provider95full containers and not overlays by specifying the following in the provider
97configuration:96configuration:
98 lxc-clone-aufs: false97 use-clone-aufs: false
9998
10099
101References:100References:
102101
=== modified file 'cmd/juju/helptool_test.go'
--- cmd/juju/helptool_test.go 2014-05-16 04:20:04 +0000
+++ cmd/juju/helptool_test.go 2014-05-22 14:33:28 +0000
@@ -13,11 +13,19 @@
13)13)
1414
15type HelpToolSuite struct {15type HelpToolSuite struct {
16 testing.FakeJujuHomeSuite16 home *testing.FakeHome
17}17}
1818
19var _ = gc.Suite(&HelpToolSuite{})19var _ = gc.Suite(&HelpToolSuite{})
2020
21func (suite *HelpToolSuite) SetUpTest(c *gc.C) {
22 suite.home = testing.MakeSampleHome(c)
23}
24
25func (suite *HelpToolSuite) TearDownTest(c *gc.C) {
26 suite.home.Restore()
27}
28
21func (suite *HelpToolSuite) TestHelpToolHelp(c *gc.C) {29func (suite *HelpToolSuite) TestHelpToolHelp(c *gc.C) {
22 output := badrun(c, 0, "help", "help-tool")30 output := badrun(c, 0, "help", "help-tool")
23 c.Assert(output, gc.Equals, `usage: juju help-tool [tool]31 c.Assert(output, gc.Equals, `usage: juju help-tool [tool]
2432
=== modified file 'cmd/juju/init_test.go'
--- cmd/juju/init_test.go 2014-05-16 04:20:04 +0000
+++ cmd/juju/init_test.go 2014-05-22 14:33:28 +0000
@@ -6,7 +6,6 @@
6import (6import (
7 "bytes"7 "bytes"
8 "io/ioutil"8 "io/ioutil"
9 "os"
10 "strings"9 "strings"
1110
12 gc "launchpad.net/gocheck"11 gc "launchpad.net/gocheck"
@@ -16,7 +15,6 @@
16)15)
1716
18type InitSuite struct {17type InitSuite struct {
19 testing.FakeJujuHomeSuite
20}18}
2119
22var _ = gc.Suite(&InitSuite{})20var _ = gc.Suite(&InitSuite{})
@@ -24,9 +22,7 @@
24// The environments.yaml is created by default if it22// The environments.yaml is created by default if it
25// does not already exist.23// does not already exist.
26func (*InitSuite) TestBoilerPlateEnvironment(c *gc.C) {24func (*InitSuite) TestBoilerPlateEnvironment(c *gc.C) {
27 envPath := testing.HomePath(".juju", "environments.yaml")25 defer testing.MakeEmptyFakeHome(c).Restore()
28 err := os.Remove(envPath)
29 c.Assert(err, gc.IsNil)
30 ctx := testing.Context(c)26 ctx := testing.Context(c)
31 code := cmd.Main(&InitCommand{}, ctx, nil)27 code := cmd.Main(&InitCommand{}, ctx, nil)
32 c.Check(code, gc.Equals, 0)28 c.Check(code, gc.Equals, 0)
@@ -43,9 +39,7 @@
43// The boilerplate is sent to stdout with --show, and the environments.yaml39// The boilerplate is sent to stdout with --show, and the environments.yaml
44// is not created.40// is not created.
45func (*InitSuite) TestBoilerPlatePrinted(c *gc.C) {41func (*InitSuite) TestBoilerPlatePrinted(c *gc.C) {
46 envPath := testing.HomePath(".juju", "environments.yaml")42 defer testing.MakeEmptyFakeHome(c).Restore()
47 err := os.Remove(envPath)
48 c.Assert(err, gc.IsNil)
49 ctx := testing.Context(c)43 ctx := testing.Context(c)
50 code := cmd.Main(&InitCommand{}, ctx, []string{"--show"})44 code := cmd.Main(&InitCommand{}, ctx, []string{"--show"})
51 c.Check(code, gc.Equals, 0)45 c.Check(code, gc.Equals, 0)
@@ -53,7 +47,7 @@
53 strippedOut := strings.Replace(outStr, "\n", "", -1)47 strippedOut := strings.Replace(outStr, "\n", "", -1)
54 c.Check(strippedOut, gc.Matches, ".*# This is the Juju config file, which you can use.*")48 c.Check(strippedOut, gc.Matches, ".*# This is the Juju config file, which you can use.*")
55 environpath := testing.HomePath(".juju", "environments.yaml")49 environpath := testing.HomePath(".juju", "environments.yaml")
56 _, err = ioutil.ReadFile(environpath)50 _, err := ioutil.ReadFile(environpath)
57 c.Assert(err, gc.NotNil)51 c.Assert(err, gc.NotNil)
58}52}
5953
@@ -68,7 +62,7 @@
68// An existing environments.yaml will not be overwritten without62// An existing environments.yaml will not be overwritten without
69// the explicit -f option.63// the explicit -f option.
70func (*InitSuite) TestExistingEnvironmentNotOverwritten(c *gc.C) {64func (*InitSuite) TestExistingEnvironmentNotOverwritten(c *gc.C) {
71 testing.WriteEnvironments(c, existingEnv)65 defer testing.MakeFakeHome(c, existingEnv, "existing").Restore()
7266
73 ctx := testing.Context(c)67 ctx := testing.Context(c)
74 code := cmd.Main(&InitCommand{}, ctx, nil)68 code := cmd.Main(&InitCommand{}, ctx, nil)
@@ -85,7 +79,7 @@
85// An existing environments.yaml will be overwritten when -f is79// An existing environments.yaml will be overwritten when -f is
86// given explicitly.80// given explicitly.
87func (*InitSuite) TestExistingEnvironmentOverwritten(c *gc.C) {81func (*InitSuite) TestExistingEnvironmentOverwritten(c *gc.C) {
88 testing.WriteEnvironments(c, existingEnv)82 defer testing.MakeFakeHome(c, existingEnv, "existing").Restore()
8983
90 ctx := testing.Context(c)84 ctx := testing.Context(c)
91 code := cmd.Main(&InitCommand{}, ctx, []string{"-f"})85 code := cmd.Main(&InitCommand{}, ctx, []string{"-f"})
9286
=== modified file 'cmd/juju/main.go'
--- cmd/juju/main.go 2014-05-20 01:23:55 +0000
+++ cmd/juju/main.go 2014-05-22 14:33:28 +0000
@@ -141,9 +141,6 @@
141 // Manage authorized ssh keys.141 // Manage authorized ssh keys.
142 r.Register(NewAuthorizedKeysCommand())142 r.Register(NewAuthorizedKeysCommand())
143143
144 // Manage users and access
145 r.Register(NewUserCommand())
146
147 // Manage state server availability.144 // Manage state server availability.
148 r.Register(wrapEnvCommand(&EnsureAvailabilityCommand{}))145 r.Register(wrapEnvCommand(&EnsureAvailabilityCommand{}))
149146
150147
=== modified file 'cmd/juju/main_test.go'
--- cmd/juju/main_test.go 2014-05-20 01:23:55 +0000
+++ cmd/juju/main_test.go 2014-05-22 14:33:28 +0000
@@ -31,7 +31,7 @@
31}31}
3232
33type MainSuite struct {33type MainSuite struct {
34 testing.FakeJujuHomeSuite34 testing.FakeHomeSuite
35}35}
3636
37var _ = gc.Suite(&MainSuite{})37var _ = gc.Suite(&MainSuite{})
@@ -79,6 +79,7 @@
79}79}
8080
81func (s *MainSuite) TestRunMain(c *gc.C) {81func (s *MainSuite) TestRunMain(c *gc.C) {
82 defer testing.MakeSampleHome(c).Restore()
82 // The test array structure needs to be inline here as some of the83 // The test array structure needs to be inline here as some of the
83 // expected values below use deployHelpText(). This constructs the deploy84 // expected values below use deployHelpText(). This constructs the deploy
84 // command and runs gets the help for it. When the deploy command is85 // command and runs gets the help for it. When the deploy command is
@@ -183,6 +184,7 @@
183184
184func (s *MainSuite) TestActualRunJujuArgsBeforeCommand(c *gc.C) {185func (s *MainSuite) TestActualRunJujuArgsBeforeCommand(c *gc.C) {
185 c.Skip("breaks test isolation: lp:1233601")186 c.Skip("breaks test isolation: lp:1233601")
187 defer testing.MakeFakeHomeNoEnvironments(c, "one").Restore()
186 // Check global args work when specified before command188 // Check global args work when specified before command
187 msg := breakJuju(c, "Bootstrap")189 msg := breakJuju(c, "Bootstrap")
188 logpath := filepath.Join(c.MkDir(), "log")190 logpath := filepath.Join(c.MkDir(), "log")
@@ -196,6 +198,7 @@
196198
197func (s *MainSuite) TestActualRunJujuArgsAfterCommand(c *gc.C) {199func (s *MainSuite) TestActualRunJujuArgsAfterCommand(c *gc.C) {
198 c.Skip("breaks test isolation: lp:1233601")200 c.Skip("breaks test isolation: lp:1233601")
201 defer testing.MakeFakeHomeNoEnvironments(c, "one").Restore()
199 // Check global args work when specified after command202 // Check global args work when specified after command
200 msg := breakJuju(c, "Bootstrap")203 msg := breakJuju(c, "Bootstrap")
201 logpath := filepath.Join(c.MkDir(), "log")204 logpath := filepath.Join(c.MkDir(), "log")
@@ -259,7 +262,6 @@
259 "unset-environment",262 "unset-environment",
260 "upgrade-charm",263 "upgrade-charm",
261 "upgrade-juju",264 "upgrade-juju",
262 "user",
263 "version",265 "version",
264}266}
265267
266268
=== modified file 'cmd/juju/plugin_test.go'
--- cmd/juju/plugin_test.go 2014-05-15 05:14:01 +0000
+++ cmd/juju/plugin_test.go 2014-05-22 14:33:28 +0000
@@ -15,24 +15,28 @@
15 gc "launchpad.net/gocheck"15 gc "launchpad.net/gocheck"
1616
17 "launchpad.net/juju-core/testing"17 "launchpad.net/juju-core/testing"
18 "launchpad.net/juju-core/testing/testbase"
18)19)
1920
20type PluginSuite struct {21type PluginSuite struct {
21 testing.FakeJujuHomeSuite22 testbase.LoggingSuite
22 oldPath string23 oldPath string
24 home *testing.FakeHome
23}25}
2426
25var _ = gc.Suite(&PluginSuite{})27var _ = gc.Suite(&PluginSuite{})
2628
27func (suite *PluginSuite) SetUpTest(c *gc.C) {29func (suite *PluginSuite) SetUpTest(c *gc.C) {
28 suite.FakeJujuHomeSuite.SetUpTest(c)30 suite.LoggingSuite.SetUpTest(c)
29 suite.oldPath = os.Getenv("PATH")31 suite.oldPath = os.Getenv("PATH")
32 suite.home = testing.MakeSampleHome(c)
30 os.Setenv("PATH", "/bin:"+testing.HomePath())33 os.Setenv("PATH", "/bin:"+testing.HomePath())
31}34}
3235
33func (suite *PluginSuite) TearDownTest(c *gc.C) {36func (suite *PluginSuite) TearDownTest(c *gc.C) {
37 suite.home.Restore()
34 os.Setenv("PATH", suite.oldPath)38 os.Setenv("PATH", suite.oldPath)
35 suite.FakeJujuHomeSuite.TearDownTest(c)39 suite.LoggingSuite.TearDownTest(c)
36}40}
3741
38func (*PluginSuite) TestFindPlugins(c *gc.C) {42func (*PluginSuite) TestFindPlugins(c *gc.C) {
3943
=== modified file 'cmd/juju/publish_test.go'
--- cmd/juju/publish_test.go 2014-05-15 05:14:01 +0000
+++ cmd/juju/publish_test.go 2014-05-22 14:33:28 +0000
@@ -14,14 +14,16 @@
14 "launchpad.net/juju-core/cmd"14 "launchpad.net/juju-core/cmd"
15 "launchpad.net/juju-core/cmd/envcmd"15 "launchpad.net/juju-core/cmd/envcmd"
16 "launchpad.net/juju-core/testing"16 "launchpad.net/juju-core/testing"
17 "launchpad.net/juju-core/testing/testbase"
17)18)
1819
19// Sadly, this is a very slow test suite, heavily dominated by calls to bzr.20// Sadly, this is a very slow test suite, heavily dominated by calls to bzr.
2021
21type PublishSuite struct {22type PublishSuite struct {
22 testing.FakeJujuHomeSuite23 testbase.LoggingSuite
23 testing.HTTPSuite24 testing.HTTPSuite
2425
26 home *testing.FakeHome
25 dir string27 dir string
26 oldBaseURL string28 oldBaseURL string
27 branch *bzr.Branch29 branch *bzr.Branch
@@ -57,7 +59,7 @@
57const pollDelay = testing.ShortWait59const pollDelay = testing.ShortWait
5860
59func (s *PublishSuite) SetUpSuite(c *gc.C) {61func (s *PublishSuite) SetUpSuite(c *gc.C) {
60 s.FakeJujuHomeSuite.SetUpSuite(c)62 s.LoggingSuite.SetUpSuite(c)
61 s.HTTPSuite.SetUpSuite(c)63 s.HTTPSuite.SetUpSuite(c)
6264
63 s.oldBaseURL = charm.Store.BaseURL65 s.oldBaseURL = charm.Store.BaseURL
@@ -65,16 +67,16 @@
65}67}
6668
67func (s *PublishSuite) TearDownSuite(c *gc.C) {69func (s *PublishSuite) TearDownSuite(c *gc.C) {
68 s.FakeJujuHomeSuite.TearDownSuite(c)70 s.LoggingSuite.TearDownSuite(c)
69 s.HTTPSuite.TearDownSuite(c)71 s.HTTPSuite.TearDownSuite(c)
7072
71 charm.Store.BaseURL = s.oldBaseURL73 charm.Store.BaseURL = s.oldBaseURL
72}74}
7375
74func (s *PublishSuite) SetUpTest(c *gc.C) {76func (s *PublishSuite) SetUpTest(c *gc.C) {
75 s.FakeJujuHomeSuite.SetUpTest(c)77 s.LoggingSuite.SetUpTest(c)
76 s.HTTPSuite.SetUpTest(c)78 s.HTTPSuite.SetUpTest(c)
77 s.FakeJujuHomeSuite.Home.AddFiles(c, testing.TestFile{79 s.home = testing.MakeSampleHome(c, testing.TestFile{
78 Name: ".bazaar/bazaar.conf",80 Name: ".bazaar/bazaar.conf",
79 Data: "[DEFAULT]\nemail = Test <testing@testing.invalid>\n",81 Data: "[DEFAULT]\nemail = Test <testing@testing.invalid>\n",
80 })82 })
@@ -86,8 +88,9 @@
86}88}
8789
88func (s *PublishSuite) TearDownTest(c *gc.C) {90func (s *PublishSuite) TearDownTest(c *gc.C) {
91 s.home.Restore()
89 s.HTTPSuite.TearDownTest(c)92 s.HTTPSuite.TearDownTest(c)
90 s.FakeJujuHomeSuite.TearDownTest(c)93 s.LoggingSuite.TearDownTest(c)
91}94}
9295
93func (s *PublishSuite) TestNoBranch(c *gc.C) {96func (s *PublishSuite) TestNoBranch(c *gc.C) {
9497
=== modified file 'cmd/juju/run_test.go'
--- cmd/juju/run_test.go 2014-05-15 05:14:01 +0000
+++ cmd/juju/run_test.go 2014-05-22 14:33:28 +0000
@@ -18,7 +18,7 @@
18)18)
1919
20type RunSuite struct {20type RunSuite struct {
21 testing.FakeJujuHomeSuite21 testing.FakeHomeSuite
22}22}
2323
24var _ = gc.Suite(&RunSuite{})24var _ = gc.Suite(&RunSuite{})
2525
=== modified file 'cmd/juju/switch_test.go'
--- cmd/juju/switch_test.go 2014-05-16 04:20:04 +0000
+++ cmd/juju/switch_test.go 2014-05-22 14:33:28 +0000
@@ -14,51 +14,50 @@
14)14)
1515
16type SwitchSimpleSuite struct {16type SwitchSimpleSuite struct {
17 testing.FakeJujuHomeSuite
18}17}
1918
20var _ = gc.Suite(&SwitchSimpleSuite{})19var _ = gc.Suite(&SwitchSimpleSuite{})
2120
22func (*SwitchSimpleSuite) TestNoEnvironment(c *gc.C) {21func (*SwitchSimpleSuite) TestNoEnvironment(c *gc.C) {
23 envPath := testing.HomePath(".juju", "environments.yaml")22 defer testing.MakeEmptyFakeHome(c).Restore()
24 err := os.Remove(envPath)23 _, err := testing.RunCommand(c, &SwitchCommand{}, nil)
25 c.Assert(err, gc.IsNil)
26 _, err = testing.RunCommand(c, &SwitchCommand{}, nil)
27 c.Assert(err, gc.ErrorMatches, "couldn't read the environment")24 c.Assert(err, gc.ErrorMatches, "couldn't read the environment")
28}25}
2926
30func (*SwitchSimpleSuite) TestNoDefault(c *gc.C) {27func (*SwitchSimpleSuite) TestNoDefault(c *gc.C) {
31 testing.WriteEnvironments(c, testing.MultipleEnvConfigNoDefault)28 defer testing.MakeFakeHome(c, testing.MultipleEnvConfigNoDefault).Restore()
32 _, err := testing.RunCommand(c, &SwitchCommand{}, nil)29 _, err := testing.RunCommand(c, &SwitchCommand{}, nil)
33 c.Assert(err, gc.ErrorMatches, "no currently specified environment")30 c.Assert(err, gc.ErrorMatches, "no currently specified environment")
34}31}
3532
36func (*SwitchSimpleSuite) TestShowsDefault(c *gc.C) {33func (*SwitchSimpleSuite) TestShowsDefault(c *gc.C) {
37 testing.WriteEnvironments(c, testing.MultipleEnvConfig)34 defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
38 context, err := testing.RunCommand(c, &SwitchCommand{}, nil)35 context, err := testing.RunCommand(c, &SwitchCommand{}, nil)
39 c.Assert(err, gc.IsNil)36 c.Assert(err, gc.IsNil)
40 c.Assert(testing.Stdout(context), gc.Equals, "erewhemos\n")37 c.Assert(testing.Stdout(context), gc.Equals, "erewhemos\n")
41}38}
4239
43func (s *SwitchSimpleSuite) TestCurrentEnvironmentHasPrecidence(c *gc.C) {40func (*SwitchSimpleSuite) TestCurrentEnvironmentHasPrecidence(c *gc.C) {
44 testing.WriteEnvironments(c, testing.MultipleEnvConfig)41 home := testing.MakeFakeHome(c, testing.MultipleEnvConfig)
45 s.FakeHomeSuite.Home.AddFiles(c, testing.TestFile{".juju/current-environment", "fubar"})42 defer home.Restore()
43 home.AddFiles(c, []testing.TestFile{{".juju/current-environment", "fubar"}})
46 context, err := testing.RunCommand(c, &SwitchCommand{}, nil)44 context, err := testing.RunCommand(c, &SwitchCommand{}, nil)
47 c.Assert(err, gc.IsNil)45 c.Assert(err, gc.IsNil)
48 c.Assert(testing.Stdout(context), gc.Equals, "fubar\n")46 c.Assert(testing.Stdout(context), gc.Equals, "fubar\n")
49}47}
5048
51func (*SwitchSimpleSuite) TestShowsJujuEnv(c *gc.C) {49func (*SwitchSimpleSuite) TestShowsJujuEnv(c *gc.C) {
52 testing.WriteEnvironments(c, testing.MultipleEnvConfig)50 defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
53 os.Setenv("JUJU_ENV", "using-env")51 os.Setenv("JUJU_ENV", "using-env")
54 context, err := testing.RunCommand(c, &SwitchCommand{}, nil)52 context, err := testing.RunCommand(c, &SwitchCommand{}, nil)
55 c.Assert(err, gc.IsNil)53 c.Assert(err, gc.IsNil)
56 c.Assert(testing.Stdout(context), gc.Equals, "using-env\n")54 c.Assert(testing.Stdout(context), gc.Equals, "using-env\n")
57}55}
5856
59func (s *SwitchSimpleSuite) TestJujuEnvOverCurrentEnvironment(c *gc.C) {57func (*SwitchSimpleSuite) TestJujuEnvOverCurrentEnvironment(c *gc.C) {
60 testing.WriteEnvironments(c, testing.MultipleEnvConfig)58 home := testing.MakeFakeHome(c, testing.MultipleEnvConfig)
61 s.FakeHomeSuite.Home.AddFiles(c, testing.TestFile{".juju/current-environment", "fubar"})59 defer home.Restore()
60 home.AddFiles(c, []testing.TestFile{{".juju/current-environment", "fubar"}})
62 os.Setenv("JUJU_ENV", "using-env")61 os.Setenv("JUJU_ENV", "using-env")
63 context, err := testing.RunCommand(c, &SwitchCommand{}, nil)62 context, err := testing.RunCommand(c, &SwitchCommand{}, nil)
64 c.Assert(err, gc.IsNil)63 c.Assert(err, gc.IsNil)
@@ -66,7 +65,7 @@
66}65}
6766
68func (*SwitchSimpleSuite) TestSettingWritesFile(c *gc.C) {67func (*SwitchSimpleSuite) TestSettingWritesFile(c *gc.C) {
69 testing.WriteEnvironments(c, testing.MultipleEnvConfig)68 defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
70 context, err := testing.RunCommand(c, &SwitchCommand{}, []string{"erewhemos-2"})69 context, err := testing.RunCommand(c, &SwitchCommand{}, []string{"erewhemos-2"})
71 c.Assert(err, gc.IsNil)70 c.Assert(err, gc.IsNil)
72 c.Assert(testing.Stdout(context), gc.Equals, "erewhemos -> erewhemos-2\n")71 c.Assert(testing.Stdout(context), gc.Equals, "erewhemos -> erewhemos-2\n")
@@ -74,13 +73,13 @@
74}73}
7574
76func (*SwitchSimpleSuite) TestSettingToUnknown(c *gc.C) {75func (*SwitchSimpleSuite) TestSettingToUnknown(c *gc.C) {
77 testing.WriteEnvironments(c, testing.MultipleEnvConfig)76 defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
78 _, err := testing.RunCommand(c, &SwitchCommand{}, []string{"unknown"})77 _, err := testing.RunCommand(c, &SwitchCommand{}, []string{"unknown"})
79 c.Assert(err, gc.ErrorMatches, `"unknown" is not a name of an existing defined environment`)78 c.Assert(err, gc.ErrorMatches, `"unknown" is not a name of an existing defined environment`)
80}79}
8180
82func (*SwitchSimpleSuite) TestSettingWhenJujuEnvSet(c *gc.C) {81func (*SwitchSimpleSuite) TestSettingWhenJujuEnvSet(c *gc.C) {
83 testing.WriteEnvironments(c, testing.MultipleEnvConfig)82 defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
84 os.Setenv("JUJU_ENV", "using-env")83 os.Setenv("JUJU_ENV", "using-env")
85 _, err := testing.RunCommand(c, &SwitchCommand{}, []string{"erewhemos-2"})84 _, err := testing.RunCommand(c, &SwitchCommand{}, []string{"erewhemos-2"})
86 c.Assert(err, gc.ErrorMatches, `cannot switch when JUJU_ENV is overriding the environment \(set to "using-env"\)`)85 c.Assert(err, gc.ErrorMatches, `cannot switch when JUJU_ENV is overriding the environment \(set to "using-env"\)`)
@@ -91,14 +90,14 @@
91`90`
9291
93func (*SwitchSimpleSuite) TestListEnvironments(c *gc.C) {92func (*SwitchSimpleSuite) TestListEnvironments(c *gc.C) {
94 testing.WriteEnvironments(c, testing.MultipleEnvConfig)93 defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
95 context, err := testing.RunCommand(c, &SwitchCommand{}, []string{"--list"})94 context, err := testing.RunCommand(c, &SwitchCommand{}, []string{"--list"})
96 c.Assert(err, gc.IsNil)95 c.Assert(err, gc.IsNil)
97 c.Assert(testing.Stdout(context), gc.Equals, expectedEnvironments)96 c.Assert(testing.Stdout(context), gc.Equals, expectedEnvironments)
98}97}
9998
100func (*SwitchSimpleSuite) TestListEnvironmentsOSJujuEnvSet(c *gc.C) {99func (*SwitchSimpleSuite) TestListEnvironmentsOSJujuEnvSet(c *gc.C) {
101 testing.WriteEnvironments(c, testing.MultipleEnvConfig)100 defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
102 os.Setenv("JUJU_ENV", "using-env")101 os.Setenv("JUJU_ENV", "using-env")
103 context, err := testing.RunCommand(c, &SwitchCommand{}, []string{"--list"})102 context, err := testing.RunCommand(c, &SwitchCommand{}, []string{"--list"})
104 c.Assert(err, gc.IsNil)103 c.Assert(err, gc.IsNil)
@@ -106,13 +105,13 @@
106}105}
107106
108func (*SwitchSimpleSuite) TestListEnvironmentsAndChange(c *gc.C) {107func (*SwitchSimpleSuite) TestListEnvironmentsAndChange(c *gc.C) {
109 testing.WriteEnvironments(c, testing.MultipleEnvConfig)108 defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
110 _, err := testing.RunCommand(c, &SwitchCommand{}, []string{"--list", "erewhemos-2"})109 _, err := testing.RunCommand(c, &SwitchCommand{}, []string{"--list", "erewhemos-2"})
111 c.Assert(err, gc.ErrorMatches, "cannot switch and list at the same time")110 c.Assert(err, gc.ErrorMatches, "cannot switch and list at the same time")
112}111}
113112
114func (*SwitchSimpleSuite) TestTooManyParams(c *gc.C) {113func (*SwitchSimpleSuite) TestTooManyParams(c *gc.C) {
115 testing.WriteEnvironments(c, testing.MultipleEnvConfig)114 defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
116 _, err := testing.RunCommand(c, &SwitchCommand{}, []string{"foo", "bar"})115 _, err := testing.RunCommand(c, &SwitchCommand{}, []string{"foo", "bar"})
117 c.Assert(err, gc.ErrorMatches, `unrecognized args: ."bar".`)116 c.Assert(err, gc.ErrorMatches, `unrecognized args: ."bar".`)
118}117}
119118
=== modified file 'cmd/juju/synctools_test.go'
--- cmd/juju/synctools_test.go 2014-05-16 04:20:04 +0000
+++ cmd/juju/synctools_test.go 2014-05-22 14:33:28 +0000
@@ -18,10 +18,12 @@
18 "launchpad.net/juju-core/environs/sync"18 "launchpad.net/juju-core/environs/sync"
19 "launchpad.net/juju-core/provider/dummy"19 "launchpad.net/juju-core/provider/dummy"
20 coretesting "launchpad.net/juju-core/testing"20 coretesting "launchpad.net/juju-core/testing"
21 "launchpad.net/juju-core/testing/testbase"
21)22)
2223
23type syncToolsSuite struct {24type syncToolsSuite struct {
24 coretesting.FakeJujuHomeSuite25 testbase.LoggingSuite
26 home *coretesting.FakeHome
25 configStore configstore.Storage27 configStore configstore.Storage
26 localStorage string28 localStorage string
2729
@@ -31,10 +33,10 @@
31var _ = gc.Suite(&syncToolsSuite{})33var _ = gc.Suite(&syncToolsSuite{})
3234
33func (s *syncToolsSuite) SetUpTest(c *gc.C) {35func (s *syncToolsSuite) SetUpTest(c *gc.C) {
34 s.FakeJujuHomeSuite.SetUpTest(c)36 s.LoggingSuite.SetUpTest(c)
3537
36 // Create a target environments.yaml and make sure its environment is empty.38 // Create a target environments.yaml and make sure its environment is empty.
37 coretesting.WriteEnvironments(c, `39 s.home = coretesting.MakeFakeHome(c, `
38environments:40environments:
39 test-target:41 test-target:
40 type: dummy42 type: dummy
@@ -50,7 +52,8 @@
50func (s *syncToolsSuite) TearDownTest(c *gc.C) {52func (s *syncToolsSuite) TearDownTest(c *gc.C) {
51 syncTools = s.origSyncTools53 syncTools = s.origSyncTools
52 dummy.Reset()54 dummy.Reset()
53 s.FakeJujuHomeSuite.TearDownTest(c)55 s.home.Restore()
56 s.LoggingSuite.TearDownTest(c)
54}57}
5558
56func (s *syncToolsSuite) Reset(c *gc.C) {59func (s *syncToolsSuite) Reset(c *gc.C) {
5760
=== removed file 'cmd/juju/user.go'
--- cmd/juju/user.go 2014-05-20 04:27:21 +0000
+++ cmd/juju/user.go 1970-01-01 00:00:00 +0000
@@ -1,35 +0,0 @@
1// Copyright 2014 Canonical Ltd.
2// Licensed under the AGPLv3, see LICENCE file for details.
3
4package main
5
6import (
7 "launchpad.net/juju-core/cmd"
8 "launchpad.net/juju-core/cmd/envcmd"
9)
10
11type UserCommand struct {
12 *cmd.SuperCommand
13}
14
15const userCommandDoc = `
16"juju user" is used to manage the user accounts and access control in
17the Juju environment.
18`
19
20const userCommandPurpose = "manage user accounts and access control"
21
22func NewUserCommand() cmd.Command {
23 usercmd := &UserCommand{
24 SuperCommand: cmd.NewSuperCommand(cmd.SuperCommandParams{
25 Name: "user",
26 Doc: userCommandDoc,
27 UsagePrefix: "juju",
28 Purpose: userCommandPurpose,
29 }),
30 }
31 // Define each subcommand in a separate "user_FOO.go" source file
32 // (with tests in user_FOO_test.go) and wire in here.
33 usercmd.Register(envcmd.Wrap(&UserAddCommand{}))
34 return usercmd
35}
360
=== removed file 'cmd/juju/user_test.go'
--- cmd/juju/user_test.go 2014-05-20 02:41:00 +0000
+++ cmd/juju/user_test.go 1970-01-01 00:00:00 +0000
@@ -1,42 +0,0 @@
1// Copyright 2014 Canonical Ltd.
2// Licensed under the AGPLv3, see LICENCE file for details.
3
4package main
5
6import (
7 "strings"
8
9 gc "launchpad.net/gocheck"
10 coretesting "launchpad.net/juju-core/testing"
11)
12
13type UserCommandSuite struct {
14 coretesting.BaseSuite
15}
16
17var _ = gc.Suite(&UserCommandSuite{})
18
19var expectedUserCommmandNames = []string{
20 "add",
21 "help",
22}
23
24func (s *UserCommandSuite) TestHelp(c *gc.C) {
25 // Check the help output
26 ctx, err := coretesting.RunCommand(c, NewUserCommand(), []string{"--help"})
27 c.Assert(err, gc.IsNil)
28 c.Assert(coretesting.Stdout(ctx), gc.Matches,
29 "(?s)usage: user <command> .+"+
30 userCommandPurpose+".+"+
31 userCommandDoc+".+")
32
33 // Check that we have registered all the sub commands by
34 // inspecting the help output.
35 var namesFound []string
36 commandHelp := strings.SplitAfter(coretesting.Stdout(ctx), "commands:")[1]
37 commandHelp = strings.TrimSpace(commandHelp)
38 for _, line := range strings.Split(commandHelp, "\n") {
39 namesFound = append(namesFound, strings.TrimSpace(strings.Split(line, " - ")[0]))
40 }
41 c.Assert(namesFound, gc.DeepEquals, expectedUserCommmandNames)
42}
430
=== modified file 'cmd/jujud/agent_test.go'
--- cmd/jujud/agent_test.go 2014-05-20 04:27:02 +0000
+++ cmd/jujud/agent_test.go 2014-05-22 14:33:28 +0000
@@ -25,6 +25,7 @@
25 "launchpad.net/juju-core/state/api"25 "launchpad.net/juju-core/state/api"
26 "launchpad.net/juju-core/state/api/params"26 "launchpad.net/juju-core/state/api/params"
27 coretesting "launchpad.net/juju-core/testing"27 coretesting "launchpad.net/juju-core/testing"
28 "launchpad.net/juju-core/testing/testbase"
28 coretools "launchpad.net/juju-core/tools"29 coretools "launchpad.net/juju-core/tools"
29 "launchpad.net/juju-core/version"30 "launchpad.net/juju-core/version"
30 "launchpad.net/juju-core/worker"31 "launchpad.net/juju-core/worker"
@@ -34,7 +35,7 @@
34var _ = gc.Suite(&toolSuite{})35var _ = gc.Suite(&toolSuite{})
3536
36type toolSuite struct {37type toolSuite struct {
37 coretesting.BaseSuite38 testbase.LoggingSuite
38}39}
3940
40var errorImportanceTests = []error{41var errorImportanceTests = []error{
@@ -89,7 +90,7 @@
89}90}
9091
91type apiOpenSuite struct {92type apiOpenSuite struct {
92 coretesting.BaseSuite93 testbase.LoggingSuite
93}94}
9495
95type fakeAPIOpenConfig struct {96type fakeAPIOpenConfig struct {
9697
=== modified file 'cmd/jujud/bootstrap_test.go'
--- cmd/jujud/bootstrap_test.go 2014-05-20 04:27:02 +0000
+++ cmd/jujud/bootstrap_test.go 2014-05-22 14:33:28 +0000
@@ -27,6 +27,7 @@
27 "launchpad.net/juju-core/state"27 "launchpad.net/juju-core/state"
28 "launchpad.net/juju-core/state/api/params"28 "launchpad.net/juju-core/state/api/params"
29 "launchpad.net/juju-core/testing"29 "launchpad.net/juju-core/testing"
30 "launchpad.net/juju-core/testing/testbase"
30 "launchpad.net/juju-core/utils"31 "launchpad.net/juju-core/utils"
31 "launchpad.net/juju-core/version"32 "launchpad.net/juju-core/version"
32 "launchpad.net/juju-core/worker/peergrouper"33 "launchpad.net/juju-core/worker/peergrouper"
@@ -37,7 +38,7 @@
37// We don't want to use JujuConnSuite because it gives us38// We don't want to use JujuConnSuite because it gives us
38// an already-bootstrapped environment.39// an already-bootstrapped environment.
39type BootstrapSuite struct {40type BootstrapSuite struct {
40 testing.BaseSuite41 testbase.LoggingSuite
41 testing.MgoSuite42 testing.MgoSuite
42 envcfg string43 envcfg string
43 instanceId instance.Id44 instanceId instance.Id
@@ -76,19 +77,19 @@
76 s.PatchValue(&ensureMongoServer, s.fakeEnsureMongo.fakeEnsureMongo)77 s.PatchValue(&ensureMongoServer, s.fakeEnsureMongo.fakeEnsureMongo)
77 s.PatchValue(&maybeInitiateMongoServer, s.fakeEnsureMongo.fakeInitiateMongo)78 s.PatchValue(&maybeInitiateMongoServer, s.fakeEnsureMongo.fakeInitiateMongo)
7879
79 s.BaseSuite.SetUpSuite(c)80 s.LoggingSuite.SetUpSuite(c)
80 s.MgoSuite.SetUpSuite(c)81 s.MgoSuite.SetUpSuite(c)
81 s.makeTestEnv(c)82 s.makeTestEnv(c)
82}83}
8384
84func (s *BootstrapSuite) TearDownSuite(c *gc.C) {85func (s *BootstrapSuite) TearDownSuite(c *gc.C) {
85 s.MgoSuite.TearDownSuite(c)86 s.MgoSuite.TearDownSuite(c)
86 s.BaseSuite.TearDownSuite(c)87 s.LoggingSuite.TearDownSuite(c)
87 dummy.Reset()88 dummy.Reset()
88}89}
8990
90func (s *BootstrapSuite) SetUpTest(c *gc.C) {91func (s *BootstrapSuite) SetUpTest(c *gc.C) {
91 s.BaseSuite.SetUpTest(c)92 s.LoggingSuite.SetUpTest(c)
92 s.MgoSuite.SetUpTest(c)93 s.MgoSuite.SetUpTest(c)
93 s.dataDir = c.MkDir()94 s.dataDir = c.MkDir()
94 s.logDir = c.MkDir()95 s.logDir = c.MkDir()
@@ -97,7 +98,7 @@
9798
98func (s *BootstrapSuite) TearDownTest(c *gc.C) {99func (s *BootstrapSuite) TearDownTest(c *gc.C) {
99 s.MgoSuite.TearDownTest(c)100 s.MgoSuite.TearDownTest(c)
100 s.BaseSuite.TearDownTest(c)101 s.LoggingSuite.TearDownTest(c)
101}102}
102103
103var testPassword = "my-admin-secret"104var testPassword = "my-admin-secret"
104105
=== modified file 'cmd/jujud/machine.go'
--- cmd/jujud/machine.go 2014-05-19 12:59:11 +0000
+++ cmd/jujud/machine.go 2014-05-22 14:33:28 +0000
@@ -450,11 +450,9 @@
450 a.startWorkerAfterUpgrade(runner, "instancepoller", func() (worker.Worker, error) {450 a.startWorkerAfterUpgrade(runner, "instancepoller", func() (worker.Worker, error) {
451 return instancepoller.NewWorker(st), nil451 return instancepoller.NewWorker(st), nil
452 })452 })
453 if shouldEnableHA(agentConfig) {453 runner.StartWorker("peergrouper", func() (worker.Worker, error) {
454 a.startWorkerAfterUpgrade(runner, "peergrouper", func() (worker.Worker, error) {454 return peergrouperNew(st)
455 return peergrouperNew(st)455 })
456 })
457 }
458 runner.StartWorker("apiserver", func() (worker.Worker, error) {456 runner.StartWorker("apiserver", func() (worker.Worker, error) {
459 // If the configuration does not have the required information,457 // If the configuration does not have the required information,
460 // it is currently not a recoverable error, so we kill the whole458 // it is currently not a recoverable error, so we kill the whole
461459
=== modified file 'cmd/jujud/machine_test.go'
--- cmd/jujud/machine_test.go 2014-05-19 13:07:51 +0000
+++ cmd/jujud/machine_test.go 2014-05-22 14:33:28 +0000
@@ -13,6 +13,7 @@
13 "time"13 "time"
1414
15 "github.com/juju/errors"15 "github.com/juju/errors"
16 "github.com/juju/testing"
16 jc "github.com/juju/testing/checkers"17 jc "github.com/juju/testing/checkers"
17 gc "launchpad.net/gocheck"18 gc "launchpad.net/gocheck"
1819
@@ -64,7 +65,8 @@
64func (s *commonMachineSuite) SetUpSuite(c *gc.C) {65func (s *commonMachineSuite) SetUpSuite(c *gc.C) {
65 s.agentSuite.SetUpSuite(c)66 s.agentSuite.SetUpSuite(c)
66 s.TestSuite.SetUpSuite(c)67 s.TestSuite.SetUpSuite(c)
67 s.agentSuite.PatchValue(&charm.CacheDir, c.MkDir())68 restore := testing.PatchValue(&charm.CacheDir, c.MkDir())
69 s.AddSuiteCleanup(func(*gc.C) { restore() })
68}70}
6971
70func (s *commonMachineSuite) TearDownSuite(c *gc.C) {72func (s *commonMachineSuite) TearDownSuite(c *gc.C) {
@@ -77,26 +79,28 @@
77 s.TestSuite.SetUpTest(c)79 s.TestSuite.SetUpTest(c)
7880
79 os.Remove(jujuRun) // ignore error; may not exist81 os.Remove(jujuRun) // ignore error; may not exist
80 // Patch ssh user to avoid touching ~ubuntu/.ssh/authorized_keys.82 // Fake $HOME, and ssh user to avoid touching ~ubuntu/.ssh/authorized_keys.
81 s.agentSuite.PatchValue(&authenticationworker.SSHUser, "")83 fakeHome := coretesting.MakeEmptyFakeHomeWithoutJuju(c)
84 s.AddCleanup(func(*gc.C) { fakeHome.Restore() })
85 s.PatchValue(&authenticationworker.SSHUser, "")
8286
83 testpath := c.MkDir()87 testpath := c.MkDir()
84 s.agentSuite.PatchEnvPathPrepend(testpath)88 s.PatchEnvPathPrepend(testpath)
85 // mock out the start method so we can fake install services without sudo89 // mock out the start method so we can fake install services without sudo
86 fakeCmd(filepath.Join(testpath, "start"))90 fakeCmd(filepath.Join(testpath, "start"))
87 fakeCmd(filepath.Join(testpath, "stop"))91 fakeCmd(filepath.Join(testpath, "stop"))
8892
89 s.agentSuite.PatchValue(&upstart.InitDir, c.MkDir())93 s.PatchValue(&upstart.InitDir, c.MkDir())
9094
91 s.singularRecord = &singularRunnerRecord{}95 s.singularRecord = &singularRunnerRecord{}
92 s.agentSuite.PatchValue(&newSingularRunner, s.singularRecord.newSingularRunner)96 testing.PatchValue(&newSingularRunner, s.singularRecord.newSingularRunner)
93 s.agentSuite.PatchValue(&peergrouperNew, func(st *state.State) (worker.Worker, error) {97 testing.PatchValue(&peergrouperNew, func(st *state.State) (worker.Worker, error) {
94 return newDummyWorker(), nil98 return newDummyWorker(), nil
95 })99 })
96100
97 s.fakeEnsureMongo = fakeEnsure{}101 s.fakeEnsureMongo = fakeEnsure{}
98 s.agentSuite.PatchValue(&ensureMongoServer, s.fakeEnsureMongo.fakeEnsureMongo)102 s.PatchValue(&ensureMongoServer, s.fakeEnsureMongo.fakeEnsureMongo)
99 s.agentSuite.PatchValue(&maybeInitiateMongoServer, s.fakeEnsureMongo.fakeInitiateMongo)103 s.PatchValue(&maybeInitiateMongoServer, s.fakeEnsureMongo.fakeInitiateMongo)
100}104}
101105
102func fakeCmd(path string) {106func fakeCmd(path string) {
@@ -404,7 +408,7 @@
404}408}
405409
406func (s *MachineSuite) TestManageEnvironRunsInstancePoller(c *gc.C) {410func (s *MachineSuite) TestManageEnvironRunsInstancePoller(c *gc.C) {
407 s.agentSuite.PatchValue(&instancepoller.ShortPoll, 500*time.Millisecond)411 s.PatchValue(&instancepoller.ShortPoll, 500*time.Millisecond)
408 usefulVersion := version.Current412 usefulVersion := version.Current
409 usefulVersion.Series = "quantal" // to match the charm created below413 usefulVersion.Series = "quantal" // to match the charm created below
410 envtesting.AssertUploadFakeToolsVersions(c, s.Conn.Environ.Storage(), usefulVersion)414 envtesting.AssertUploadFakeToolsVersions(c, s.Conn.Environ.Storage(), usefulVersion)
@@ -445,7 +449,7 @@
445449
446func (s *MachineSuite) TestManageEnvironRunsPeergrouper(c *gc.C) {450func (s *MachineSuite) TestManageEnvironRunsPeergrouper(c *gc.C) {
447 started := make(chan struct{}, 1)451 started := make(chan struct{}, 1)
448 s.agentSuite.PatchValue(&peergrouperNew, func(st *state.State) (worker.Worker, error) {452 testing.PatchValue(&peergrouperNew, func(st *state.State) (worker.Worker, error) {
449 c.Check(st, gc.NotNil)453 c.Check(st, gc.NotNil)
450 select {454 select {
451 case started <- struct{}{}:455 case started <- struct{}{}:
@@ -466,33 +470,6 @@
466 }470 }
467}471}
468472
469func (s *MachineSuite) TestEnsureLocalEnvironDoesntRunPeergrouper(c *gc.C) {
470 started := make(chan struct{}, 1)
471 s.agentSuite.PatchValue(&peergrouperNew, func(st *state.State) (worker.Worker, error) {
472 c.Check(st, gc.NotNil)
473 select {
474 case started <- struct{}{}:
475 default:
476 }
477 return newDummyWorker(), nil
478 })
479 m, _, _ := s.primeAgent(c, version.Current, state.JobManageEnviron)
480 a := s.newAgent(c, m)
481 err := a.ChangeConfig(func(config agent.ConfigSetter) {
482 config.SetValue(agent.ProviderType, "local")
483 })
484 c.Assert(err, gc.IsNil)
485 defer func() { c.Check(a.Stop(), gc.IsNil) }()
486 go func() {
487 c.Check(a.Run(nil), gc.IsNil)
488 }()
489 select {
490 case <-started:
491 c.Fatalf("local environment should not start peergrouper")
492 case <-time.After(coretesting.ShortWait):
493 }
494}
495
496func (s *MachineSuite) TestManageEnvironCallsUseMultipleCPUs(c *gc.C) {473func (s *MachineSuite) TestManageEnvironCallsUseMultipleCPUs(c *gc.C) {
497 // If it has been enabled, the JobManageEnviron agent should call utils.UseMultipleCPUs474 // If it has been enabled, the JobManageEnviron agent should call utils.UseMultipleCPUs
498 usefulVersion := version.Current475 usefulVersion := version.Current
@@ -500,7 +477,7 @@
500 envtesting.AssertUploadFakeToolsVersions(c, s.Conn.Environ.Storage(), usefulVersion)477 envtesting.AssertUploadFakeToolsVersions(c, s.Conn.Environ.Storage(), usefulVersion)
501 m, _, _ := s.primeAgent(c, version.Current, state.JobManageEnviron)478 m, _, _ := s.primeAgent(c, version.Current, state.JobManageEnviron)
502 calledChan := make(chan struct{}, 1)479 calledChan := make(chan struct{}, 1)
503 s.agentSuite.PatchValue(&useMultipleCPUs, func() { calledChan <- struct{}{} })480 s.PatchValue(&useMultipleCPUs, func() { calledChan <- struct{}{} })
504 // Now, start the agent, and observe that a JobManageEnviron agent481 // Now, start the agent, and observe that a JobManageEnviron agent
505 // calls UseMultipleCPUs482 // calls UseMultipleCPUs
506 a := s.newAgent(c, m)483 a := s.newAgent(c, m)
@@ -653,7 +630,7 @@
653 // need to check for that here, like in assertJobWithState.630 // need to check for that here, like in assertJobWithState.
654631
655 agentAPIs := make(chan eitherState, 1)632 agentAPIs := make(chan eitherState, 1)
656 s.agentSuite.PatchValue(reportOpened, func(st eitherState) {633 s.PatchValue(reportOpened, func(st eitherState) {
657 select {634 select {
658 case agentAPIs <- st:635 case agentAPIs <- st:
659 default:636 default:
@@ -853,8 +830,8 @@
853830
854func (s *MachineSuite) TestMachineEnvironWorker(c *gc.C) {831func (s *MachineSuite) TestMachineEnvironWorker(c *gc.C) {
855 proxyDir := c.MkDir()832 proxyDir := c.MkDir()
856 s.agentSuite.PatchValue(&machineenvironmentworker.ProxyDirectory, proxyDir)833 s.PatchValue(&machineenvironmentworker.ProxyDirectory, proxyDir)
857 s.agentSuite.PatchValue(&utils.AptConfFile, filepath.Join(proxyDir, "juju-apt-proxy"))834 s.PatchValue(&utils.AptConfFile, filepath.Join(proxyDir, "juju-apt-proxy"))
858835
859 s.primeAgent(c, version.Current, state.JobHostUnits)836 s.primeAgent(c, version.Current, state.JobHostUnits)
860 // Make sure there are some proxy settings to write.837 // Make sure there are some proxy settings to write.
@@ -911,7 +888,7 @@
911888
912func (s *MachineSuite) testMachineAgentRsyslogConfigWorker(c *gc.C, job state.MachineJob, expectedMode rsyslog.RsyslogMode) {889func (s *MachineSuite) testMachineAgentRsyslogConfigWorker(c *gc.C, job state.MachineJob, expectedMode rsyslog.RsyslogMode) {
913 created := make(chan rsyslog.RsyslogMode, 1)890 created := make(chan rsyslog.RsyslogMode, 1)
914 s.agentSuite.PatchValue(&newRsyslogConfigWorker, func(_ *apirsyslog.State, _ agent.Config, mode rsyslog.RsyslogMode) (worker.Worker, error) {891 s.PatchValue(&newRsyslogConfigWorker, func(_ *apirsyslog.State, _ agent.Config, mode rsyslog.RsyslogMode) (worker.Worker, error) {
915 created <- mode892 created <- mode
916 return newDummyWorker(), nil893 return newDummyWorker(), nil
917 })894 })
@@ -959,14 +936,14 @@
959 err = s.State.MongoSession().DB("admin").RemoveUser(m.Tag())936 err = s.State.MongoSession().DB("admin").RemoveUser(m.Tag())
960 c.Assert(err, gc.IsNil)937 c.Assert(err, gc.IsNil)
961938
962 s.agentSuite.PatchValue(&ensureMongoAdminUser, func(p mongo.EnsureAdminUserParams) (bool, error) {939 s.PatchValue(&ensureMongoAdminUser, func(p mongo.EnsureAdminUserParams) (bool, error) {
963 err := s.State.MongoSession().DB("admin").AddUser(p.User, p.Password, false)940 err := s.State.MongoSession().DB("admin").AddUser(p.User, p.Password, false)
964 c.Assert(err, gc.IsNil)941 c.Assert(err, gc.IsNil)
965 return true, nil942 return true, nil
966 })943 })
967944
968 stateOpened := make(chan eitherState, 1)945 stateOpened := make(chan eitherState, 1)
969 s.agentSuite.PatchValue(&reportOpenedState, func(st eitherState) {946 s.PatchValue(&reportOpenedState, func(st eitherState) {
970 select {947 select {
971 case stateOpened <- st:948 case stateOpened <- st:
972 default:949 default:
973950
=== modified file 'cmd/jujud/run_test.go'
--- cmd/jujud/run_test.go 2014-05-20 04:27:02 +0000
+++ cmd/jujud/run_test.go 2014-05-22 14:33:28 +0000
@@ -15,13 +15,14 @@
1515
16 "launchpad.net/juju-core/cmd"16 "launchpad.net/juju-core/cmd"
17 "launchpad.net/juju-core/testing"17 "launchpad.net/juju-core/testing"
18 "launchpad.net/juju-core/testing/testbase"
18 "launchpad.net/juju-core/utils/exec"19 "launchpad.net/juju-core/utils/exec"
19 "launchpad.net/juju-core/utils/fslock"20 "launchpad.net/juju-core/utils/fslock"
20 "launchpad.net/juju-core/worker/uniter"21 "launchpad.net/juju-core/worker/uniter"
21)22)
2223
23type RunTestSuite struct {24type RunTestSuite struct {
24 testing.BaseSuite25 testbase.LoggingSuite
25}26}
2627
27var _ = gc.Suite(&RunTestSuite{})28var _ = gc.Suite(&RunTestSuite{})
2829
=== modified file 'cmd/jujud/upgrade_test.go'
--- cmd/jujud/upgrade_test.go 2014-05-16 04:20:04 +0000
+++ cmd/jujud/upgrade_test.go 2014-05-22 14:33:28 +0000
@@ -36,7 +36,7 @@
3636
37 // Capture all apt commands.37 // Capture all apt commands.
38 s.aptCmds = nil38 s.aptCmds = nil
39 aptCmds := s.agentSuite.HookCommandOutput(&utils.AptCommandOutput, nil, nil)39 aptCmds := s.HookCommandOutput(&utils.AptCommandOutput, nil, nil)
40 go func() {40 go func() {
41 for cmd := range aptCmds {41 for cmd := range aptCmds {
42 s.aptCmds = append(s.aptCmds, cmd)42 s.aptCmds = append(s.aptCmds, cmd)
@@ -65,7 +65,7 @@
65}65}
6666
67func (s *UpgradeSuite) assertUpgradeSteps(c *gc.C, job state.MachineJob) {67func (s *UpgradeSuite) assertUpgradeSteps(c *gc.C, job state.MachineJob) {
68 s.agentSuite.PatchValue(&version.Current, s.upgradeToVersion)68 s.PatchValue(&version.Current, s.upgradeToVersion)
69 err := s.State.SetEnvironAgentVersion(s.upgradeToVersion.Number)69 err := s.State.SetEnvironAgentVersion(s.upgradeToVersion.Number)
70 c.Assert(err, gc.IsNil)70 c.Assert(err, gc.IsNil)
7171
7272
=== modified file 'cmd/plugins/juju-metadata/imagemetadata_test.go'
--- cmd/plugins/juju-metadata/imagemetadata_test.go 2014-05-16 01:33:13 +0000
+++ cmd/plugins/juju-metadata/imagemetadata_test.go 2014-05-22 14:33:28 +0000
@@ -19,23 +19,26 @@
19 "launchpad.net/juju-core/environs/config"19 "launchpad.net/juju-core/environs/config"
20 "launchpad.net/juju-core/provider/dummy"20 "launchpad.net/juju-core/provider/dummy"
21 "launchpad.net/juju-core/testing"21 "launchpad.net/juju-core/testing"
22 "launchpad.net/juju-core/testing/testbase"
22)23)
2324
24type ImageMetadataSuite struct {25type ImageMetadataSuite struct {
25 testing.FakeJujuHomeSuite26 testbase.LoggingSuite
26 environ []string27 environ []string
28 home *testing.FakeHome
27 dir string29 dir string
28}30}
2931
30var _ = gc.Suite(&ImageMetadataSuite{})32var _ = gc.Suite(&ImageMetadataSuite{})
3133
32func (s *ImageMetadataSuite) SetUpSuite(c *gc.C) {34func (s *ImageMetadataSuite) SetUpSuite(c *gc.C) {
33 s.FakeJujuHomeSuite.SetUpSuite(c)35 s.LoggingSuite.SetUpSuite(c)
34 s.environ = os.Environ()36 s.environ = os.Environ()
35}37}
3638
37func (s *ImageMetadataSuite) SetUpTest(c *gc.C) {39func (s *ImageMetadataSuite) SetUpTest(c *gc.C) {
38 s.FakeJujuHomeSuite.SetUpTest(c)40 s.LoggingSuite.SetUpTest(c)
41 os.Clearenv()
39 s.dir = c.MkDir()42 s.dir = c.MkDir()
40 // Create a fake certificate so azure test environment can be opened.43 // Create a fake certificate so azure test environment can be opened.
41 certfile, err := ioutil.TempFile(s.dir, "")44 certfile, err := ioutil.TempFile(s.dir, "")
@@ -44,11 +47,20 @@
44 err = ioutil.WriteFile(filename, []byte("test certificate"), 0644)47 err = ioutil.WriteFile(filename, []byte("test certificate"), 0644)
45 c.Assert(err, gc.IsNil)48 c.Assert(err, gc.IsNil)
46 envConfig := strings.Replace(metadataTestEnvConfig, "/home/me/azure.pem", filename, -1)49 envConfig := strings.Replace(metadataTestEnvConfig, "/home/me/azure.pem", filename, -1)
47 testing.WriteEnvironments(c, envConfig)50 s.home = testing.MakeFakeHome(c, envConfig)
48 s.PatchEnvironment("AWS_ACCESS_KEY_ID", "access")51 s.PatchEnvironment("AWS_ACCESS_KEY_ID", "access")
49 s.PatchEnvironment("AWS_SECRET_ACCESS_KEY", "secret")52 s.PatchEnvironment("AWS_SECRET_ACCESS_KEY", "secret")
50}53}
5154
55func (s *ImageMetadataSuite) TearDownTest(c *gc.C) {
56 for _, envstring := range s.environ {
57 kv := strings.SplitN(envstring, "=", 2)
58 os.Setenv(kv[0], kv[1])
59 }
60 s.home.Restore()
61 s.LoggingSuite.TearDownTest(c)
62}
63
52var seriesVersions map[string]string = map[string]string{64var seriesVersions map[string]string = map[string]string{
53 "precise": "12.04",65 "precise": "12.04",
54 "raring": "13.04",66 "raring": "13.04",
@@ -131,8 +143,6 @@
131}143}
132144
133func (s *ImageMetadataSuite) TestImageMetadataFilesLatestLts(c *gc.C) {145func (s *ImageMetadataSuite) TestImageMetadataFilesLatestLts(c *gc.C) {
134 envConfig := strings.Replace(metadataTestEnvConfig, "default-series: precise", "", -1)
135 testing.WriteEnvironments(c, envConfig)
136 ctx := testing.Context(c)146 ctx := testing.Context(c)
137 code := cmd.Main(147 code := cmd.Main(
138 envcmd.Wrap(&ImageMetadataCommand{}), ctx, []string{148 envcmd.Wrap(&ImageMetadataCommand{}), ctx, []string{
@@ -217,8 +227,9 @@
217}227}
218228
219func (s *ImageMetadataSuite) TestImageMetadataBadArgs(c *gc.C) {229func (s *ImageMetadataSuite) TestImageMetadataBadArgs(c *gc.C) {
220 testing.MakeSampleJujuHome(c)230 home := testing.MakeSampleHome(c)
221 s.AddCleanup(func(*gc.C) {231 s.AddCleanup(func(*gc.C) {
232 home.Restore()
222 dummy.Reset()233 dummy.Reset()
223 })234 })
224 for i, t := range errTests {235 for i, t := range errTests {
225236
=== modified file 'cmd/plugins/juju-metadata/metadataplugin_test.go'
--- cmd/plugins/juju-metadata/metadataplugin_test.go 2014-05-16 01:33:13 +0000
+++ cmd/plugins/juju-metadata/metadataplugin_test.go 2014-05-22 14:33:28 +0000
@@ -22,7 +22,7 @@
22}22}
2323
24type MetadataSuite struct {24type MetadataSuite struct {
25 testing.FakeJujuHomeSuite25 jujuHome *testing.FakeHome
26}26}
2727
28var _ = gc.Suite(&MetadataSuite{})28var _ = gc.Suite(&MetadataSuite{})
@@ -36,6 +36,14 @@
36 "validate-tools",36 "validate-tools",
37}37}
3838
39func (s *MetadataSuite) SetUpTest(c *gc.C) {
40 s.jujuHome = testing.MakeEmptyFakeHome(c)
41}
42
43func (s *MetadataSuite) TearDownTest(c *gc.C) {
44 s.jujuHome.Restore()
45}
46
39var (47var (
40 flagRunMain = flag.Bool("run-main", false, "Run the application's main function for recursive testing")48 flagRunMain = flag.Bool("run-main", false, "Run the application's main function for recursive testing")
41)49)
4250
=== modified file 'cmd/plugins/juju-metadata/toolsmetadata_test.go'
--- cmd/plugins/juju-metadata/toolsmetadata_test.go 2014-05-19 04:28:01 +0000
+++ cmd/plugins/juju-metadata/toolsmetadata_test.go 2014-05-22 14:33:28 +0000
@@ -23,11 +23,13 @@
23 "launchpad.net/juju-core/juju/osenv"23 "launchpad.net/juju-core/juju/osenv"
24 "launchpad.net/juju-core/provider/dummy"24 "launchpad.net/juju-core/provider/dummy"
25 coretesting "launchpad.net/juju-core/testing"25 coretesting "launchpad.net/juju-core/testing"
26 "launchpad.net/juju-core/testing/testbase"
26 "launchpad.net/juju-core/version"27 "launchpad.net/juju-core/version"
27)28)
2829
29type ToolsMetadataSuite struct {30type ToolsMetadataSuite struct {
30 coretesting.FakeJujuHomeSuite31 testbase.LoggingSuite
32 home *coretesting.FakeHome
31 env environs.Environ33 env environs.Environ
32 publicStorageDir string34 publicStorageDir string
33}35}
@@ -35,8 +37,10 @@
35var _ = gc.Suite(&ToolsMetadataSuite{})37var _ = gc.Suite(&ToolsMetadataSuite{})
3638
37func (s *ToolsMetadataSuite) SetUpTest(c *gc.C) {39func (s *ToolsMetadataSuite) SetUpTest(c *gc.C) {
38 s.FakeJujuHomeSuite.SetUpTest(c)40 s.LoggingSuite.SetUpTest(c)
41 s.home = coretesting.MakeSampleHome(c)
39 s.AddCleanup(func(*gc.C) {42 s.AddCleanup(func(*gc.C) {
43 s.home.Restore()
40 dummy.Reset()44 dummy.Reset()
41 loggo.ResetLoggers()45 loggo.ResetLoggers()
42 })46 })
4347
=== modified file 'cmd/plugins/juju-metadata/validateimagemetadata_test.go'
--- cmd/plugins/juju-metadata/validateimagemetadata_test.go 2014-05-16 01:33:13 +0000
+++ cmd/plugins/juju-metadata/validateimagemetadata_test.go 2014-05-22 14:33:28 +0000
@@ -16,10 +16,12 @@
16 "launchpad.net/juju-core/environs/imagemetadata"16 "launchpad.net/juju-core/environs/imagemetadata"
17 "launchpad.net/juju-core/environs/simplestreams"17 "launchpad.net/juju-core/environs/simplestreams"
18 coretesting "launchpad.net/juju-core/testing"18 coretesting "launchpad.net/juju-core/testing"
19 "launchpad.net/juju-core/testing/testbase"
19)20)
2021
21type ValidateImageMetadataSuite struct {22type ValidateImageMetadataSuite struct {
22 coretesting.FakeJujuHomeSuite23 testbase.LoggingSuite
24 home *coretesting.FakeHome
23 metadataDir string25 metadataDir string
24}26}
2527
@@ -104,13 +106,18 @@
104`106`
105107
106func (s *ValidateImageMetadataSuite) SetUpTest(c *gc.C) {108func (s *ValidateImageMetadataSuite) SetUpTest(c *gc.C) {
107 s.FakeJujuHomeSuite.SetUpTest(c)109 s.LoggingSuite.SetUpTest(c)
108 s.metadataDir = c.MkDir()110 s.metadataDir = c.MkDir()
109 coretesting.WriteEnvironments(c, metadataTestEnvConfig)111 s.home = coretesting.MakeFakeHome(c, metadataTestEnvConfig)
110 s.PatchEnvironment("AWS_ACCESS_KEY_ID", "access")112 s.PatchEnvironment("AWS_ACCESS_KEY_ID", "access")
111 s.PatchEnvironment("AWS_SECRET_ACCESS_KEY", "secret")113 s.PatchEnvironment("AWS_SECRET_ACCESS_KEY", "secret")
112}114}
113115
116func (s *ValidateImageMetadataSuite) TearDownTest(c *gc.C) {
117 s.home.Restore()
118 s.LoggingSuite.TearDownTest(c)
119}
120
114func (s *ValidateImageMetadataSuite) setupEc2LocalMetadata(c *gc.C, region, stream string) {121func (s *ValidateImageMetadataSuite) setupEc2LocalMetadata(c *gc.C, region, stream string) {
115 ec2Region, ok := aws.Regions[region]122 ec2Region, ok := aws.Regions[region]
116 if !ok {123 if !ok {
117124
=== modified file 'cmd/plugins/juju-metadata/validatetoolsmetadata_test.go'
--- cmd/plugins/juju-metadata/validatetoolsmetadata_test.go 2014-05-16 01:33:13 +0000
+++ cmd/plugins/juju-metadata/validatetoolsmetadata_test.go 2014-05-22 14:33:28 +0000
@@ -15,11 +15,13 @@
15 "launchpad.net/juju-core/environs/filestorage"15 "launchpad.net/juju-core/environs/filestorage"
16 "launchpad.net/juju-core/environs/tools"16 "launchpad.net/juju-core/environs/tools"
17 coretesting "launchpad.net/juju-core/testing"17 coretesting "launchpad.net/juju-core/testing"
18 "launchpad.net/juju-core/testing/testbase"
18 "launchpad.net/juju-core/version"19 "launchpad.net/juju-core/version"
19)20)
2021
21type ValidateToolsMetadataSuite struct {22type ValidateToolsMetadataSuite struct {
22 coretesting.FakeJujuHomeSuite23 testbase.LoggingSuite
24 home *coretesting.FakeHome
23 metadataDir string25 metadataDir string
24}26}
2527
@@ -86,13 +88,18 @@
86}88}
8789
88func (s *ValidateToolsMetadataSuite) SetUpTest(c *gc.C) {90func (s *ValidateToolsMetadataSuite) SetUpTest(c *gc.C) {
89 s.FakeJujuHomeSuite.SetUpTest(c)91 s.LoggingSuite.SetUpTest(c)
90 coretesting.WriteEnvironments(c, metadataTestEnvConfig)92 s.home = coretesting.MakeFakeHome(c, metadataTestEnvConfig)
91 s.metadataDir = c.MkDir()93 s.metadataDir = c.MkDir()
92 s.PatchEnvironment("AWS_ACCESS_KEY_ID", "access")94 s.PatchEnvironment("AWS_ACCESS_KEY_ID", "access")
93 s.PatchEnvironment("AWS_SECRET_ACCESS_KEY", "secret")95 s.PatchEnvironment("AWS_SECRET_ACCESS_KEY", "secret")
94}96}
9597
98func (s *ValidateToolsMetadataSuite) TearDownTest(c *gc.C) {
99 s.home.Restore()
100 s.LoggingSuite.TearDownTest(c)
101}
102
96func (s *ValidateToolsMetadataSuite) setupEc2LocalMetadata(c *gc.C, region string) {103func (s *ValidateToolsMetadataSuite) setupEc2LocalMetadata(c *gc.C, region string) {
97 ec2Region, ok := aws.Regions[region]104 ec2Region, ok := aws.Regions[region]
98 if !ok {105 if !ok {
99106
=== modified file 'cmd/plugins/local/main_test.go'
--- cmd/plugins/local/main_test.go 2014-05-20 04:27:02 +0000
+++ cmd/plugins/local/main_test.go 2014-05-22 14:33:28 +0000
@@ -15,10 +15,11 @@
15 "launchpad.net/juju-core/cmd"15 "launchpad.net/juju-core/cmd"
16 "launchpad.net/juju-core/cmd/plugins/local"16 "launchpad.net/juju-core/cmd/plugins/local"
17 coretesting "launchpad.net/juju-core/testing"17 coretesting "launchpad.net/juju-core/testing"
18 "launchpad.net/juju-core/testing/testbase"
18)19)
1920
20type mainSuite struct {21type mainSuite struct {
21 coretesting.BaseSuite22 testbase.LoggingSuite
22}23}
2324
24var _ = gc.Suite(&mainSuite{})25var _ = gc.Suite(&mainSuite{})
2526
=== modified file 'constraints/validation_test.go'
--- constraints/validation_test.go 2014-05-20 05:33:59 +0000
+++ constraints/validation_test.go 2014-05-22 14:33:28 +0000
@@ -126,7 +126,7 @@
126 unsupported, err := validator.Validate(cons)126 unsupported, err := validator.Validate(cons)
127 if t.err == "" {127 if t.err == "" {
128 c.Assert(err, gc.IsNil)128 c.Assert(err, gc.IsNil)
129 c.Assert(unsupported, jc.SameContents, t.unsupported)129 c.Assert(unsupported, jc.DeepEquals, t.unsupported)
130 } else {130 } else {
131 c.Assert(err, gc.ErrorMatches, t.err)131 c.Assert(err, gc.ErrorMatches, t.err)
132 }132 }
133133
=== modified file 'container/directory_test.go'
--- container/directory_test.go 2014-05-20 04:27:02 +0000
+++ container/directory_test.go 2014-05-22 14:33:28 +0000
@@ -11,11 +11,11 @@
11 gc "launchpad.net/gocheck"11 gc "launchpad.net/gocheck"
1212
13 "launchpad.net/juju-core/container"13 "launchpad.net/juju-core/container"
14 "launchpad.net/juju-core/testing"14 "launchpad.net/juju-core/testing/testbase"
15)15)
1616
17type DirectorySuite struct {17type DirectorySuite struct {
18 testing.BaseSuite18 testbase.LoggingSuite
19 containerDir string19 containerDir string
20 removedDir string20 removedDir string
21}21}
@@ -23,7 +23,7 @@
23var _ = gc.Suite(&DirectorySuite{})23var _ = gc.Suite(&DirectorySuite{})
2424
25func (s *DirectorySuite) SetUpTest(c *gc.C) {25func (s *DirectorySuite) SetUpTest(c *gc.C) {
26 s.BaseSuite.SetUpTest(c)26 s.LoggingSuite.SetUpTest(c)
27 s.containerDir = c.MkDir()27 s.containerDir = c.MkDir()
28 s.PatchValue(&container.ContainerDir, s.containerDir)28 s.PatchValue(&container.ContainerDir, s.containerDir)
29 s.removedDir = c.MkDir()29 s.removedDir = c.MkDir()
3030
=== modified file 'container/factory/factory_test.go'
--- container/factory/factory_test.go 2014-05-20 04:27:02 +0000
+++ container/factory/factory_test.go 2014-05-22 14:33:28 +0000
@@ -9,11 +9,11 @@
9 "launchpad.net/juju-core/container"9 "launchpad.net/juju-core/container"
10 "launchpad.net/juju-core/container/factory"10 "launchpad.net/juju-core/container/factory"
11 "launchpad.net/juju-core/instance"11 "launchpad.net/juju-core/instance"
12 "launchpad.net/juju-core/testing"12 "launchpad.net/juju-core/testing/testbase"
13)13)
1414
15type factorySuite struct {15type factorySuite struct {
16 testing.BaseSuite16 testbase.LoggingSuite
17}17}
1818
19var _ = gc.Suite(&factorySuite{})19var _ = gc.Suite(&factorySuite{})
2020
=== modified file 'container/kvm/kvm_test.go'
--- container/kvm/kvm_test.go 2014-05-20 04:27:02 +0000
+++ container/kvm/kvm_test.go 2014-05-22 14:33:28 +0000
@@ -16,7 +16,7 @@
16 kvmtesting "launchpad.net/juju-core/container/kvm/testing"16 kvmtesting "launchpad.net/juju-core/container/kvm/testing"
17 containertesting "launchpad.net/juju-core/container/testing"17 containertesting "launchpad.net/juju-core/container/testing"
18 "launchpad.net/juju-core/instance"18 "launchpad.net/juju-core/instance"
19 coretesting "launchpad.net/juju-core/testing"19 "launchpad.net/juju-core/testing/testbase"
20 "launchpad.net/juju-core/version"20 "launchpad.net/juju-core/version"
21)21)
2222
@@ -109,7 +109,7 @@
109}109}
110110
111type ConstraintsSuite struct {111type ConstraintsSuite struct {
112 coretesting.BaseSuite112 testbase.LoggingSuite
113}113}
114114
115var _ = gc.Suite(&ConstraintsSuite{})115var _ = gc.Suite(&ConstraintsSuite{})
116116
=== modified file 'container/kvm/live_test.go'
--- container/kvm/live_test.go 2014-05-20 04:27:02 +0000
+++ container/kvm/live_test.go 2014-05-22 14:33:28 +0000
@@ -19,12 +19,13 @@
19 "launchpad.net/juju-core/instance"19 "launchpad.net/juju-core/instance"
20 jujutesting "launchpad.net/juju-core/juju/testing"20 jujutesting "launchpad.net/juju-core/juju/testing"
21 coretesting "launchpad.net/juju-core/testing"21 coretesting "launchpad.net/juju-core/testing"
22 "launchpad.net/juju-core/testing/testbase"
22 "launchpad.net/juju-core/tools"23 "launchpad.net/juju-core/tools"
23 "launchpad.net/juju-core/version"24 "launchpad.net/juju-core/version"
24)25)
2526
26type LiveSuite struct {27type LiveSuite struct {
27 coretesting.BaseSuite28 testbase.LoggingSuite
28 ContainerDir string29 ContainerDir string
29 RemovedDir string30 RemovedDir string
30}31}
@@ -32,7 +33,7 @@
32var _ = gc.Suite(&LiveSuite{})33var _ = gc.Suite(&LiveSuite{})
3334
34func (s *LiveSuite) SetUpTest(c *gc.C) {35func (s *LiveSuite) SetUpTest(c *gc.C) {
35 s.BaseSuite.SetUpTest(c)36 s.LoggingSuite.SetUpTest(c)
36 // Skip if not linux37 // Skip if not linux
37 if runtime.GOOS != "linux" {38 if runtime.GOOS != "linux" {
38 c.Skip("not running linux")39 c.Skip("not running linux")
3940
=== modified file 'container/kvm/mock/mock-kvm_test.go'
--- container/kvm/mock/mock-kvm_test.go 2014-05-20 04:27:02 +0000
+++ container/kvm/mock/mock-kvm_test.go 2014-05-22 14:33:28 +0000
@@ -9,11 +9,11 @@
99
10 "launchpad.net/juju-core/container/kvm"10 "launchpad.net/juju-core/container/kvm"
11 "launchpad.net/juju-core/container/kvm/mock"11 "launchpad.net/juju-core/container/kvm/mock"
12 "launchpad.net/juju-core/testing"12 "launchpad.net/juju-core/testing/testbase"
13)13)
1414
15type MockSuite struct {15type MockSuite struct {
16 testing.BaseSuite16 testbase.LoggingSuite
17}17}
1818
19var _ = gc.Suite(&MockSuite{})19var _ = gc.Suite(&MockSuite{})
2020
=== modified file 'container/kvm/testing/test.go'
--- container/kvm/testing/test.go 2014-05-20 04:27:02 +0000
+++ container/kvm/testing/test.go 2014-05-22 14:33:28 +0000
@@ -13,20 +13,20 @@
13 "launchpad.net/juju-core/container"13 "launchpad.net/juju-core/container"
14 "launchpad.net/juju-core/container/kvm"14 "launchpad.net/juju-core/container/kvm"
15 "launchpad.net/juju-core/container/kvm/mock"15 "launchpad.net/juju-core/container/kvm/mock"
16 "launchpad.net/juju-core/testing"16 "launchpad.net/juju-core/testing/testbase"
17)17)
1818
19// TestSuite replaces the kvm factory that the manager uses with a mock19// TestSuite replaces the kvm factory that the manager uses with a mock
20// implementation.20// implementation.
21type TestSuite struct {21type TestSuite struct {
22 testing.BaseSuite22 testbase.LoggingSuite
23 Factory mock.ContainerFactory23 Factory mock.ContainerFactory
24 ContainerDir string24 ContainerDir string
25 RemovedDir string25 RemovedDir string
26}26}
2727
28func (s *TestSuite) SetUpTest(c *gc.C) {28func (s *TestSuite) SetUpTest(c *gc.C) {
29 s.BaseSuite.SetUpTest(c)29 s.LoggingSuite.SetUpTest(c)
30 s.ContainerDir = c.MkDir()30 s.ContainerDir = c.MkDir()
31 s.PatchValue(&container.ContainerDir, s.ContainerDir)31 s.PatchValue(&container.ContainerDir, s.ContainerDir)
32 s.RemovedDir = c.MkDir()32 s.RemovedDir = c.MkDir()
3333
=== modified file 'container/lxc/export_test.go'
--- container/lxc/export_test.go 2014-05-13 12:57:53 +0000
+++ container/lxc/export_test.go 2014-05-22 14:33:28 +0000
@@ -3,18 +3,10 @@
33
4package lxc4package lxc
55
6import "launchpad.net/juju-core/container"
7
8var (6var (
9 ContainerConfigFilename = containerConfigFilename7 ContainerConfigFilename = containerConfigFilename
10 ContainerDirFilesystem = containerDirFilesystem8 ContainerDirFilesystem = containerDirFilesystem
11 GenerateNetworkConfig = generateNetworkConfig9 GenerateNetworkConfig = generateNetworkConfig
12 NetworkConfigTemplate = networkConfigTemplate10 NetworkConfigTemplate = networkConfigTemplate
13 RestartSymlink = restartSymlink11 RestartSymlink = restartSymlink
14 ReleaseVersion = &releaseVersion
15 PreferFastLXC = preferFastLXC
16)12)
17
18func GetCreateWithCloneValue(mgr container.Manager) bool {
19 return mgr.(*containerManager).createWithClone
20}
2113
=== modified file 'container/lxc/initialisation_test.go'
--- container/lxc/initialisation_test.go 2014-05-20 04:27:02 +0000
+++ container/lxc/initialisation_test.go 2014-05-22 14:33:28 +0000
@@ -6,12 +6,12 @@
6import (6import (
7 gc "launchpad.net/gocheck"7 gc "launchpad.net/gocheck"
88
9 "launchpad.net/juju-core/testing"9 "launchpad.net/juju-core/testing/testbase"
10 "launchpad.net/juju-core/utils"10 "launchpad.net/juju-core/utils"
11)11)
1212
13type InitialiserSuite struct {13type InitialiserSuite struct {
14 testing.BaseSuite14 testbase.LoggingSuite
15}15}
1616
17var _ = gc.Suite(&InitialiserSuite{})17var _ = gc.Suite(&InitialiserSuite{})
1818
=== modified file 'container/lxc/lxc.go'
--- container/lxc/lxc.go 2014-05-15 10:31:08 +0000
+++ container/lxc/lxc.go 2014-05-22 14:33:28 +0000
@@ -88,19 +88,10 @@
88 if logDir == "" {88 if logDir == "" {
89 logDir = agent.DefaultLogDir89 logDir = agent.DefaultLogDir
90 }90 }
91 var useClone bool91 // Explicitly ignore the error result from ParseBool.
92 useCloneVal := conf.PopValue("use-clone")92 // If it fails to parse, the value is false, and this suits
93 if useCloneVal != "" {93 // us fine.
94 // Explicitly ignore the error result from ParseBool.94 useClone, _ := strconv.ParseBool(conf.PopValue("use-clone"))
95 // If it fails to parse, the value is false, and this suits
96 // us fine.
97 useClone, _ = strconv.ParseBool(useCloneVal)
98 } else {
99 // If no lxc-clone value is explicitly set in config, then
100 // see if the Ubuntu series we are running on supports it
101 // and if it does, we will use clone.
102 useClone = preferFastLXC(releaseVersion())
103 }
104 useAUFS, _ := strconv.ParseBool(conf.PopValue("use-aufs"))95 useAUFS, _ := strconv.ParseBool(conf.PopValue("use-aufs"))
105 backingFS, err := containerDirFilesystem()96 backingFS, err := containerDirFilesystem()
106 if err != nil {97 if err != nil {
@@ -121,23 +112,6 @@
121 }, nil112 }, nil
122}113}
123114
124// releaseVersion is a function that returns a string representing the
125// DISTRIB_RELEASE from the /etc/lsb-release file.
126var releaseVersion = version.ReleaseVersion
127
128// preferFastLXC returns true if the host is capable of
129// LXC cloning from a template.
130func preferFastLXC(release string) bool {
131 if release == "" {
132 return false
133 }
134 value, err := strconv.ParseFloat(release, 64)
135 if err != nil {
136 return false
137 }
138 return value >= 14.04
139}
140
141func (manager *containerManager) CreateContainer(115func (manager *containerManager) CreateContainer(
142 machineConfig *cloudinit.MachineConfig,116 machineConfig *cloudinit.MachineConfig,
143 series string,117 series string,
144118
=== modified file 'container/lxc/lxc_test.go'
--- container/lxc/lxc_test.go 2014-05-20 04:27:02 +0000
+++ container/lxc/lxc_test.go 2014-05-22 14:33:28 +0000
@@ -26,7 +26,7 @@
26 containertesting "launchpad.net/juju-core/container/testing"26 containertesting "launchpad.net/juju-core/container/testing"
27 instancetest "launchpad.net/juju-core/instance/testing"27 instancetest "launchpad.net/juju-core/instance/testing"
28 "launchpad.net/juju-core/juju/osenv"28 "launchpad.net/juju-core/juju/osenv"
29 coretesting "launchpad.net/juju-core/testing"29 "launchpad.net/juju-core/testing/testbase"
30)30)
3131
32func Test(t *stdtesting.T) {32func Test(t *stdtesting.T) {
@@ -58,68 +58,6 @@
58 s.TestSuite.TearDownTest(c)58 s.TestSuite.TearDownTest(c)
59}59}
6060
61func (t *LxcSuite) TestPreferFastLXC(c *gc.C) {
62 for i, test := range []struct {
63 message string
64 releaseVersion string
65 expected bool
66 }{{
67 message: "missing release file",
68 }, {
69 message: "precise release",
70 releaseVersion: "12.04",
71 }, {
72 message: "trusty release",
73 releaseVersion: "14.04",
74 expected: true,
75 }, {
76 message: "unstable unicorn",
77 releaseVersion: "14.10",
78 expected: true,
79 }, {
80 message: "lucid",
81 releaseVersion: "10.04",
82 }} {
83 c.Logf("%v: %v", i, test.message)
84 value := lxc.PreferFastLXC(test.releaseVersion)
85 c.Assert(value, gc.Equals, test.expected)
86 }
87}
88
89func (s *LxcSuite) TestContainerManagerLXCClone(c *gc.C) {
90 type test struct {
91 releaseVersion string
92 useClone string
93 expectClone bool
94 }
95 tests := []test{{
96 releaseVersion: "12.04",
97 useClone: "true",
98 expectClone: true,
99 }, {
100 releaseVersion: "14.04",
101 expectClone: true,
102 }, {
103 releaseVersion: "12.04",
104 useClone: "false",
105 }, {
106 releaseVersion: "14.04",
107 useClone: "false",
108 }}
109
110 for i, test := range tests {
111 c.Logf("test %d: %v", i, test)
112 s.PatchValue(lxc.ReleaseVersion, func() string { return test.releaseVersion })
113
114 mgr, err := lxc.NewContainerManager(container.ManagerConfig{
115 container.ConfigName: "juju",
116 "use-clone": test.useClone,
117 })
118 c.Assert(err, gc.IsNil)
119 c.Check(lxc.GetCreateWithCloneValue(mgr), gc.Equals, test.expectClone)
120 }
121}
122
123func (s *LxcSuite) TestContainerDirFilesystem(c *gc.C) {61func (s *LxcSuite) TestContainerDirFilesystem(c *gc.C) {
124 for i, test := range []struct {62 for i, test := range []struct {
125 message string63 message string
@@ -155,9 +93,9 @@
155 params := container.ManagerConfig{93 params := container.ManagerConfig{
156 container.ConfigName: name,94 container.ConfigName: name,
157 }95 }
158 // Need to ensure use-clone is explicitly set to avoid it96 if s.useClone {
159 // being set based on the OS version.97 params["use-clone"] = "true"
160 params["use-clone"] = fmt.Sprintf("%v", s.useClone)98 }
161 if s.useAUFS {99 if s.useAUFS {
162 params["use-aufs"] = "true"100 params["use-aufs"] = "true"
163 }101 }
@@ -447,7 +385,7 @@
447}385}
448386
449type NetworkSuite struct {387type NetworkSuite struct {
450 coretesting.BaseSuite388 testbase.LoggingSuite
451}389}
452390
453var _ = gc.Suite(&NetworkSuite{})391var _ = gc.Suite(&NetworkSuite{})
454392
=== modified file 'container/lxc/testing/test.go'
--- container/lxc/testing/test.go 2014-05-16 01:33:13 +0000
+++ container/lxc/testing/test.go 2014-05-22 14:33:28 +0000
@@ -9,13 +9,13 @@
9 "launchpad.net/juju-core/container"9 "launchpad.net/juju-core/container"
10 "launchpad.net/juju-core/container/lxc"10 "launchpad.net/juju-core/container/lxc"
11 "launchpad.net/juju-core/container/lxc/mock"11 "launchpad.net/juju-core/container/lxc/mock"
12 "launchpad.net/juju-core/testing"12 "launchpad.net/juju-core/testing/testbase"
13)13)
1414
15// TestSuite replaces the lxc factory that the broker uses with a mock15// TestSuite replaces the lxc factory that the broker uses with a mock
16// implementation.16// implementation.
17type TestSuite struct {17type TestSuite struct {
18 testing.FakeJujuHomeSuite18 testbase.LoggingSuite
19 Factory mock.ContainerFactory19 Factory mock.ContainerFactory
20 ContainerDir string20 ContainerDir string
21 RemovedDir string21 RemovedDir string
@@ -24,7 +24,7 @@
24}24}
2525
26func (s *TestSuite) SetUpTest(c *gc.C) {26func (s *TestSuite) SetUpTest(c *gc.C) {
27 s.FakeJujuHomeSuite.SetUpTest(c)27 s.LoggingSuite.SetUpTest(c)
28 s.ContainerDir = c.MkDir()28 s.ContainerDir = c.MkDir()
29 s.PatchValue(&container.ContainerDir, s.ContainerDir)29 s.PatchValue(&container.ContainerDir, s.ContainerDir)
30 s.RemovedDir = c.MkDir()30 s.RemovedDir = c.MkDir()
3131
=== removed file 'doc.go'
--- doc.go 2014-05-20 01:56:13 +0000
+++ doc.go 1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
1// Copyright 2013 Canonical Ltd.
2// Licensed under the AGPLv3, see LICENCE file for details.
3
4// Juju is devops distilled.
5//
6// Project homepage: https://launchpad.net/juju-core
7//
8// For more information please refer to the README file
9// in this directory.
10package juju
110
=== modified file 'doc/how-to-write-tests.txt'
--- doc/how-to-write-tests.txt 2014-05-16 01:33:13 +0000
+++ doc/how-to-write-tests.txt 2014-05-22 14:33:28 +0000
@@ -140,28 +140,23 @@
140set-up and tear-down logic. Suites are often composed of other suites140set-up and tear-down logic. Suites are often composed of other suites
141that provide specific set-up and tear-down behaviour.141that provide specific set-up and tear-down behaviour.
142142
143There are four main suites:143There are three main suites:
144144
145 * /testing.BaseSuite (testing/base.go)145 * /testing/testbase.LoggingSuite (testing/testbase/log.go)
146 * /testing.FakeHomeSuite (testing/environ.go)146 * /testing.FakeHomeSuite (testing/environ.go)
147 * /testing.FakeJujuHomeSuite (testing/environ.go)
148 * /juju/testing.JujuConnSuite (juju/testing/conn.go)147 * /juju/testing.JujuConnSuite (juju/testing/conn.go)
149148
150The last three have the BaseSuite functionality included through149The second two have the LoggingSuite functionality included through
151composition. The BaseSuite isolates a user's home directory from accidental150composition. The LoggingSuite is also composed of the LoggingSuite from
152modification (by setting $HOME to "") and errors if there is an attempt to do151github.com/juju/testing, which brings in the CleanupSuite from the same.
153outgoing http access. It also clears the relevant $JUJU_* environment variables.152The CleanupSuite has the functionality around patching environment
154The BaseSuite is also composed of the core LoggingSuite, and also LoggingSuite153variables and normal variables for the duration of a test. It also
155from github.com/juju/testing, which brings in the CleanupSuite from the same.154provides a clean-up stack that gets called when the test teardown happens.
156The CleanupSuite has the functionality around patching environment variables155
157and normal variables for the duration of a test. It also provides a clean-up156The FakeHomeSuite creates a temporary directory and sets the HOME environment
158stack that gets called when the test teardown happens.157variable to it. It also creates ~/.juju and a simple environments.yaml file,
159158~/.ssh with a fake id_rsa.pub key, it isolates the test from the JUJU_HOME,
160All test suites should embedd BaseSuite. Those that need the extra functionality159JUJU_ENV, and JUJU_LOGGING_CONFIG environment variables.
161can instead embedd one of the fake home suites:
162
163* FakeHomeSuite: creates a fake home directory with ~/.ssh and fake ssh keys.
164* FakeJujuHomeSuite: as above but also sets up a ~/.juju with a fake environment.
165160
166The JujuConnSuite does this and more. It also sets up a state server and api161The JujuConnSuite does this and more. It also sets up a state server and api
167server. This is one problem with the JujuConnSuite, it almost always does a162server. This is one problem with the JujuConnSuite, it almost always does a
@@ -174,7 +169,7 @@
174169
175```go170```go
176type ToolsSuite struct {171type ToolsSuite struct {
177 testing.BaseSuite172 testbase.LoggingSuite
178 dataDir string173 dataDir string
179}174}
180175
@@ -191,21 +186,19 @@
191186
192```go187```go
193func (t *ToolsSuite) SetUpTest(c *gc.C) {188func (t *ToolsSuite) SetUpTest(c *gc.C) {
194 t.BaseSuite.SetUpTest(c)189 t.LoggingSuite.SetUpTest(c)
195 t.dataDir = c.MkDir()190 t.dataDir = c.MkDir()
196}191}
197```192```
198193
199If the test suite has multiple contained suites, please call them in the194If the test suite has multiple contained suites, please call them in the
200order that they are defined, and make sure something that is composed from195order that they are defined, and make sure something that is composed from
201the BaseSuite is first. They should be torn down in the reverse order.196the LoggingSuite is first. They should be torn down in the reverse order.
202197
203Even if the code that is being tested currently has no logging or outbound198Even if the code that is being tested currently has no logging in it, it
204network access in it, it is a good idea to use the BaseSuite as a base:199is a good idea to use the LoggingSuite as a base for two reasons:
205 * it isolates the user's home directory against accidental modification
206 * if someone does add outbound network access later, it will be caught
207 * it brings in something composed of the CleanupSuite200 * it brings in something composed of the CleanupSuite
208 * if someone does add logging later, it is captured and doesn't pollute201 * if someone does add logging later, it is captured and doesn't polute
209 the logging output202 the logging output
210203
211204
212205
=== modified file 'downloader/downloader_test.go'
--- downloader/downloader_test.go 2014-05-20 04:27:02 +0000
+++ downloader/downloader_test.go 2014-05-22 14:33:28 +0000
@@ -14,32 +14,33 @@
1414
15 "launchpad.net/juju-core/downloader"15 "launchpad.net/juju-core/downloader"
16 "launchpad.net/juju-core/testing"16 "launchpad.net/juju-core/testing"
17 "launchpad.net/juju-core/testing/testbase"
17 "launchpad.net/juju-core/utils"18 "launchpad.net/juju-core/utils"
18)19)
1920
20type suite struct {21type suite struct {
21 testing.BaseSuite22 testbase.LoggingSuite
22 testing.HTTPSuite23 testing.HTTPSuite
23}24}
2425
25func (s *suite) SetUpSuite(c *gc.C) {26func (s *suite) SetUpSuite(c *gc.C) {
26 s.BaseSuite.SetUpSuite(c)27 s.LoggingSuite.SetUpSuite(c)
27 s.HTTPSuite.SetUpSuite(c)28 s.HTTPSuite.SetUpSuite(c)
28}29}
2930
30func (s *suite) TearDownSuite(c *gc.C) {31func (s *suite) TearDownSuite(c *gc.C) {
31 s.HTTPSuite.TearDownSuite(c)32 s.HTTPSuite.TearDownSuite(c)
32 s.BaseSuite.TearDownSuite(c)33 s.LoggingSuite.TearDownSuite(c)
33}34}
3435
35func (s *suite) SetUpTest(c *gc.C) {36func (s *suite) SetUpTest(c *gc.C) {
36 s.BaseSuite.SetUpTest(c)37 s.LoggingSuite.SetUpTest(c)
37 s.HTTPSuite.SetUpTest(c)38 s.HTTPSuite.SetUpTest(c)
38}39}
3940
40func (s *suite) TearDownTest(c *gc.C) {41func (s *suite) TearDownTest(c *gc.C) {
41 s.HTTPSuite.TearDownTest(c)42 s.HTTPSuite.TearDownTest(c)
42 s.BaseSuite.TearDownTest(c)43 s.LoggingSuite.TearDownTest(c)
43}44}
4445
45var _ = gc.Suite(&suite{})46var _ = gc.Suite(&suite{})
4647
=== modified file 'environs/bootstrap/bootstrap_test.go'
--- environs/bootstrap/bootstrap_test.go 2014-05-19 04:28:01 +0000
+++ environs/bootstrap/bootstrap_test.go 2014-05-22 14:33:28 +0000
@@ -24,6 +24,7 @@
24 "launchpad.net/juju-core/juju/arch"24 "launchpad.net/juju-core/juju/arch"
25 "launchpad.net/juju-core/provider/dummy"25 "launchpad.net/juju-core/provider/dummy"
26 coretesting "launchpad.net/juju-core/testing"26 coretesting "launchpad.net/juju-core/testing"
27 "launchpad.net/juju-core/testing/testbase"
27 "launchpad.net/juju-core/tools"28 "launchpad.net/juju-core/tools"
28 "launchpad.net/juju-core/version"29 "launchpad.net/juju-core/version"
29)30)
@@ -38,20 +39,23 @@
38)39)
3940
40type bootstrapSuite struct {41type bootstrapSuite struct {
41 coretesting.BaseSuite42 home *coretesting.FakeHome
43 testbase.LoggingSuite
42 envtesting.ToolsFixture44 envtesting.ToolsFixture
43}45}
4446
45var _ = gc.Suite(&bootstrapSuite{})47var _ = gc.Suite(&bootstrapSuite{})
4648
47func (s *bootstrapSuite) SetUpTest(c *gc.C) {49func (s *bootstrapSuite) SetUpTest(c *gc.C) {
48 s.BaseSuite.SetUpTest(c)50 s.LoggingSuite.SetUpTest(c)
49 s.ToolsFixture.SetUpTest(c)51 s.ToolsFixture.SetUpTest(c)
52 s.home = coretesting.MakeFakeHomeNoEnvironments(c, "foo")
50}53}
5154
52func (s *bootstrapSuite) TearDownTest(c *gc.C) {55func (s *bootstrapSuite) TearDownTest(c *gc.C) {
56 s.home.Restore()
53 s.ToolsFixture.TearDownTest(c)57 s.ToolsFixture.TearDownTest(c)
54 s.BaseSuite.TearDownTest(c)58 s.LoggingSuite.TearDownTest(c)
55}59}
5660
57func (s *bootstrapSuite) TestBootstrapNeedsSettings(c *gc.C) {61func (s *bootstrapSuite) TestBootstrapNeedsSettings(c *gc.C) {
5862
=== modified file 'environs/bootstrap/interruptiblestorage_test.go'
--- environs/bootstrap/interruptiblestorage_test.go 2014-05-20 04:27:02 +0000
+++ environs/bootstrap/interruptiblestorage_test.go 2014-05-22 14:33:28 +0000
@@ -10,11 +10,11 @@
1010
11 "launchpad.net/juju-core/environs/bootstrap"11 "launchpad.net/juju-core/environs/bootstrap"
12 envtesting "launchpad.net/juju-core/environs/testing"12 envtesting "launchpad.net/juju-core/environs/testing"
13 coretesting "launchpad.net/juju-core/testing"13 "launchpad.net/juju-core/testing/testbase"
14)14)
1515
16type interruptibleStorageSuite struct {16type interruptibleStorageSuite struct {
17 coretesting.BaseSuite17 testbase.LoggingSuite
18}18}
1919
20var _ = gc.Suite(&interruptibleStorageSuite{})20var _ = gc.Suite(&interruptibleStorageSuite{})
2121
=== modified file 'environs/bootstrap/state_test.go'
--- environs/bootstrap/state_test.go 2014-05-20 04:27:02 +0000
+++ environs/bootstrap/state_test.go 2014-05-22 14:33:28 +0000
@@ -19,11 +19,11 @@
19 "launchpad.net/juju-core/environs/storage"19 "launchpad.net/juju-core/environs/storage"
20 envtesting "launchpad.net/juju-core/environs/testing"20 envtesting "launchpad.net/juju-core/environs/testing"
21 "launchpad.net/juju-core/instance"21 "launchpad.net/juju-core/instance"
22 coretesting "launchpad.net/juju-core/testing"22 "launchpad.net/juju-core/testing/testbase"
23)23)
2424
25type StateSuite struct {25type StateSuite struct {
26 coretesting.BaseSuite26 testbase.LoggingSuite
27}27}
2828
29var _ = gc.Suite(&StateSuite{})29var _ = gc.Suite(&StateSuite{})
3030
=== modified file 'environs/cloudinit/cloudinit_test.go'
--- environs/cloudinit/cloudinit_test.go 2014-05-20 04:27:02 +0000
+++ environs/cloudinit/cloudinit_test.go 2014-05-22 14:33:28 +0000
@@ -24,6 +24,7 @@
24 "launchpad.net/juju-core/state/api"24 "launchpad.net/juju-core/state/api"
25 "launchpad.net/juju-core/state/api/params"25 "launchpad.net/juju-core/state/api/params"
26 "launchpad.net/juju-core/testing"26 "launchpad.net/juju-core/testing"
27 "launchpad.net/juju-core/testing/testbase"
27 "launchpad.net/juju-core/tools"28 "launchpad.net/juju-core/tools"
28 "launchpad.net/juju-core/version"29 "launchpad.net/juju-core/version"
29)30)
@@ -31,7 +32,7 @@
31// Use local suite since this file lives in the ec2 package32// Use local suite since this file lives in the ec2 package
32// for testing internals.33// for testing internals.
33type cloudinitSuite struct {34type cloudinitSuite struct {
34 testing.BaseSuite35 testbase.LoggingSuite
35}36}
3637
37var _ = gc.Suite(&cloudinitSuite{})38var _ = gc.Suite(&cloudinitSuite{})
3839
=== modified file 'environs/cloudinit_test.go'
--- environs/cloudinit_test.go 2014-05-20 04:27:02 +0000
+++ environs/cloudinit_test.go 2014-05-22 14:33:28 +0000
@@ -23,6 +23,7 @@
23 "launchpad.net/juju-core/state/api"23 "launchpad.net/juju-core/state/api"
24 "launchpad.net/juju-core/state/api/params"24 "launchpad.net/juju-core/state/api/params"
25 "launchpad.net/juju-core/testing"25 "launchpad.net/juju-core/testing"
26 "launchpad.net/juju-core/testing/testbase"
26 "launchpad.net/juju-core/tools"27 "launchpad.net/juju-core/tools"
27 "launchpad.net/juju-core/utils"28 "launchpad.net/juju-core/utils"
28 "launchpad.net/juju-core/version"29 "launchpad.net/juju-core/version"
@@ -38,7 +39,7 @@
38}39}
3940
40type CloudInitSuite struct {41type CloudInitSuite struct {
41 testing.BaseSuite42 testbase.LoggingSuite
42}43}
4344
44var _ = gc.Suite(&CloudInitSuite{})45var _ = gc.Suite(&CloudInitSuite{})
4546
=== modified file 'environs/config.go'
--- environs/config.go 2014-05-15 10:31:08 +0000
+++ environs/config.go 2014-05-22 14:33:28 +0000
@@ -98,14 +98,6 @@
98 )98 )
99 }99 }
100100
101 // lxc-use-clone has been renamed to lxc-clone
102 if _, ok := attrs["lxc-use-clone"]; ok {
103 logger.Warningf(
104 "Config attribute \"lxc-use-clone\" has been renamed to \"lxc-clone\".\n" +
105 "Please update your environment configuration.",
106 )
107 }
108
109 cfg, err := config.New(config.UseDefaults, attrs)101 cfg, err := config.New(config.UseDefaults, attrs)
110 if err != nil {102 if err != nil {
111 return nil, err103 return nil, err
112104
=== modified file 'environs/config/authkeys_test.go'
--- environs/config/authkeys_test.go 2014-05-20 04:27:02 +0000
+++ environs/config/authkeys_test.go 2014-05-22 14:33:28 +0000
@@ -13,19 +13,19 @@
1313
14 "launchpad.net/juju-core/environs/config"14 "launchpad.net/juju-core/environs/config"
15 "launchpad.net/juju-core/juju/osenv"15 "launchpad.net/juju-core/juju/osenv"
16 "launchpad.net/juju-core/testing"16 "launchpad.net/juju-core/testing/testbase"
17 "launchpad.net/juju-core/utils/ssh"17 "launchpad.net/juju-core/utils/ssh"
18)18)
1919
20type AuthKeysSuite struct {20type AuthKeysSuite struct {
21 testing.BaseSuite21 testbase.LoggingSuite
22 dotssh string // ~/.ssh22 dotssh string // ~/.ssh
23}23}
2424
25var _ = gc.Suite(&AuthKeysSuite{})25var _ = gc.Suite(&AuthKeysSuite{})
2626
27func (s *AuthKeysSuite) SetUpTest(c *gc.C) {27func (s *AuthKeysSuite) SetUpTest(c *gc.C) {
28 s.BaseSuite.SetUpTest(c)28 s.LoggingSuite.SetUpTest(c)
29 old := osenv.Home()29 old := osenv.Home()
30 newhome := c.MkDir()30 newhome := c.MkDir()
31 osenv.SetHome(newhome)31 osenv.SetHome(newhome)
@@ -37,7 +37,7 @@
3737
38func (s *AuthKeysSuite) TearDownTest(c *gc.C) {38func (s *AuthKeysSuite) TearDownTest(c *gc.C) {
39 ssh.ClearClientKeys()39 ssh.ClearClientKeys()
40 s.BaseSuite.TearDownTest(c)40 s.LoggingSuite.TearDownTest(c)
41}41}
4242
43func (s *AuthKeysSuite) TestReadAuthorizedKeysErrors(c *gc.C) {43func (s *AuthKeysSuite) TestReadAuthorizedKeysErrors(c *gc.C) {
4444
=== modified file 'environs/config/config.go'
--- environs/config/config.go 2014-05-15 10:31:08 +0000
+++ environs/config/config.go 2014-05-22 14:33:28 +0000
@@ -258,16 +258,6 @@
258 // Even if the user has edited their environment yaml to remove the deprecated tools-url value,258 // Even if the user has edited their environment yaml to remove the deprecated tools-url value,
259 // we still want it in the config for upgrades.259 // we still want it in the config for upgrades.
260 cfg.defined["tools-url"], _ = cfg.ToolsURL()260 cfg.defined["tools-url"], _ = cfg.ToolsURL()
261
262 // Copy across lxc-use-clone to lxc-clone.
263 if lxcUseClone, ok := cfg.defined["lxc-use-clone"]; ok {
264 _, newValSpecified := cfg.LXCUseClone()
265 // Ensure the new attribute name "lxc-clone" is set.
266 if !newValSpecified {
267 cfg.defined["lxc-clone"] = lxcUseClone
268 }
269 }
270
271 // Update the provider type from null to manual.261 // Update the provider type from null to manual.
272 if cfg.Type() == "null" {262 if cfg.Type() == "null" {
273 cfg.defined["type"] = "manual"263 cfg.defined["type"] = "manual"
@@ -710,16 +700,9 @@
710700
711// LXCUseClone reports whether the LXC provisioner should create a701// LXCUseClone reports whether the LXC provisioner should create a
712// template and use cloning to speed up container provisioning.702// template and use cloning to speed up container provisioning.
713func (c *Config) LXCUseClone() (bool, bool) {703func (c *Config) LXCUseClone() bool {
714 v, ok := c.defined["lxc-clone"].(bool)704 v, _ := c.defined["lxc-use-clone"].(bool)
715 return v, ok705 return v
716}
717
718// LXCUseCloneAUFS reports whether the LXC provisioner should create a
719// lxc clone using aufs if available.
720func (c *Config) LXCUseCloneAUFS() (bool, bool) {
721 v, ok := c.defined["lxc-clone-aufs"].(bool)
722 return v, ok
723}706}
724707
725// UnknownAttrs returns a copy of the raw configuration attributes708// UnknownAttrs returns a copy of the raw configuration attributes
@@ -798,12 +781,10 @@
798 "bootstrap-addresses-delay": schema.ForceInt(),781 "bootstrap-addresses-delay": schema.ForceInt(),
799 "test-mode": schema.Bool(),782 "test-mode": schema.Bool(),
800 "proxy-ssh": schema.Bool(),783 "proxy-ssh": schema.Bool(),
801 "lxc-clone": schema.Bool(),784 "lxc-use-clone": schema.Bool(),
802 "lxc-clone-aufs": schema.Bool(),
803785
804 // Deprecated fields, retain for backwards compatibility.786 // Deprecated fields, retain for backwards compatibility.
805 "tools-url": schema.String(),787 "tools-url": schema.String(),
806 "lxc-use-clone": schema.Bool(),
807}788}
808789
809// alwaysOptional holds configuration defaults for attributes that may790// alwaysOptional holds configuration defaults for attributes that may
@@ -834,11 +815,9 @@
834 "apt-http-proxy": schema.Omit,815 "apt-http-proxy": schema.Omit,
835 "apt-https-proxy": schema.Omit,816 "apt-https-proxy": schema.Omit,
836 "apt-ftp-proxy": schema.Omit,817 "apt-ftp-proxy": schema.Omit,
837 "lxc-clone": schema.Omit,
838818
839 // Deprecated fields, retain for backwards compatibility.819 // Deprecated fields, retain for backwards compatibility.
840 "tools-url": "",820 "tools-url": "",
841 "lxc-use-clone": schema.Omit,
842821
843 // For backward compatibility reasons, the following822 // For backward compatibility reasons, the following
844 // attributes default to empty strings rather than being823 // attributes default to empty strings rather than being
@@ -860,10 +839,10 @@
860 // Authentication string sent with requests to the charm store839 // Authentication string sent with requests to the charm store
861 "charm-store-auth": "",840 "charm-store-auth": "",
862 // Previously image-stream could be set to an empty value841 // Previously image-stream could be set to an empty value
863 "image-stream": "",842 "image-stream": "",
864 "test-mode": false,843 "test-mode": false,
865 "proxy-ssh": false,844 "proxy-ssh": false,
866 "lxc-clone-aufs": false,845 "lxc-use-clone": false,
867}846}
868847
869func allowEmpty(attr string) bool {848func allowEmpty(attr string) bool {
@@ -924,8 +903,7 @@
924 "bootstrap-timeout",903 "bootstrap-timeout",
925 "bootstrap-retry-delay",904 "bootstrap-retry-delay",
926 "bootstrap-addresses-delay",905 "bootstrap-addresses-delay",
927 "lxc-clone",906 "lxc-use-clone",
928 "lxc-clone-aufs",
929}907}
930908
931var (909var (
932910
=== modified file 'environs/config/config_test.go'
--- environs/config/config_test.go 2014-05-16 04:57:59 +0000
+++ environs/config/config_test.go 2014-05-22 14:33:28 +0000
@@ -18,6 +18,7 @@
18 "launchpad.net/juju-core/juju/osenv"18 "launchpad.net/juju-core/juju/osenv"
19 "launchpad.net/juju-core/schema"19 "launchpad.net/juju-core/schema"
20 "launchpad.net/juju-core/testing"20 "launchpad.net/juju-core/testing"
21 "launchpad.net/juju-core/testing/testbase"
21 "launchpad.net/juju-core/version"22 "launchpad.net/juju-core/version"
22)23)
2324
@@ -26,14 +27,14 @@
26}27}
2728
28type ConfigSuite struct {29type ConfigSuite struct {
29 testing.FakeJujuHomeSuite30 testbase.LoggingSuite
30 home string31 home string
31}32}
3233
33var _ = gc.Suite(&ConfigSuite{})34var _ = gc.Suite(&ConfigSuite{})
3435
35func (s *ConfigSuite) SetUpTest(c *gc.C) {36func (s *ConfigSuite) SetUpTest(c *gc.C) {
36 s.FakeJujuHomeSuite.SetUpTest(c)37 s.LoggingSuite.SetUpTest(c)
37 // Make sure that the defaults are used, which38 // Make sure that the defaults are used, which
38 // is <root>=WARNING39 // is <root>=WARNING
39 loggo.ResetLoggers()40 loggo.ResetLoggers()
@@ -60,8 +61,7 @@
60type configTest struct {61type configTest struct {
61 about string62 about string
62 useDefaults config.Defaulting63 useDefaults config.Defaulting
63 attrs testing.Attrs64 attrs map[string]interface{}
64 expected testing.Attrs
65 err string65 err string
66}66}
6767
@@ -140,33 +140,6 @@
140 "authorized-keys-path": "~/.ssh/authorized_keys2",140 "authorized-keys-path": "~/.ssh/authorized_keys2",
141 },141 },
142 }, {142 }, {
143 about: "LXC clone values",
144 useDefaults: config.UseDefaults,
145 attrs: testing.Attrs{
146 "type": "my-type",
147 "name": "my-name",
148 "default-series": "precise",
149 "lxc-clone": true,
150 "lxc-clone-aufs": true,
151 },
152 }, {
153 about: "Deprecated lxc-use-clone used",
154 useDefaults: config.UseDefaults,
155 attrs: testing.Attrs{
156 "type": "my-type",
157 "name": "my-name",
158 "lxc-use-clone": true,
159 },
160 }, {
161 about: "Deprecated lxc-use-clone ignored",
162 useDefaults: config.UseDefaults,
163 attrs: testing.Attrs{
164 "type": "my-type",
165 "name": "my-name",
166 "lxc-use-clone": false,
167 "lxc-clone": true,
168 },
169 }, {
170 about: "CA cert & key from path",143 about: "CA cert & key from path",
171 useDefaults: config.UseDefaults,144 useDefaults: config.UseDefaults,
172 attrs: testing.Attrs{145 attrs: testing.Attrs{
@@ -723,7 +696,7 @@
723 name, data string696 name, data string
724}697}
725698
726func (s *ConfigSuite) TestConfig(c *gc.C) {699func (*ConfigSuite) TestConfig(c *gc.C) {
727 files := []testing.TestFile{700 files := []testing.TestFile{
728 {".ssh/id_dsa.pub", "dsa"},701 {".ssh/id_dsa.pub", "dsa"},
729 {".ssh/id_rsa.pub", "rsa\n"},702 {".ssh/id_rsa.pub", "rsa\n"},
@@ -738,10 +711,11 @@
738 {"othercert.pem", caCert3},711 {"othercert.pem", caCert3},
739 {"otherkey.pem", caKey3},712 {"otherkey.pem", caKey3},
740 }713 }
741 s.FakeHomeSuite.Home.AddFiles(c, files...)714 h := testing.MakeFakeHomeWithFiles(c, files)
715 defer h.Restore()
742 for i, test := range configTests {716 for i, test := range configTests {
743 c.Logf("test %d. %s", i, test.about)717 c.Logf("test %d. %s", i, test.about)
744 test.check(c, s.FakeHomeSuite.Home)718 test.check(c, h)
745 }719 }
746}720}
747721
@@ -767,10 +741,12 @@
767 },741 },
768}742}
769743
770func (s *ConfigSuite) TestConfigNoCertFiles(c *gc.C) {744func (*ConfigSuite) TestConfigNoCertFiles(c *gc.C) {
745 h := testing.MakeEmptyFakeHome(c)
746 defer h.Restore()
771 for i, test := range noCertFilesTests {747 for i, test := range noCertFilesTests {
772 c.Logf("test %d. %s", i, test.about)748 c.Logf("test %d. %s", i, test.about)
773 test.check(c, s.FakeHomeSuite.Home)749 test.check(c, h)
774 }750 }
775}751}
776752
@@ -827,16 +803,17 @@
827 }, */803 }, */
828}804}
829805
830func (s *ConfigSuite) TestConfigEmptyCertFiles(c *gc.C) {806func (*ConfigSuite) TestConfigEmptyCertFiles(c *gc.C) {
831 files := []testing.TestFile{807 files := []testing.TestFile{
832 {".juju/my-name-cert.pem", ""},808 {".juju/my-name-cert.pem", ""},
833 {".juju/my-name-private-key.pem", ""},809 {".juju/my-name-private-key.pem", ""},
834 }810 }
835 s.FakeHomeSuite.Home.AddFiles(c, files...)811 h := testing.MakeFakeHomeWithFiles(c, files)
812 defer h.Restore()
836813
837 for i, test := range emptyCertFilesTests {814 for i, test := range emptyCertFilesTests {
838 c.Logf("test %d. %s", i, test.about)815 c.Logf("test %d. %s", i, test.about)
839 test.check(c, s.FakeHomeSuite.Home)816 test.check(c, h)
840 }817 }
841}818}
842819
@@ -1004,27 +981,6 @@
1004 c.Assert(oldURLAttrPresent, jc.IsFalse)981 c.Assert(oldURLAttrPresent, jc.IsFalse)
1005 c.Assert(oldToolsURL, gc.Equals, "")982 c.Assert(oldToolsURL, gc.Equals, "")
1006 }983 }
1007
1008 useLxcClone, useLxcClonePresent := cfg.LXCUseClone()
1009 oldUseClone, oldUseClonePresent := cfg.AllAttrs()["lxc-use-clone"]
1010 if v, ok := test.attrs["lxc-clone"]; ok {
1011 c.Assert(useLxcClone, gc.Equals, v)
1012 c.Assert(useLxcClonePresent, jc.IsTrue)
1013 } else {
1014 if oldUseClonePresent {
1015 c.Assert(useLxcClonePresent, jc.IsTrue)
1016 c.Assert(useLxcClone, gc.Equals, oldUseClone)
1017 } else {
1018 c.Assert(useLxcClonePresent, jc.IsFalse)
1019 c.Assert(useLxcClone, gc.Equals, false)
1020 }
1021 }
1022 useLxcCloneAufs, ok := cfg.LXCUseCloneAUFS()
1023 if v, ok := test.attrs["lxc-clone-aufs"]; ok {
1024 c.Assert(useLxcCloneAufs, gc.Equals, v)
1025 } else {
1026 c.Assert(useLxcCloneAufs, gc.Equals, false)
1027 }
1028}984}
1029985
1030func (test configTest) assertDuration(c *gc.C, name string, actual time.Duration, defaultInSeconds int) {986func (test configTest) assertDuration(c *gc.C, name string, actual time.Duration, defaultInSeconds int) {
@@ -1072,7 +1028,7 @@
1072 attrs["tools-url"] = ""1028 attrs["tools-url"] = ""
1073 attrs["image-stream"] = ""1029 attrs["image-stream"] = ""
1074 attrs["proxy-ssh"] = false1030 attrs["proxy-ssh"] = false
1075 attrs["lxc-clone-aufs"] = false1031 attrs["lxc-use-clone"] = false
10761032
1077 // Default firewall mode is instance1033 // Default firewall mode is instance
1078 attrs["firewall-mode"] = string(config.FwInstance)1034 attrs["firewall-mode"] = string(config.FwInstance)
@@ -1156,22 +1112,18 @@
1156 new: testing.Attrs{"bootstrap-timeout": 5},1112 new: testing.Attrs{"bootstrap-timeout": 5},
1157 err: `cannot change bootstrap-timeout from 600 to 5`,1113 err: `cannot change bootstrap-timeout from 600 to 5`,
1158}, {1114}, {
1159 about: "Cannot change lxc-clone",1115 about: "Cannot change lxc-use-clone",
1160 old: testing.Attrs{"lxc-clone": false},1116 old: testing.Attrs{"lxc-use-clone": false},
1161 new: testing.Attrs{"lxc-clone": true},1117 new: testing.Attrs{"lxc-use-clone": true},
1162 err: `cannot change lxc-clone from false to true`,1118 err: `cannot change lxc-use-clone from false to true`,
1163}, {
1164 about: "Cannot change lxc-clone-aufs",
1165 old: testing.Attrs{"lxc-clone-aufs": false},
1166 new: testing.Attrs{"lxc-clone-aufs": true},
1167 err: `cannot change lxc-clone-aufs from false to true`,
1168}}1119}}
11691120
1170func (s *ConfigSuite) TestValidateChange(c *gc.C) {1121func (*ConfigSuite) TestValidateChange(c *gc.C) {
1171 files := []testing.TestFile{1122 files := []testing.TestFile{
1172 {".ssh/identity.pub", "identity"},1123 {".ssh/identity.pub", "identity"},
1173 }1124 }
1174 s.FakeHomeSuite.Home.AddFiles(c, files...)1125 h := testing.MakeFakeHomeWithFiles(c, files)
1126 defer h.Restore()
11751127
1176 for i, test := range validationTests {1128 for i, test := range validationTests {
1177 c.Logf("test %d: %s", i, test.about)1129 c.Logf("test %d: %s", i, test.about)
@@ -1179,23 +1131,23 @@
1179 oldConfig := newTestConfig(c, test.old)1131 oldConfig := newTestConfig(c, test.old)
1180 err := config.Validate(newConfig, oldConfig)1132 err := config.Validate(newConfig, oldConfig)
1181 if test.err == "" {1133 if test.err == "" {
1182 c.Check(err, gc.IsNil)1134 c.Assert(err, gc.IsNil)
1183 } else {1135 } else {
1184 c.Check(err, gc.ErrorMatches, test.err)1136 c.Assert(err, gc.ErrorMatches, test.err)
1185 }1137 }
1186 }1138 }
1187}1139}
11881140
1189func (s *ConfigSuite) addJujuFiles(c *gc.C) {1141func makeFakeHome(c *gc.C) *testing.FakeHome {
1190 s.FakeHomeSuite.Home.AddFiles(c, []testing.TestFile{1142 return testing.MakeFakeHomeWithFiles(c, []testing.TestFile{
1191 {".ssh/id_rsa.pub", "rsa\n"},1143 {".ssh/id_rsa.pub", "rsa\n"},
1192 {".juju/myenv-cert.pem", caCert},1144 {".juju/myenv-cert.pem", caCert},
1193 {".juju/myenv-private-key.pem", caKey},1145 {".juju/myenv-private-key.pem", caKey},
1194 }...)1146 })
1195}1147}
11961148
1197func (s *ConfigSuite) TestValidateUnknownAttrs(c *gc.C) {1149func (*ConfigSuite) TestValidateUnknownAttrs(c *gc.C) {
1198 s.addJujuFiles(c)1150 defer makeFakeHome(c).Restore()
1199 cfg, err := config.New(config.UseDefaults, map[string]interface{}{1151 cfg, err := config.New(config.UseDefaults, map[string]interface{}{
1200 "name": "myenv",1152 "name": "myenv",
1201 "type": "other",1153 "type": "other",
@@ -1247,30 +1199,32 @@
1247 return result1199 return result
1248}1200}
12491201
1250func (s *ConfigSuite) TestLoggingConfig(c *gc.C) {1202func (*ConfigSuite) TestLoggingConfig(c *gc.C) {
1251 s.addJujuFiles(c)1203 defer makeFakeHome(c).Restore()
1204
1252 config := newTestConfig(c, testing.Attrs{1205 config := newTestConfig(c, testing.Attrs{
1253 "logging-config": "<root>=WARNING;juju=DEBUG"})1206 "logging-config": "<root>=WARNING;juju=DEBUG"})
1254 c.Assert(config.LoggingConfig(), gc.Equals, "<root>=WARNING;juju=DEBUG;unit=DEBUG")1207 c.Assert(config.LoggingConfig(), gc.Equals, "<root>=WARNING;juju=DEBUG;unit=DEBUG")
1255}1208}
12561209
1257func (s *ConfigSuite) TestLoggingConfigWithUnit(c *gc.C) {1210func (*ConfigSuite) TestLoggingConfigWithUnit(c *gc.C) {
1258 s.addJujuFiles(c)1211 defer makeFakeHome(c).Restore()
1212
1259 config := newTestConfig(c, testing.Attrs{1213 config := newTestConfig(c, testing.Attrs{
1260 "logging-config": "<root>=WARNING;unit=INFO"})1214 "logging-config": "<root>=WARNING;unit=INFO"})
1261 c.Assert(config.LoggingConfig(), gc.Equals, "<root>=WARNING;unit=INFO")1215 c.Assert(config.LoggingConfig(), gc.Equals, "<root>=WARNING;unit=INFO")
1262}1216}
12631217
1264func (s *ConfigSuite) TestLoggingConfigFromEnvironment(c *gc.C) {1218func (s *ConfigSuite) TestLoggingConfigFromEnvironment(c *gc.C) {
1265 s.addJujuFiles(c)1219 defer makeFakeHome(c).Restore()
1266 s.PatchEnvironment(osenv.JujuLoggingConfigEnvKey, "<root>=INFO")1220 s.PatchEnvironment(osenv.JujuLoggingConfigEnvKey, "<root>=INFO")
12671221
1268 config := newTestConfig(c, nil)1222 config := newTestConfig(c, nil)
1269 c.Assert(config.LoggingConfig(), gc.Equals, "<root>=INFO;unit=DEBUG")1223 c.Assert(config.LoggingConfig(), gc.Equals, "<root>=INFO;unit=DEBUG")
1270}1224}
12711225
1272func (s *ConfigSuite) TestProxyValuesWithFallback(c *gc.C) {1226func (*ConfigSuite) TestProxyValuesWithFallback(c *gc.C) {
1273 s.addJujuFiles(c)1227 defer makeFakeHome(c).Restore()
12741228
1275 config := newTestConfig(c, testing.Attrs{1229 config := newTestConfig(c, testing.Attrs{
1276 "http-proxy": "http://user@10.0.0.1",1230 "http-proxy": "http://user@10.0.0.1",
@@ -1287,8 +1241,9 @@
1287 c.Assert(config.NoProxy(), gc.Equals, "localhost,10.0.3.1")1241 c.Assert(config.NoProxy(), gc.Equals, "localhost,10.0.3.1")
1288}1242}
12891243
1290func (s *ConfigSuite) TestProxyValues(c *gc.C) {1244func (*ConfigSuite) TestProxyValues(c *gc.C) {
1291 s.addJujuFiles(c)1245 defer makeFakeHome(c).Restore()
1246
1292 config := newTestConfig(c, testing.Attrs{1247 config := newTestConfig(c, testing.Attrs{
1293 "http-proxy": "http://user@10.0.0.1",1248 "http-proxy": "http://user@10.0.0.1",
1294 "https-proxy": "https://user@10.0.0.1",1249 "https-proxy": "https://user@10.0.0.1",
@@ -1305,8 +1260,9 @@
1305 c.Assert(config.AptFtpProxy(), gc.Equals, "ftp://user@10.0.0.2")1260 c.Assert(config.AptFtpProxy(), gc.Equals, "ftp://user@10.0.0.2")
1306}1261}
13071262
1308func (s *ConfigSuite) TestProxyValuesNotSet(c *gc.C) {1263func (*ConfigSuite) TestProxyValuesNotSet(c *gc.C) {
1309 s.addJujuFiles(c)1264 defer makeFakeHome(c).Restore()
1265
1310 config := newTestConfig(c, testing.Attrs{})1266 config := newTestConfig(c, testing.Attrs{})
1311 c.Assert(config.HttpProxy(), gc.Equals, "")1267 c.Assert(config.HttpProxy(), gc.Equals, "")
1312 c.Assert(config.AptHttpProxy(), gc.Equals, "")1268 c.Assert(config.AptHttpProxy(), gc.Equals, "")
@@ -1317,8 +1273,9 @@
1317 c.Assert(config.NoProxy(), gc.Equals, "")1273 c.Assert(config.NoProxy(), gc.Equals, "")
1318}1274}
13191275
1320func (s *ConfigSuite) TestProxyConfigMap(c *gc.C) {1276func (*ConfigSuite) TestProxyConfigMap(c *gc.C) {
1321 s.addJujuFiles(c)1277 defer makeFakeHome(c).Restore()
1278
1322 cfg := newTestConfig(c, testing.Attrs{})1279 cfg := newTestConfig(c, testing.Attrs{})
1323 proxy := osenv.ProxySettings{1280 proxy := osenv.ProxySettings{
1324 Http: "http proxy",1281 Http: "http proxy",
@@ -1334,8 +1291,9 @@
1334 c.Assert(cfg.AptProxySettings(), gc.DeepEquals, proxy)1291 c.Assert(cfg.AptProxySettings(), gc.DeepEquals, proxy)
1335}1292}
13361293
1337func (s *ConfigSuite) TestAptProxyConfigMap(c *gc.C) {1294func (*ConfigSuite) TestAptProxyConfigMap(c *gc.C) {
1338 s.addJujuFiles(c)1295 defer makeFakeHome(c).Restore()
1296
1339 cfg := newTestConfig(c, testing.Attrs{})1297 cfg := newTestConfig(c, testing.Attrs{})
1340 proxy := osenv.ProxySettings{1298 proxy := osenv.ProxySettings{
1341 Http: "http proxy",1299 Http: "http proxy",
@@ -1349,9 +1307,12 @@
1349 c.Assert(cfg.AptProxySettings(), gc.DeepEquals, proxy)1307 c.Assert(cfg.AptProxySettings(), gc.DeepEquals, proxy)
1350}1308}
13511309
1352func (s *ConfigSuite) TestGenerateStateServerCertAndKey(c *gc.C) {1310func (*ConfigSuite) TestGenerateStateServerCertAndKey(c *gc.C) {
1353 // Add a cert.1311 // In order to test missing certs, it checks the JUJU_HOME dir, so we need
1354 s.FakeHomeSuite.Home.AddFiles(c, testing.TestFile{".ssh/id_rsa.pub", "rsa\n"})1312 // a fake home.
1313 defer testing.MakeFakeHomeWithFiles(c, []testing.TestFile{
1314 {".ssh/id_rsa.pub", "rsa\n"},
1315 }).Restore()
13551316
1356 for _, test := range []struct {1317 for _, test := range []struct {
1357 configValues map[string]interface{}1318 configValues map[string]interface{}
13581319
=== modified file 'environs/config_test.go'
--- environs/config_test.go 2014-05-16 04:57:59 +0000
+++ environs/config_test.go 2014-05-22 14:33:28 +0000
@@ -19,17 +19,18 @@
19 "launchpad.net/juju-core/provider/dummy"19 "launchpad.net/juju-core/provider/dummy"
20 _ "launchpad.net/juju-core/provider/manual"20 _ "launchpad.net/juju-core/provider/manual"
21 "launchpad.net/juju-core/testing"21 "launchpad.net/juju-core/testing"
22 "launchpad.net/juju-core/testing/testbase"
22)23)
2324
24type suite struct {25type suite struct {
25 testing.FakeJujuHomeSuite26 testbase.LoggingSuite
26}27}
2728
28var _ = gc.Suite(&suite{})29var _ = gc.Suite(&suite{})
2930
30func (s *suite) TearDownTest(c *gc.C) {31func (s *suite) TearDownTest(c *gc.C) {
31 dummy.Reset()32 dummy.Reset()
32 s.FakeJujuHomeSuite.TearDownTest(c)33 s.LoggingSuite.TearDownTest(c)
33}34}
3435
35var invalidConfigTests = []struct {36var invalidConfigTests = []struct {
@@ -79,6 +80,7 @@
79}80}
8081
81func (*suite) TestInvalidEnv(c *gc.C) {82func (*suite) TestInvalidEnv(c *gc.C) {
83 defer testing.MakeFakeHomeNoEnvironments(c, "only").Restore()
82 for i, t := range invalidEnvTests {84 for i, t := range invalidEnvTests {
83 c.Logf("running test %v", i)85 c.Logf("running test %v", i)
84 es, err := environs.ReadEnvironsBytes([]byte(t.env))86 es, err := environs.ReadEnvironsBytes([]byte(t.env))
@@ -95,6 +97,7 @@
95 // However, we can only really trigger that when we have a deprecated97 // However, we can only really trigger that when we have a deprecated
96 // field. If support for the field is removed entirely, another98 // field. If support for the field is removed entirely, another
97 // mechanism will need to be used99 // mechanism will need to be used
100 defer testing.MakeFakeHomeNoEnvironments(c, "only").Restore()
98 content := `101 content := `
99environments:102environments:
100 valid:103 valid:
@@ -104,7 +107,6 @@
104 type: dummy107 type: dummy
105 state-server: false108 state-server: false
106 tools-url: aknowndeprecatedfield109 tools-url: aknowndeprecatedfield
107 lxc-use-clone: true
108`110`
109 tw := &loggo.TestWriter{}111 tw := &loggo.TestWriter{}
110 // we only capture Warning or above112 // we only capture Warning or above
@@ -126,12 +128,12 @@
126 // Only once we grab the deprecated one do we see any warnings128 // Only once we grab the deprecated one do we see any warnings
127 _, err = envs.Config("deprecated")129 _, err = envs.Config("deprecated")
128 c.Check(err, gc.IsNil)130 c.Check(err, gc.IsNil)
129 c.Check(tw.Log, gc.HasLen, 2)131 c.Check(tw.Log, gc.HasLen, 1)
130}132}
131133
132func (*suite) TestNoHomeBeforeConfig(c *gc.C) {134func (*suite) TestNoHomeBeforeConfig(c *gc.C) {
133 // Test that we don't actually need HOME set until we call envs.Config()135 // Test that we don't actually need HOME set until we call envs.Config()
134 os.Setenv("HOME", "")136 // Because of this, we intentionally do *not* call testing.MakeFakeHomeNoEnvironments()
135 content := `137 content := `
136environments:138environments:
137 valid:139 valid:
@@ -144,9 +146,7 @@
144}146}
145147
146func (*suite) TestNoEnv(c *gc.C) {148func (*suite) TestNoEnv(c *gc.C) {
147 envPath := testing.HomePath(".juju", "environments.yaml")149 defer testing.MakeFakeHomeNoEnvironments(c).Restore()
148 err := os.Remove(envPath)
149 c.Assert(err, gc.IsNil)
150 es, err := environs.ReadEnvirons("")150 es, err := environs.ReadEnvirons("")
151 c.Assert(es, gc.IsNil)151 c.Assert(es, gc.IsNil)
152 c.Assert(err, jc.Satisfies, environs.IsNoEnv)152 c.Assert(err, jc.Satisfies, environs.IsNoEnv)
@@ -197,6 +197,7 @@
197}197}
198198
199func (*suite) TestConfig(c *gc.C) {199func (*suite) TestConfig(c *gc.C) {
200 defer testing.MakeFakeHomeNoEnvironments(c, "only", "valid", "one", "two").Restore()
200 for i, t := range configTests {201 for i, t := range configTests {
201 c.Logf("running test %v", i)202 c.Logf("running test %v", i)
202 envs, err := environs.ReadEnvironsBytes([]byte(t.env))203 envs, err := environs.ReadEnvironsBytes([]byte(t.env))
@@ -206,6 +207,8 @@
206}207}
207208
208func (*suite) TestDefaultConfigFile(c *gc.C) {209func (*suite) TestDefaultConfigFile(c *gc.C) {
210 defer testing.MakeEmptyFakeHome(c).Restore()
211
209 env := `212 env := `
210environments:213environments:
211 only:214 only:
@@ -225,8 +228,8 @@
225 c.Assert(cfg.Name(), gc.Equals, "only")228 c.Assert(cfg.Name(), gc.Equals, "only")
226}229}
227230
228func (s *suite) TestConfigPerm(c *gc.C) {231func (*suite) TestConfigPerm(c *gc.C) {
229 testing.MakeSampleJujuHome(c)232 defer testing.MakeSampleHome(c).Restore()
230233
231 path := testing.HomePath(".juju")234 path := testing.HomePath(".juju")
232 info, err := os.Lstat(path)235 info, err := os.Lstat(path)
@@ -253,6 +256,7 @@
253}256}
254257
255func (*suite) TestNamedConfigFile(c *gc.C) {258func (*suite) TestNamedConfigFile(c *gc.C) {
259 defer testing.MakeFakeHomeNoEnvironments(c, "only").Restore()
256260
257 env := `261 env := `
258environments:262environments:
@@ -279,6 +283,7 @@
279}283}
280284
281func (*suite) TestBootstrapConfig(c *gc.C) {285func (*suite) TestBootstrapConfig(c *gc.C) {
286 defer testing.MakeFakeHomeNoEnvironments(c, "bladaam").Restore()
282 attrs := dummySampleConfig().Merge(testing.Attrs{287 attrs := dummySampleConfig().Merge(testing.Attrs{
283 "agent-version": "1.2.3",288 "agent-version": "1.2.3",
284 })289 })
@@ -405,6 +410,7 @@
405}410}
406411
407func (s *ConfigDeprecationSuite) checkDeprecationWarning(c *gc.C, attrs testing.Attrs, expectedMsg string) {412func (s *ConfigDeprecationSuite) checkDeprecationWarning(c *gc.C, attrs testing.Attrs, expectedMsg string) {
413 defer testing.MakeFakeHomeNoEnvironments(c, "only").Restore()
408 content := `414 content := `
409environments:415environments:
410 deprecated:416 deprecated:
@@ -449,9 +455,3 @@
449 expected := `Provider type \"null\" has been renamed to \"manual\"\.Please update your environment configuration\.`455 expected := `Provider type \"null\" has been renamed to \"manual\"\.Please update your environment configuration\.`
450 s.checkDeprecationWarning(c, attrs, expected)456 s.checkDeprecationWarning(c, attrs, expected)
451}457}
452
453func (s *ConfigDeprecationSuite) TestDeprecatedLxcUseCloneWarning(c *gc.C) {
454 attrs := testing.Attrs{"lxc-use-clone": true}
455 expected := `Config attribute \"lxc-use-clone\" has been renamed to \"lxc-clone\".Please update your environment configuration\.`
456 s.checkDeprecationWarning(c, attrs, expected)
457}
458458
=== modified file 'environs/configstore/disk_test.go'
--- environs/configstore/disk_test.go 2014-05-20 04:27:02 +0000
+++ environs/configstore/disk_test.go 2014-05-22 14:33:28 +0000
@@ -17,7 +17,7 @@
17 gc "launchpad.net/gocheck"17 gc "launchpad.net/gocheck"
1818
19 "launchpad.net/juju-core/environs/configstore"19 "launchpad.net/juju-core/environs/configstore"
20 "launchpad.net/juju-core/testing"20 "launchpad.net/juju-core/testing/testbase"
21)21)
2222
23var _ = gc.Suite(&diskInterfaceSuite{})23var _ = gc.Suite(&diskInterfaceSuite{})
@@ -63,7 +63,7 @@
63var _ = gc.Suite(&diskStoreSuite{})63var _ = gc.Suite(&diskStoreSuite{})
6464
65type diskStoreSuite struct {65type diskStoreSuite struct {
66 testing.BaseSuite66 testbase.LoggingSuite
67}67}
6868
69func (*diskStoreSuite) TestNewDisk(c *gc.C) {69func (*diskStoreSuite) TestNewDisk(c *gc.C) {
7070
=== modified file 'environs/configstore/interface_test.go'
--- environs/configstore/interface_test.go 2014-05-20 04:27:02 +0000
+++ environs/configstore/interface_test.go 2014-05-22 14:33:28 +0000
@@ -8,7 +8,7 @@
8 gc "launchpad.net/gocheck"8 gc "launchpad.net/gocheck"
99
10 "launchpad.net/juju-core/environs/configstore"10 "launchpad.net/juju-core/environs/configstore"
11 "launchpad.net/juju-core/testing"11 "launchpad.net/juju-core/testing/testbase"
12)12)
1313
14// interfaceSuite defines a set of tests on a ConfigStorage14// interfaceSuite defines a set of tests on a ConfigStorage
@@ -16,7 +16,7 @@
16// The NewStore field must be set up to return a ConfigStorage16// The NewStore field must be set up to return a ConfigStorage
17// instance of the type to be tested.17// instance of the type to be tested.
18type interfaceSuite struct {18type interfaceSuite struct {
19 testing.BaseSuite19 testbase.LoggingSuite
20 NewStore func(c *gc.C) configstore.Storage20 NewStore func(c *gc.C) configstore.Storage
21}21}
2222
2323
=== modified file 'environs/emptystorage_test.go'
--- environs/emptystorage_test.go 2014-05-16 01:33:13 +0000
+++ environs/emptystorage_test.go 2014-05-22 14:33:28 +0000
@@ -14,10 +14,11 @@
14 "launchpad.net/juju-core/environs/storage"14 "launchpad.net/juju-core/environs/storage"
15 "launchpad.net/juju-core/provider/dummy"15 "launchpad.net/juju-core/provider/dummy"
16 "launchpad.net/juju-core/testing"16 "launchpad.net/juju-core/testing"
17 "launchpad.net/juju-core/testing/testbase"
17)18)
1819
19type EmptyStorageSuite struct {20type EmptyStorageSuite struct {
20 testing.FakeJujuHomeSuite21 testbase.LoggingSuite
21}22}
2223
23var _ = gc.Suite(&EmptyStorageSuite{})24var _ = gc.Suite(&EmptyStorageSuite{})
@@ -41,7 +42,7 @@
41}42}
4243
43type verifyStorageSuite struct {44type verifyStorageSuite struct {
44 testing.FakeJujuHomeSuite45 testbase.LoggingSuite
45}46}
4647
47var _ = gc.Suite(&verifyStorageSuite{})48var _ = gc.Suite(&verifyStorageSuite{})
@@ -54,17 +55,14 @@
54 authorized-keys: i-am-a-key55 authorized-keys: i-am-a-key
55`56`
5657
57func (s *verifyStorageSuite) SetUpTest(c *gc.C) {
58 s.FakeJujuHomeSuite.SetUpTest(c)
59 testing.WriteEnvironments(c, existingEnv)
60}
61
62func (s *verifyStorageSuite) TearDownTest(c *gc.C) {58func (s *verifyStorageSuite) TearDownTest(c *gc.C) {
63 dummy.Reset()59 dummy.Reset()
64 s.FakeJujuHomeSuite.TearDownTest(c)60 s.LoggingSuite.TearDownTest(c)
65}61}
6662
67func (s *verifyStorageSuite) TestVerifyStorage(c *gc.C) {63func (s *verifyStorageSuite) TestVerifyStorage(c *gc.C) {
64 defer testing.MakeFakeHome(c, existingEnv, "existing").Restore()
65
68 ctx := testing.Context(c)66 ctx := testing.Context(c)
69 environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem())67 environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem())
70 c.Assert(err, gc.IsNil)68 c.Assert(err, gc.IsNil)
@@ -81,6 +79,8 @@
81}79}
8280
83func (s *verifyStorageSuite) TestVerifyStorageFails(c *gc.C) {81func (s *verifyStorageSuite) TestVerifyStorageFails(c *gc.C) {
82 defer testing.MakeFakeHome(c, existingEnv, "existing").Restore()
83
84 ctx := testing.Context(c)84 ctx := testing.Context(c)
85 environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem())85 environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem())
86 c.Assert(err, gc.IsNil)86 c.Assert(err, gc.IsNil)
8787
=== modified file 'environs/httpstorage/backend_test.go'
--- environs/httpstorage/backend_test.go 2014-05-20 04:27:02 +0000
+++ environs/httpstorage/backend_test.go 2014-05-22 14:33:28 +0000
@@ -22,6 +22,7 @@
22 "launchpad.net/juju-core/environs/filestorage"22 "launchpad.net/juju-core/environs/filestorage"
23 "launchpad.net/juju-core/environs/httpstorage"23 "launchpad.net/juju-core/environs/httpstorage"
24 coretesting "launchpad.net/juju-core/testing"24 coretesting "launchpad.net/juju-core/testing"
25 "launchpad.net/juju-core/testing/testbase"
25 "launchpad.net/juju-core/utils"26 "launchpad.net/juju-core/utils"
26)27)
2728
@@ -32,7 +33,7 @@
32}33}
3334
34type backendSuite struct {35type backendSuite struct {
35 coretesting.BaseSuite36 testbase.LoggingSuite
36}37}
3738
38var _ = gc.Suite(&backendSuite{})39var _ = gc.Suite(&backendSuite{})
3940
=== modified file 'environs/imagemetadata/generate_test.go'
--- environs/imagemetadata/generate_test.go 2014-05-20 04:27:02 +0000
+++ environs/imagemetadata/generate_test.go 2014-05-22 14:33:28 +0000
@@ -11,13 +11,13 @@
11 "launchpad.net/juju-core/environs/imagemetadata/testing"11 "launchpad.net/juju-core/environs/imagemetadata/testing"
12 "launchpad.net/juju-core/environs/simplestreams"12 "launchpad.net/juju-core/environs/simplestreams"
13 "launchpad.net/juju-core/environs/storage"13 "launchpad.net/juju-core/environs/storage"
14 coretesting "launchpad.net/juju-core/testing"14 "launchpad.net/juju-core/testing/testbase"
15)15)
1616
17var _ = gc.Suite(&generateSuite{})17var _ = gc.Suite(&generateSuite{})
1818
19type generateSuite struct {19type generateSuite struct {
20 coretesting.BaseSuite20 testbase.LoggingSuite
21}21}
2222
23func assertFetch(c *gc.C, stor storage.Storage, series, arch, region, endpoint, id string) {23func assertFetch(c *gc.C, stor storage.Storage, series, arch, region, endpoint, id string) {
2424
=== modified file 'environs/imagemetadata/marshal_test.go'
--- environs/imagemetadata/marshal_test.go 2014-05-20 04:27:02 +0000
+++ environs/imagemetadata/marshal_test.go 2014-05-22 14:33:28 +0000
@@ -10,13 +10,13 @@
1010
11 "launchpad.net/juju-core/environs/imagemetadata"11 "launchpad.net/juju-core/environs/imagemetadata"
12 "launchpad.net/juju-core/environs/simplestreams"12 "launchpad.net/juju-core/environs/simplestreams"
13 "launchpad.net/juju-core/testing"13 "launchpad.net/juju-core/testing/testbase"
14)14)
1515
16var _ = gc.Suite(&marshalSuite{})16var _ = gc.Suite(&marshalSuite{})
1717
18type marshalSuite struct {18type marshalSuite struct {
19 testing.BaseSuite19 testbase.LoggingSuite
20}20}
2121
22var expectedIndex = `{22var expectedIndex = `{
2323
=== modified file 'environs/imagemetadata/upload_test.go'
--- environs/imagemetadata/upload_test.go 2014-05-20 04:27:02 +0000
+++ environs/imagemetadata/upload_test.go 2014-05-22 14:33:28 +0000
@@ -17,13 +17,13 @@
17 "launchpad.net/juju-core/environs/imagemetadata/testing"17 "launchpad.net/juju-core/environs/imagemetadata/testing"
18 "launchpad.net/juju-core/environs/simplestreams"18 "launchpad.net/juju-core/environs/simplestreams"
19 "launchpad.net/juju-core/environs/storage"19 "launchpad.net/juju-core/environs/storage"
20 coretesting "launchpad.net/juju-core/testing"20 "launchpad.net/juju-core/testing/testbase"
21)21)
2222
23var _ = gc.Suite(&uploadSuite{})23var _ = gc.Suite(&uploadSuite{})
2424
25type uploadSuite struct {25type uploadSuite struct {
26 coretesting.BaseSuite26 testbase.LoggingSuite
27}27}
2828
29func createImageMetadata(c *gc.C) (sourceDir string, destDir string, destStor storage.Storage, metadata *imagemetadata.ImageMetadata) {29func createImageMetadata(c *gc.C) (sourceDir string, destDir string, destStor storage.Storage, metadata *imagemetadata.ImageMetadata) {
3030
=== modified file 'environs/imagemetadata/urls_test.go'
--- environs/imagemetadata/urls_test.go 2014-05-15 05:14:01 +0000
+++ environs/imagemetadata/urls_test.go 2014-05-22 14:33:28 +0000
@@ -15,18 +15,21 @@
15 sstesting "launchpad.net/juju-core/environs/simplestreams/testing"15 sstesting "launchpad.net/juju-core/environs/simplestreams/testing"
16 "launchpad.net/juju-core/provider/dummy"16 "launchpad.net/juju-core/provider/dummy"
17 "launchpad.net/juju-core/testing"17 "launchpad.net/juju-core/testing"
18 coretesting "launchpad.net/juju-core/testing"
19)18)
2019
21type URLsSuite struct {20type URLsSuite struct {
22 coretesting.BaseSuite21 home *testing.FakeHome
23}22}
2423
25var _ = gc.Suite(&URLsSuite{})24var _ = gc.Suite(&URLsSuite{})
2625
26func (s *URLsSuite) SetUpTest(c *gc.C) {
27 s.home = testing.MakeEmptyFakeHome(c)
28}
29
27func (s *URLsSuite) TearDownTest(c *gc.C) {30func (s *URLsSuite) TearDownTest(c *gc.C) {
28 dummy.Reset()31 dummy.Reset()
29 s.BaseSuite.TearDownTest(c)32 s.home.Restore()
30}33}
3134
32func (s *URLsSuite) env(c *gc.C, imageMetadataURL, stream string) environs.Environ {35func (s *URLsSuite) env(c *gc.C, imageMetadataURL, stream string) environs.Environ {
3336
=== modified file 'environs/imagemetadata/validation_test.go'
--- environs/imagemetadata/validation_test.go 2014-05-20 04:27:02 +0000
+++ environs/imagemetadata/validation_test.go 2014-05-22 14:33:28 +0000
@@ -12,12 +12,12 @@
12 "launchpad.net/juju-core/environs/filestorage"12 "launchpad.net/juju-core/environs/filestorage"
13 "launchpad.net/juju-core/environs/imagemetadata"13 "launchpad.net/juju-core/environs/imagemetadata"
14 "launchpad.net/juju-core/environs/simplestreams"14 "launchpad.net/juju-core/environs/simplestreams"
15 "launchpad.net/juju-core/testing"15 "launchpad.net/juju-core/testing/testbase"
16 "launchpad.net/juju-core/utils"16 "launchpad.net/juju-core/utils"
17)17)
1818
19type ValidateSuite struct {19type ValidateSuite struct {
20 testing.BaseSuite20 testbase.LoggingSuite
21 metadataDir string21 metadataDir string
22}22}
2323
@@ -45,7 +45,7 @@
45}45}
4646
47func (s *ValidateSuite) SetUpTest(c *gc.C) {47func (s *ValidateSuite) SetUpTest(c *gc.C) {
48 s.BaseSuite.SetUpTest(c)48 s.LoggingSuite.SetUpTest(c)
49 s.metadataDir = c.MkDir()49 s.metadataDir = c.MkDir()
50}50}
5151
5252
=== modified file 'environs/instances/image.go'
--- environs/instances/image.go 2014-05-16 09:58:00 +0000
+++ environs/instances/image.go 2014-05-22 14:33:28 +0000
@@ -5,7 +5,6 @@
55
6import (6import (
7 "fmt"7 "fmt"
8 "sort"
98
10 "launchpad.net/juju-core/constraints"9 "launchpad.net/juju-core/constraints"
11 "launchpad.net/juju-core/environs/imagemetadata"10 "launchpad.net/juju-core/environs/imagemetadata"
@@ -45,8 +44,6 @@
45type InstanceSpec struct {44type InstanceSpec struct {
46 InstanceType InstanceType45 InstanceType InstanceType
47 Image Image46 Image Image
48 // order is used to sort InstanceSpec based on the input InstanceTypes.
49 order int
50}47}
5148
52// FindInstanceSpec returns an InstanceSpec satisfying the supplied InstanceConstraint.49// FindInstanceSpec returns an InstanceSpec satisfying the supplied InstanceConstraint.
@@ -86,17 +83,13 @@
86 for _, itype := range matchingTypes {83 for _, itype := range matchingTypes {
87 for _, image := range possibleImages {84 for _, image := range possibleImages {
88 if image.match(itype) {85 if image.match(itype) {
89 specs = append(specs, &InstanceSpec{86 specs = append(specs, &InstanceSpec{itype, image})
90 InstanceType: itype,
91 Image: image,
92 order: len(specs),
93 })
94 }87 }
95 }88 }
96 }89 }
97 if len(specs) > 0 {90
98 sort.Sort(byArch(specs))91 if spec := preferredSpec(specs); spec != nil {
99 return specs[0], nil92 return spec, nil
100 }93 }
10194
102 names := make([]string, len(matchingTypes))95 names := make([]string, len(matchingTypes))
@@ -106,39 +99,21 @@
106 return nil, fmt.Errorf("no %q images in %s matching instance types %v", ic.Series, ic.Region, names)99 return nil, fmt.Errorf("no %q images in %s matching instance types %v", ic.Series, ic.Region, names)
107}100}
108101
109// byArch sorts InstanceSpecs first by descending word-size, then102// preferredSpec will if possible return a spec with arch matching that
110// alphabetically by name, and choose the first spec in the sequence.103// of the host machine.
111type byArch []*InstanceSpec104func preferredSpec(specs []*InstanceSpec) *InstanceSpec {
112105 if len(specs) > 1 {
113func (a byArch) Len() int {106 hostArch := arch.HostArch()
114 return len(a)107 for _, spec := range specs {
115}108 if spec.Image.Arch == hostArch {
116109 return spec
117func (a byArch) Less(i, j int) bool {110 }
118 iArchName := a[i].Image.Arch111 }
119 jArchName := a[j].Image.Arch112 }
120 iArch := arch.Info[iArchName]113 if len(specs) > 0 {
121 jArch := arch.Info[jArchName]114 return specs[0]
122 // Wider word-size first.115 }
123 switch {116 return nil
124 case iArch.WordSize > jArch.WordSize:
125 return true
126 case iArch.WordSize < jArch.WordSize:
127 return false
128 }
129 // Alphabetically by arch name.
130 switch {
131 case iArchName < jArchName:
132 return true
133 case iArchName > jArchName:
134 return false
135 }
136 // If word-size and name the same, keep stable.
137 return a[i].order < a[j].order
138}
139
140func (a byArch) Swap(i, j int) {
141 a[i], a[j] = a[j], a[i]
142}117}
143118
144// Image holds the attributes that vary amongst relevant images for119// Image holds the attributes that vary amongst relevant images for
145120
=== modified file 'environs/instances/image_test.go'
--- environs/instances/image_test.go 2014-05-20 04:27:02 +0000
+++ environs/instances/image_test.go 2014-05-22 14:33:28 +0000
@@ -11,12 +11,13 @@
11 "launchpad.net/juju-core/constraints"11 "launchpad.net/juju-core/constraints"
12 "launchpad.net/juju-core/environs/imagemetadata"12 "launchpad.net/juju-core/environs/imagemetadata"
13 "launchpad.net/juju-core/environs/simplestreams"13 "launchpad.net/juju-core/environs/simplestreams"
14 coretesting "launchpad.net/juju-core/testing"14 "launchpad.net/juju-core/juju/arch"
15 "launchpad.net/juju-core/testing/testbase"
15 "launchpad.net/juju-core/utils"16 "launchpad.net/juju-core/utils"
16)17)
1718
18type imageSuite struct {19type imageSuite struct {
19 coretesting.BaseSuite20 testbase.LoggingSuite
20}21}
2122
22func Test(t *testing.T) {23func Test(t *testing.T) {
@@ -90,10 +91,10 @@
90 }91 }
91 }92 }
92 },93 },
93 "com.ubuntu.cloud:server:12.04:armhf": {94 "com.ubuntu.cloud:server:12.04:arm": {
94 "release": "precise",95 "release": "precise",
95 "version": "12.04",96 "version": "12.04",
96 "arch": "armhf",97 "arch": "arm",
97 "versions": {98 "versions": {
98 "20121218": {99 "20121218": {
99 "items": {100 "items": {
@@ -116,57 +117,7 @@
116 "id": "ami-00000036"117 "id": "ami-00000036"
117 }118 }
118 },119 },
119 "pubname": "ubuntu-precise-12.04-armhf-server-20121218",120 "pubname": "ubuntu-precise-12.04-arm-server-20121218",
120 "label": "release"
121 }
122 }
123 },
124 "com.ubuntu.cloud:server:12.04:i386": {
125 "release": "precise",
126 "version": "12.04",
127 "arch": "i386",
128 "versions": {
129 "20121218": {
130 "items": {
131 "apne1pe": {
132 "root_store": "ebs",
133 "virt": "pv",
134 "region": "ap-northeast-1",
135 "id": "ami-b79b09b6"
136 },
137 "test1pe": {
138 "root_store": "ebs",
139 "virt": "pv",
140 "region": "test",
141 "id": "ami-b79b09b7"
142 }
143 },
144 "pubname": "ubuntu-precise-12.04-i386-server-20121218",
145 "label": "release"
146 }
147 }
148 },
149 "com.ubuntu.cloud:server:12.04:ppc64": {
150 "release": "precise",
151 "version": "12.04",
152 "arch": "ppc64",
153 "versions": {
154 "20121218": {
155 "items": {
156 "apne1pe": {
157 "root_store": "ebs",
158 "virt": "pv",
159 "region": "ap-northeast-1",
160 "id": "ami-b79b09b8"
161 },
162 "test1pe": {
163 "root_store": "ebs",
164 "virt": "pv",
165 "region": "test",
166 "id": "ami-b79b09b9"
167 }
168 },
169 "pubname": "ubuntu-precise-12.04-ppc64-server-20121218",
170 "label": "release"121 "label": "release"
171 }122 }
172 }123 }
@@ -216,10 +167,10 @@
216167
217func (p *instanceSpecTestParams) init() {168func (p *instanceSpecTestParams) init() {
218 if p.arches == nil {169 if p.arches == nil {
219 p.arches = []string{"amd64", "armhf"}170 p.arches = []string{"amd64", "arm"}
220 }171 }
221 if p.instanceTypes == nil {172 if p.instanceTypes == nil {
222 p.instanceTypes = []InstanceType{{Id: "1", Name: "it-1", Arches: []string{"amd64", "armhf"}}}173 p.instanceTypes = []InstanceType{{Id: "1", Name: "it-1", Arches: []string{"amd64", "arm"}}}
223 p.instanceTypeId = "1"174 p.instanceTypeId = "1"
224 p.instanceTypeName = "it-1"175 p.instanceTypeName = "it-1"
225 }176 }
@@ -236,42 +187,6 @@
236 },187 },
237 },188 },
238 {189 {
239 desc: "prefer amd64 over i386",
240 region: "test",
241 imageId: "ami-00000033",
242 arches: []string{"amd64", "i386"},
243 instanceTypes: []InstanceType{
244 {Id: "1", Name: "it-1", Arches: []string{"i386", "amd64"}, VirtType: &pv, Mem: 512},
245 },
246 },
247 {
248 desc: "prefer armhf over i386 (first alphabetical wins)",
249 region: "test",
250 imageId: "ami-00000034",
251 arches: []string{"armhf", "i386"},
252 instanceTypes: []InstanceType{
253 {Id: "1", Name: "it-1", Arches: []string{"armhf", "i386"}, VirtType: &pv, Mem: 512},
254 },
255 },
256 {
257 desc: "prefer ppc64 over i386 (64-bit trumps 32-bit, regardless of alphabetical order)",
258 region: "test",
259 imageId: "ami-b79b09b9",
260 arches: []string{"ppc64", "i386"},
261 instanceTypes: []InstanceType{
262 {Id: "1", Name: "it-1", Arches: []string{"i386", "ppc64"}, VirtType: &pv, Mem: 512},
263 },
264 },
265 {
266 desc: "prefer amd64 over arm64 (first 64-bit alphabetical wins)",
267 region: "test",
268 imageId: "ami-00000033",
269 arches: []string{"arm64", "amd64"},
270 instanceTypes: []InstanceType{
271 {Id: "1", Name: "it-1", Arches: []string{"arm64", "amd64"}, VirtType: &pv, Mem: 512},
272 },
273 },
274 {
275 desc: "explicit release stream",190 desc: "explicit release stream",
276 region: "test",191 region: "test",
277 stream: "released",192 stream: "released",
@@ -328,7 +243,7 @@
328 {243 {
329 desc: "no image exists in metadata",244 desc: "no image exists in metadata",
330 region: "invalid-region",245 region: "invalid-region",
331 err: `no "precise" images in invalid-region with arches \[amd64 armhf\]`,246 err: `no "precise" images in invalid-region with arches \[amd64 arm\]`,
332 },247 },
333 {248 {
334 desc: "no valid instance types",249 desc: "no valid instance types",
@@ -392,6 +307,44 @@
392 }307 }
393}308}
394309
310func (s *imageSuite) TestPreferredSpec(c *gc.C) {
311 type prefTest struct {
312 desc string
313 specs []*InstanceSpec
314 expected *InstanceSpec
315 }
316
317 s.PatchValue(&arch.HostArch, func() string { return arch.ARM64 })
318
319 amd64 := &InstanceSpec{Image: Image{Arch: arch.AMD64}}
320 i386 := &InstanceSpec{Image: Image{Arch: arch.I386}}
321 arm64 := &InstanceSpec{Image: Image{Arch: arch.ARM64}}
322
323 prefTests := []prefTest{
324 {
325 "choose hostarch (arm64) over other arches",
326 []*InstanceSpec{i386, arm64, amd64},
327 arm64,
328 },
329 {
330 "choose first image if no arm64",
331 []*InstanceSpec{i386, amd64},
332 i386,
333 },
334 {
335 "choose only image only one there",
336 []*InstanceSpec{amd64},
337 amd64,
338 },
339 }
340
341 for n, test := range prefTests {
342 c.Logf("PreferredSpec test %d: %s", n, test.desc)
343 actual := preferredSpec(test.specs)
344 c.Assert(actual, gc.Equals, test.expected)
345 }
346}
347
395var imageMatchtests = []struct {348var imageMatchtests = []struct {
396 image Image349 image Image
397 itype InstanceType350 itype InstanceType
@@ -403,14 +356,14 @@
403 match: true,356 match: true,
404 }, {357 }, {
405 image: Image{Arch: "amd64"},358 image: Image{Arch: "amd64"},
406 itype: InstanceType{Arches: []string{"amd64", "armhf"}},359 itype: InstanceType{Arches: []string{"amd64", "arm"}},
407 match: true,360 match: true,
408 }, {361 }, {
409 image: Image{Arch: "amd64", VirtType: hvm},362 image: Image{Arch: "amd64", VirtType: hvm},
410 itype: InstanceType{Arches: []string{"amd64"}, VirtType: &hvm},363 itype: InstanceType{Arches: []string{"amd64"}, VirtType: &hvm},
411 match: true,364 match: true,
412 }, {365 }, {
413 image: Image{Arch: "armhf"},366 image: Image{Arch: "arm"},
414 itype: InstanceType{Arches: []string{"amd64"}},367 itype: InstanceType{Arches: []string{"amd64"}},
415 }, {368 }, {
416 image: Image{Arch: "amd64", VirtType: hvm},369 image: Image{Arch: "amd64", VirtType: hvm},
417370
=== modified file 'environs/instances/instancetype_test.go'
--- environs/instances/instancetype_test.go 2014-05-20 04:27:02 +0000
+++ environs/instances/instancetype_test.go 2014-05-22 14:33:28 +0000
@@ -9,11 +9,11 @@
9 gc "launchpad.net/gocheck"9 gc "launchpad.net/gocheck"
1010
11 "launchpad.net/juju-core/constraints"11 "launchpad.net/juju-core/constraints"
12 "launchpad.net/juju-core/testing"12 "launchpad.net/juju-core/testing/testbase"
13)13)
1414
15type instanceTypeSuite struct {15type instanceTypeSuite struct {
16 testing.BaseSuite16 testbase.LoggingSuite
17}17}
1818
19var _ = gc.Suite(&instanceTypeSuite{})19var _ = gc.Suite(&instanceTypeSuite{})
2020
=== modified file 'environs/jujutest/livetests.go'
--- environs/jujutest/livetests.go 2014-05-20 00:11:22 +0000
+++ environs/jujutest/livetests.go 2014-05-22 14:33:28 +0000
@@ -33,6 +33,7 @@
33 "launchpad.net/juju-core/state/api"33 "launchpad.net/juju-core/state/api"
34 statetesting "launchpad.net/juju-core/state/testing"34 statetesting "launchpad.net/juju-core/state/testing"
35 coretesting "launchpad.net/juju-core/testing"35 coretesting "launchpad.net/juju-core/testing"
36 "launchpad.net/juju-core/testing/testbase"
36 coretools "launchpad.net/juju-core/tools"37 coretools "launchpad.net/juju-core/tools"
37 "launchpad.net/juju-core/utils"38 "launchpad.net/juju-core/utils"
38 "launchpad.net/juju-core/version"39 "launchpad.net/juju-core/version"
@@ -42,6 +43,7 @@
42// (e.g. Amazon EC2). The Environ is opened once only for all the tests43// (e.g. Amazon EC2). The Environ is opened once only for all the tests
43// in the suite, stored in Env, and Destroyed after the suite has completed.44// in the suite, stored in Env, and Destroyed after the suite has completed.
44type LiveTests struct {45type LiveTests struct {
46 testbase.LoggingSuite
45 envtesting.ToolsFixture47 envtesting.ToolsFixture
4648
47 // TestConfig contains the configuration attributes for opening an environment.49 // TestConfig contains the configuration attributes for opening an environment.
@@ -73,9 +75,15 @@
73}75}
7476
75func (t *LiveTests) SetUpSuite(c *gc.C) {77func (t *LiveTests) SetUpSuite(c *gc.C) {
78 t.LoggingSuite.SetUpSuite(c)
76 t.ConfigStore = configstore.NewMem()79 t.ConfigStore = configstore.NewMem()
77}80}
7881
82func (t *LiveTests) SetUpTest(c *gc.C) {
83 t.LoggingSuite.SetUpTest(c)
84 t.ToolsFixture.SetUpTest(c)
85}
86
79func publicAttrs(e environs.Environ) map[string]interface{} {87func publicAttrs(e environs.Environ) map[string]interface{} {
80 cfg := e.Config()88 cfg := e.Config()
81 secrets, err := e.Provider().SecretAttrs(cfg)89 secrets, err := e.Provider().SecretAttrs(cfg)
@@ -93,6 +101,12 @@
93 if t.Env != nil {101 if t.Env != nil {
94 t.Destroy(c)102 t.Destroy(c)
95 }103 }
104 t.LoggingSuite.TearDownSuite(c)
105}
106
107func (t *LiveTests) TearDownTest(c *gc.C) {
108 t.ToolsFixture.TearDownTest(c)
109 t.LoggingSuite.TearDownTest(c)
96}110}
97111
98// PrepareOnce ensures that the environment is112// PrepareOnce ensures that the environment is
@@ -122,7 +136,7 @@
122 _, err := sync.Upload(t.Env.Storage(), nil, coretesting.FakeDefaultSeries)136 _, err := sync.Upload(t.Env.Storage(), nil, coretesting.FakeDefaultSeries)
123 c.Assert(err, gc.IsNil)137 c.Assert(err, gc.IsNil)
124 }138 }
125 t.UploadFakeTools(c, t.Env.Storage())139 envtesting.UploadFakeTools(c, t.Env.Storage())
126 err := bootstrap.EnsureNotBootstrapped(t.Env)140 err := bootstrap.EnsureNotBootstrapped(t.Env)
127 c.Assert(err, gc.IsNil)141 c.Assert(err, gc.IsNil)
128 err = bootstrap.Bootstrap(coretesting.Context(c), t.Env, environs.BootstrapParams{Constraints: cons})142 err = bootstrap.Bootstrap(coretesting.Context(c), t.Env, environs.BootstrapParams{Constraints: cons})
@@ -157,7 +171,7 @@
157// that it does not assume a pristine environment.171// that it does not assume a pristine environment.
158func (t *LiveTests) TestStartStop(c *gc.C) {172func (t *LiveTests) TestStartStop(c *gc.C) {
159 t.PrepareOnce(c)173 t.PrepareOnce(c)
160 t.UploadFakeTools(c, t.Env.Storage())174 envtesting.UploadFakeTools(c, t.Env.Storage())
161175
162 inst, _ := testing.AssertStartInstance(c, t.Env, "0")176 inst, _ := testing.AssertStartInstance(c, t.Env, "0")
163 c.Assert(inst, gc.NotNil)177 c.Assert(inst, gc.NotNil)
@@ -211,7 +225,7 @@
211225
212func (t *LiveTests) TestPorts(c *gc.C) {226func (t *LiveTests) TestPorts(c *gc.C) {
213 t.PrepareOnce(c)227 t.PrepareOnce(c)
214 t.UploadFakeTools(c, t.Env.Storage())228 envtesting.UploadFakeTools(c, t.Env.Storage())
215229
216 inst1, _ := testing.AssertStartInstance(c, t.Env, "1")230 inst1, _ := testing.AssertStartInstance(c, t.Env, "1")
217 c.Assert(inst1, gc.NotNil)231 c.Assert(inst1, gc.NotNil)
@@ -300,7 +314,7 @@
300314
301func (t *LiveTests) TestGlobalPorts(c *gc.C) {315func (t *LiveTests) TestGlobalPorts(c *gc.C) {
302 t.PrepareOnce(c)316 t.PrepareOnce(c)
303 t.UploadFakeTools(c, t.Env.Storage())317 envtesting.UploadFakeTools(c, t.Env.Storage())
304318
305 // Change configuration.319 // Change configuration.
306 oldConfig := t.Env.Config()320 oldConfig := t.Env.Config()
307321
=== modified file 'environs/jujutest/tests.go'
--- environs/jujutest/tests.go 2014-05-19 09:06:00 +0000
+++ environs/jujutest/tests.go 2014-05-22 14:33:28 +0000
@@ -22,6 +22,7 @@
22 "launchpad.net/juju-core/instance"22 "launchpad.net/juju-core/instance"
23 "launchpad.net/juju-core/juju/testing"23 "launchpad.net/juju-core/juju/testing"
24 coretesting "launchpad.net/juju-core/testing"24 coretesting "launchpad.net/juju-core/testing"
25 "launchpad.net/juju-core/testing/testbase"
25 "launchpad.net/juju-core/utils"26 "launchpad.net/juju-core/utils"
26 "launchpad.net/juju-core/version"27 "launchpad.net/juju-core/version"
27)28)
@@ -32,6 +33,7 @@
32// is opened once for each test, and some potentially expensive operations33// is opened once for each test, and some potentially expensive operations
33// may be executed.34// may be executed.
34type Tests struct {35type Tests struct {
36 testbase.LoggingSuite
35 TestConfig coretesting.Attrs37 TestConfig coretesting.Attrs
36 envtesting.ToolsFixture38 envtesting.ToolsFixture
3739
@@ -64,17 +66,19 @@
64}66}
6567
66func (t *Tests) SetUpTest(c *gc.C) {68func (t *Tests) SetUpTest(c *gc.C) {
69 t.LoggingSuite.SetUpTest(c)
67 t.ToolsFixture.SetUpTest(c)70 t.ToolsFixture.SetUpTest(c)
68 t.ConfigStore = configstore.NewMem()71 t.ConfigStore = configstore.NewMem()
69}72}
7073
71func (t *Tests) TearDownTest(c *gc.C) {74func (t *Tests) TearDownTest(c *gc.C) {
72 t.ToolsFixture.TearDownTest(c)75 t.ToolsFixture.TearDownTest(c)
76 t.LoggingSuite.TearDownTest(c)
73}77}
7478
75func (t *Tests) TestStartStop(c *gc.C) {79func (t *Tests) TestStartStop(c *gc.C) {
76 e := t.Prepare(c)80 e := t.Prepare(c)
77 t.UploadFakeTools(c, e.Storage())81 envtesting.UploadFakeTools(c, e.Storage())
78 cfg, err := e.Config().Apply(map[string]interface{}{82 cfg, err := e.Config().Apply(map[string]interface{}{
79 "agent-version": version.Current.Number.String(),83 "agent-version": version.Current.Number.String(),
80 })84 })
@@ -125,7 +129,7 @@
125129
126func (t *Tests) TestBootstrap(c *gc.C) {130func (t *Tests) TestBootstrap(c *gc.C) {
127 e := t.Prepare(c)131 e := t.Prepare(c)
128 t.UploadFakeTools(c, e.Storage())132 envtesting.UploadFakeTools(c, e.Storage())
129 err := bootstrap.EnsureNotBootstrapped(e)133 err := bootstrap.EnsureNotBootstrapped(e)
130 c.Assert(err, gc.IsNil)134 c.Assert(err, gc.IsNil)
131 err = bootstrap.Bootstrap(coretesting.Context(c), e, environs.BootstrapParams{})135 err = bootstrap.Bootstrap(coretesting.Context(c), e, environs.BootstrapParams{})
@@ -139,7 +143,7 @@
139 c.Assert(err, gc.ErrorMatches, "environment is already bootstrapped")143 c.Assert(err, gc.ErrorMatches, "environment is already bootstrapped")
140144
141 e2 := t.Open(c)145 e2 := t.Open(c)
142 t.UploadFakeTools(c, e2.Storage())146 envtesting.UploadFakeTools(c, e2.Storage())
143 err = bootstrap.EnsureNotBootstrapped(e2)147 err = bootstrap.EnsureNotBootstrapped(e2)
144 c.Assert(err, gc.ErrorMatches, "environment is already bootstrapped")148 c.Assert(err, gc.ErrorMatches, "environment is already bootstrapped")
145149
@@ -152,7 +156,7 @@
152156
153 // Prepare again because Destroy invalidates old environments.157 // Prepare again because Destroy invalidates old environments.
154 e3 := t.Prepare(c)158 e3 := t.Prepare(c)
155 t.UploadFakeTools(c, e3.Storage())159 envtesting.UploadFakeTools(c, e3.Storage())
156160
157 err = bootstrap.EnsureNotBootstrapped(e3)161 err = bootstrap.EnsureNotBootstrapped(e3)
158 c.Assert(err, gc.IsNil)162 c.Assert(err, gc.IsNil)
159163
=== modified file 'environs/manual/addresses_test.go'
--- environs/manual/addresses_test.go 2014-05-20 04:27:02 +0000
+++ environs/manual/addresses_test.go 2014-05-22 14:33:28 +0000
@@ -10,7 +10,7 @@
1010
11 "launchpad.net/juju-core/environs/manual"11 "launchpad.net/juju-core/environs/manual"
12 "launchpad.net/juju-core/instance"12 "launchpad.net/juju-core/instance"
13 "launchpad.net/juju-core/testing"13 "launchpad.net/juju-core/testing/testbase"
14)14)
1515
16const (16const (
@@ -19,7 +19,7 @@
19)19)
2020
21type addressesSuite struct {21type addressesSuite struct {
22 testing.BaseSuite22 testbase.LoggingSuite
23 netLookupHostCalled int23 netLookupHostCalled int
24}24}
2525
2626
=== modified file 'environs/manual/init_test.go'
--- environs/manual/init_test.go 2014-05-20 04:27:02 +0000
+++ environs/manual/init_test.go 2014-05-22 14:33:28 +0000
@@ -10,11 +10,11 @@
10 gc "launchpad.net/gocheck"10 gc "launchpad.net/gocheck"
1111
12 "launchpad.net/juju-core/environs/manual"12 "launchpad.net/juju-core/environs/manual"
13 "launchpad.net/juju-core/testing"13 "launchpad.net/juju-core/testing/testbase"
14)14)
1515
16type initialisationSuite struct {16type initialisationSuite struct {
17 testing.BaseSuite17 testbase.LoggingSuite
18}18}
1919
20var _ = gc.Suite(&initialisationSuite{})20var _ = gc.Suite(&initialisationSuite{})
2121
=== modified file 'environs/open_test.go'
--- environs/open_test.go 2014-05-16 01:33:13 +0000
+++ environs/open_test.go 2014-05-22 14:33:28 +0000
@@ -18,23 +18,18 @@
18 envtesting "launchpad.net/juju-core/environs/testing"18 envtesting "launchpad.net/juju-core/environs/testing"
19 "launchpad.net/juju-core/provider/dummy"19 "launchpad.net/juju-core/provider/dummy"
20 "launchpad.net/juju-core/testing"20 "launchpad.net/juju-core/testing"
21 "launchpad.net/juju-core/testing/testbase"
21)22)
2223
23type OpenSuite struct {24type OpenSuite struct {
24 testing.FakeJujuHomeSuite25 testbase.LoggingSuite
25 envtesting.ToolsFixture26 envtesting.ToolsFixture
26}27}
2728
28var _ = gc.Suite(&OpenSuite{})29var _ = gc.Suite(&OpenSuite{})
2930
30func (s *OpenSuite) SetUpTest(c *gc.C) {31func (*OpenSuite) TearDownTest(c *gc.C) {
31 s.FakeJujuHomeSuite.SetUpTest(c)
32 testing.WriteEnvironments(c, testing.MultipleEnvConfigNoDefault)
33}
34
35func (s *OpenSuite) TearDownTest(c *gc.C) {
36 dummy.Reset()32 dummy.Reset()
37 s.FakeJujuHomeSuite.TearDownTest(c)
38}33}
3934
40func (*OpenSuite) TestNewDummyEnviron(c *gc.C) {35func (*OpenSuite) TestNewDummyEnviron(c *gc.C) {
@@ -59,6 +54,7 @@
59}54}
6055
61func (*OpenSuite) TestNewFromName(c *gc.C) {56func (*OpenSuite) TestNewFromName(c *gc.C) {
57 defer testing.MakeFakeHome(c, testing.MultipleEnvConfigNoDefault, testing.SampleCertName).Restore()
62 store := configstore.NewMem()58 store := configstore.NewMem()
63 ctx := testing.Context(c)59 ctx := testing.Context(c)
64 e, err := environs.PrepareFromName("erewhemos", ctx, store)60 e, err := environs.PrepareFromName("erewhemos", ctx, store)
@@ -70,6 +66,7 @@
70}66}
7167
72func (*OpenSuite) TestNewFromNameWithInvalidInfo(c *gc.C) {68func (*OpenSuite) TestNewFromNameWithInvalidInfo(c *gc.C) {
69 defer testing.MakeFakeHome(c, testing.MultipleEnvConfigNoDefault, testing.SampleCertName).Restore()
73 store := configstore.NewMem()70 store := configstore.NewMem()
74 cfg, _, err := environs.ConfigForName("erewhemos", store)71 cfg, _, err := environs.ConfigForName("erewhemos", store)
75 c.Assert(err, gc.IsNil)72 c.Assert(err, gc.IsNil)
@@ -89,6 +86,7 @@
89}86}
9087
91func (*OpenSuite) TestNewFromNameWithInvalidEnvironConfig(c *gc.C) {88func (*OpenSuite) TestNewFromNameWithInvalidEnvironConfig(c *gc.C) {
89 defer testing.MakeFakeHome(c, testing.MultipleEnvConfigNoDefault, testing.SampleCertName).Restore()
92 store := configstore.NewMem()90 store := configstore.NewMem()
9391
94 e, err := environs.NewFromName("erewhemos", store)92 e, err := environs.NewFromName("erewhemos", store)
@@ -97,6 +95,7 @@
97}95}
9896
99func (*OpenSuite) TestPrepareFromName(c *gc.C) {97func (*OpenSuite) TestPrepareFromName(c *gc.C) {
98 defer testing.MakeFakeHome(c, testing.MultipleEnvConfigNoDefault, testing.SampleCertName).Restore()
100 ctx := testing.Context(c)99 ctx := testing.Context(c)
101 e, err := environs.PrepareFromName("erewhemos", ctx, configstore.NewMem())100 e, err := environs.PrepareFromName("erewhemos", ctx, configstore.NewMem())
102 c.Assert(err, gc.IsNil)101 c.Assert(err, gc.IsNil)
@@ -106,6 +105,7 @@
106}105}
107106
108func (*OpenSuite) TestConfigForName(c *gc.C) {107func (*OpenSuite) TestConfigForName(c *gc.C) {
108 defer testing.MakeFakeHome(c, testing.MultipleEnvConfigNoDefault, testing.SampleCertName).Restore()
109 cfg, source, err := environs.ConfigForName("erewhemos", configstore.NewMem())109 cfg, source, err := environs.ConfigForName("erewhemos", configstore.NewMem())
110 c.Assert(err, gc.IsNil)110 c.Assert(err, gc.IsNil)
111 c.Assert(source, gc.Equals, environs.ConfigFromEnvirons)111 c.Assert(source, gc.Equals, environs.ConfigFromEnvirons)
@@ -113,6 +113,7 @@
113}113}
114114
115func (*OpenSuite) TestConfigForNameNoDefault(c *gc.C) {115func (*OpenSuite) TestConfigForNameNoDefault(c *gc.C) {
116 defer testing.MakeFakeHome(c, testing.MultipleEnvConfigNoDefault, testing.SampleCertName).Restore()
116 cfg, source, err := environs.ConfigForName("", configstore.NewMem())117 cfg, source, err := environs.ConfigForName("", configstore.NewMem())
117 c.Assert(err, gc.ErrorMatches, "no default environment found")118 c.Assert(err, gc.ErrorMatches, "no default environment found")
118 c.Assert(cfg, gc.IsNil)119 c.Assert(cfg, gc.IsNil)
@@ -120,7 +121,7 @@
120}121}
121122
122func (*OpenSuite) TestConfigForNameDefault(c *gc.C) {123func (*OpenSuite) TestConfigForNameDefault(c *gc.C) {
123 testing.WriteEnvironments(c, testing.SingleEnvConfig)124 defer testing.MakeFakeHome(c, testing.SingleEnvConfig, testing.SampleCertName).Restore()
124 cfg, source, err := environs.ConfigForName("", configstore.NewMem())125 cfg, source, err := environs.ConfigForName("", configstore.NewMem())
125 c.Assert(err, gc.IsNil)126 c.Assert(err, gc.IsNil)
126 c.Assert(cfg.Name(), gc.Equals, "erewhemos")127 c.Assert(cfg.Name(), gc.Equals, "erewhemos")
@@ -128,7 +129,7 @@
128}129}
129130
130func (*OpenSuite) TestConfigForNameFromInfo(c *gc.C) {131func (*OpenSuite) TestConfigForNameFromInfo(c *gc.C) {
131 testing.WriteEnvironments(c, testing.SingleEnvConfig)132 defer testing.MakeFakeHome(c, testing.SingleEnvConfig, testing.SampleCertName).Restore()
132 store := configstore.NewMem()133 store := configstore.NewMem()
133 cfg, source, err := environs.ConfigForName("", store)134 cfg, source, err := environs.ConfigForName("", store)
134 c.Assert(err, gc.IsNil)135 c.Assert(err, gc.IsNil)
@@ -325,23 +326,17 @@
325 authorized-keys: i-am-a-key326 authorized-keys: i-am-a-key
326`327`
327328
328type checkEnvironmentSuite struct {329type checkEnvironmentSuite struct{}
329 testing.FakeJujuHomeSuite
330}
331330
332var _ = gc.Suite(&checkEnvironmentSuite{})331var _ = gc.Suite(&checkEnvironmentSuite{})
333332
334func (s *checkEnvironmentSuite) SetUpTest(c *gc.C) {
335 s.FakeJujuHomeSuite.SetUpTest(c)
336 testing.WriteEnvironments(c, checkEnv)
337}
338
339func (s *checkEnvironmentSuite) TearDownTest(c *gc.C) {333func (s *checkEnvironmentSuite) TearDownTest(c *gc.C) {
340 dummy.Reset()334 dummy.Reset()
341 s.FakeJujuHomeSuite.TearDownTest(c)
342}335}
343336
344func (s *checkEnvironmentSuite) TestCheckEnvironment(c *gc.C) {337func (s *checkEnvironmentSuite) TestCheckEnvironment(c *gc.C) {
338 defer testing.MakeFakeHome(c, checkEnv, "existing").Restore()
339
345 ctx := testing.Context(c)340 ctx := testing.Context(c)
346 environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem())341 environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem())
347 c.Assert(err, gc.IsNil)342 c.Assert(err, gc.IsNil)
@@ -356,6 +351,8 @@
356}351}
357352
358func (s *checkEnvironmentSuite) TestCheckEnvironmentFileNotFound(c *gc.C) {353func (s *checkEnvironmentSuite) TestCheckEnvironmentFileNotFound(c *gc.C) {
354 defer testing.MakeFakeHome(c, checkEnv, "existing").Restore()
355
359 ctx := testing.Context(c)356 ctx := testing.Context(c)
360 environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem())357 environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem())
361 c.Assert(err, gc.IsNil)358 c.Assert(err, gc.IsNil)
@@ -376,6 +373,8 @@
376}373}
377374
378func (s *checkEnvironmentSuite) TestCheckEnvironmentGetFails(c *gc.C) {375func (s *checkEnvironmentSuite) TestCheckEnvironmentGetFails(c *gc.C) {
376 defer testing.MakeFakeHome(c, checkEnv, "existing").Restore()
377
379 ctx := testing.Context(c)378 ctx := testing.Context(c)
380 environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem())379 environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem())
381 c.Assert(err, gc.IsNil)380 c.Assert(err, gc.IsNil)
@@ -395,6 +394,8 @@
395}394}
396395
397func (s *checkEnvironmentSuite) TestCheckEnvironmentBadContent(c *gc.C) {396func (s *checkEnvironmentSuite) TestCheckEnvironmentBadContent(c *gc.C) {
397 defer testing.MakeFakeHome(c, checkEnv, "existing").Restore()
398
398 ctx := testing.Context(c)399 ctx := testing.Context(c)
399 environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem())400 environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem())
400 c.Assert(err, gc.IsNil)401 c.Assert(err, gc.IsNil)
401402
=== modified file 'environs/simplestreams/testing/testing.go'
--- environs/simplestreams/testing/testing.go 2014-05-20 04:27:02 +0000
+++ environs/simplestreams/testing/testing.go 2014-05-22 14:33:28 +0000
@@ -13,7 +13,7 @@
1313
14 "launchpad.net/juju-core/environs/jujutest"14 "launchpad.net/juju-core/environs/jujutest"
15 "launchpad.net/juju-core/environs/simplestreams"15 "launchpad.net/juju-core/environs/simplestreams"
16 "launchpad.net/juju-core/testing"16 "launchpad.net/juju-core/testing/testbase"
17 "launchpad.net/juju-core/version/ubuntu"17 "launchpad.net/juju-core/version/ubuntu"
18)18)
1919
@@ -506,7 +506,7 @@
506}506}
507507
508type LocalLiveSimplestreamsSuite struct {508type LocalLiveSimplestreamsSuite struct {
509 testing.BaseSuite509 testbase.LoggingSuite
510 Source simplestreams.DataSource510 Source simplestreams.DataSource
511 RequireSigned bool511 RequireSigned bool
512 DataType string512 DataType string
@@ -514,11 +514,11 @@
514}514}
515515
516func (s *LocalLiveSimplestreamsSuite) SetUpSuite(c *gc.C) {516func (s *LocalLiveSimplestreamsSuite) SetUpSuite(c *gc.C) {
517 s.BaseSuite.SetUpSuite(c)517 s.LoggingSuite.SetUpSuite(c)
518}518}
519519
520func (s *LocalLiveSimplestreamsSuite) TearDownSuite(c *gc.C) {520func (s *LocalLiveSimplestreamsSuite) TearDownSuite(c *gc.C) {
521 s.BaseSuite.TearDownSuite(c)521 s.LoggingSuite.TearDownSuite(c)
522}522}
523523
524const (524const (
525525
=== modified file 'environs/sshstorage/storage_test.go'
--- environs/sshstorage/storage_test.go 2014-05-20 04:27:02 +0000
+++ environs/sshstorage/storage_test.go 2014-05-22 14:33:28 +0000
@@ -22,13 +22,13 @@
22 gc "launchpad.net/gocheck"22 gc "launchpad.net/gocheck"
2323
24 "launchpad.net/juju-core/environs/storage"24 "launchpad.net/juju-core/environs/storage"
25 coretesting "launchpad.net/juju-core/testing"25 "launchpad.net/juju-core/testing/testbase"
26 "launchpad.net/juju-core/utils"26 "launchpad.net/juju-core/utils"
27 "launchpad.net/juju-core/utils/ssh"27 "launchpad.net/juju-core/utils/ssh"
28)28)
2929
30type storageSuite struct {30type storageSuite struct {
31 coretesting.BaseSuite31 testbase.LoggingSuite
32 bin string32 bin string
33}33}
3434
@@ -56,7 +56,7 @@
56var flockBin string56var flockBin string
5757
58func (s *storageSuite) SetUpSuite(c *gc.C) {58func (s *storageSuite) SetUpSuite(c *gc.C) {
59 s.BaseSuite.SetUpSuite(c)59 s.LoggingSuite.SetUpSuite(c)
6060
61 var err error61 var err error
62 flockBin, err = exec.LookPath("flock")62 flockBin, err = exec.LookPath("flock")
6363
=== modified file 'environs/storage/storage_test.go'
--- environs/storage/storage_test.go 2014-05-16 01:33:13 +0000
+++ environs/storage/storage_test.go 2014-05-22 14:33:28 +0000
@@ -27,7 +27,7 @@
27var _ = gc.Suite(&datasourceSuite{})27var _ = gc.Suite(&datasourceSuite{})
2828
29type datasourceSuite struct {29type datasourceSuite struct {
30 testing.FakeJujuHomeSuite30 home *testing.FakeHome
31 stor storage.Storage31 stor storage.Storage
32 baseURL string32 baseURL string
33}33}
@@ -41,8 +41,7 @@
41`41`
4242
43func (s *datasourceSuite) SetUpTest(c *gc.C) {43func (s *datasourceSuite) SetUpTest(c *gc.C) {
44 s.FakeJujuHomeSuite.SetUpTest(c)44 s.home = testing.MakeFakeHome(c, existingEnv, "existing")
45 testing.WriteEnvironments(c, existingEnv)
46 environ, err := environs.PrepareFromName("test", testing.Context(c), configstore.NewMem())45 environ, err := environs.PrepareFromName("test", testing.Context(c), configstore.NewMem())
47 c.Assert(err, gc.IsNil)46 c.Assert(err, gc.IsNil)
48 s.stor = environ.Storage()47 s.stor = environ.Storage()
@@ -52,7 +51,7 @@
5251
53func (s *datasourceSuite) TearDownTest(c *gc.C) {52func (s *datasourceSuite) TearDownTest(c *gc.C) {
54 dummy.Reset()53 dummy.Reset()
55 s.FakeJujuHomeSuite.TearDownTest(c)54 s.home.Restore()
56}55}
5756
58func (s *datasourceSuite) TestFetch(c *gc.C) {57func (s *datasourceSuite) TestFetch(c *gc.C) {
5958
=== modified file 'environs/sync/sync_test.go'
--- environs/sync/sync_test.go 2014-05-20 00:01:25 +0000
+++ environs/sync/sync_test.go 2014-05-22 14:33:28 +0000
@@ -40,7 +40,7 @@
40}40}
4141
42type syncSuite struct {42type syncSuite struct {
43 coretesting.FakeJujuHomeSuite43 testbase.LoggingSuite
44 envtesting.ToolsFixture44 envtesting.ToolsFixture
45 targetEnv environs.Environ45 targetEnv environs.Environ
46 origVersion version.Binary46 origVersion version.Binary
@@ -53,21 +53,21 @@
53var _ = gc.Suite(&badBuildSuite{})53var _ = gc.Suite(&badBuildSuite{})
5454
55func (s *syncSuite) setUpTest(c *gc.C) {55func (s *syncSuite) setUpTest(c *gc.C) {
56 s.FakeJujuHomeSuite.SetUpTest(c)56 s.LoggingSuite.SetUpTest(c)
57 s.ToolsFixture.SetUpTest(c)57 s.ToolsFixture.SetUpTest(c)
58 s.origVersion = version.Current58 s.origVersion = version.Current
59 // It's important that this be v1.8.x to match the test data.59 // It's important that this be v1.8.x to match the test data.
60 version.Current.Number = version.MustParse("1.8.3")60 version.Current.Number = version.MustParse("1.8.3")
6161
62 // Create a target environments.yaml.62 // Create a target environments.yaml.
63 envConfig := `63 fakeHome := coretesting.MakeFakeHome(c, `
64environments:64environments:
65 test-target:65 test-target:
66 type: dummy66 type: dummy
67 state-server: false67 state-server: false
68 authorized-keys: "not-really-one"68 authorized-keys: "not-really-one"
69`69`)
70 coretesting.WriteEnvironments(c, envConfig)70 s.AddCleanup(func(*gc.C) { fakeHome.Restore() })
71 var err error71 var err error
72 s.targetEnv, err = environs.PrepareFromName("test-target", coretesting.Context(c), configstore.NewMem())72 s.targetEnv, err = environs.PrepareFromName("test-target", coretesting.Context(c), configstore.NewMem())
73 c.Assert(err, gc.IsNil)73 c.Assert(err, gc.IsNil)
@@ -100,7 +100,7 @@
100 dummy.Reset()100 dummy.Reset()
101 version.Current = s.origVersion101 version.Current = s.origVersion
102 s.ToolsFixture.TearDownTest(c)102 s.ToolsFixture.TearDownTest(c)
103 s.FakeJujuHomeSuite.TearDownTest(c)103 s.LoggingSuite.TearDownTest(c)
104}104}
105105
106var tests = []struct {106var tests = []struct {
@@ -255,12 +255,12 @@
255255
256type uploadSuite struct {256type uploadSuite struct {
257 env environs.Environ257 env environs.Environ
258 coretesting.FakeJujuHomeSuite258 testbase.LoggingSuite
259 envtesting.ToolsFixture259 envtesting.ToolsFixture
260}260}
261261
262func (s *uploadSuite) SetUpTest(c *gc.C) {262func (s *uploadSuite) SetUpTest(c *gc.C) {
263 s.FakeJujuHomeSuite.SetUpTest(c)263 s.LoggingSuite.SetUpTest(c)
264 s.ToolsFixture.SetUpTest(c)264 s.ToolsFixture.SetUpTest(c)
265 // We only want to use simplestreams to find any synced tools.265 // We only want to use simplestreams to find any synced tools.
266 cfg, err := config.New(config.NoDefaults, dummy.SampleConfig())266 cfg, err := config.New(config.NoDefaults, dummy.SampleConfig())
@@ -272,7 +272,7 @@
272func (s *uploadSuite) TearDownTest(c *gc.C) {272func (s *uploadSuite) TearDownTest(c *gc.C) {
273 dummy.Reset()273 dummy.Reset()
274 s.ToolsFixture.TearDownTest(c)274 s.ToolsFixture.TearDownTest(c)
275 s.FakeJujuHomeSuite.TearDownTest(c)275 s.LoggingSuite.TearDownTest(c)
276}276}
277277
278func (s *uploadSuite) TestUpload(c *gc.C) {278func (s *uploadSuite) TestUpload(c *gc.C) {
279279
=== modified file 'environs/testing/tools.go'
--- environs/testing/tools.go 2014-05-19 06:06:35 +0000
+++ environs/testing/tools.go 2014-05-22 14:33:28 +0000
@@ -30,11 +30,6 @@
30type ToolsFixture struct {30type ToolsFixture struct {
31 origDefaultURL string31 origDefaultURL string
32 DefaultBaseURL string32 DefaultBaseURL string
33
34 // UploadArches holds the architectures of tools to
35 // upload in UploadFakeTools. If empty, it will default
36 // to just version.Current.Arch.
37 UploadArches []string
38}33}
3934
40func (s *ToolsFixture) SetUpTest(c *gc.C) {35func (s *ToolsFixture) SetUpTest(c *gc.C) {
@@ -46,26 +41,6 @@
46 envtools.DefaultBaseURL = s.origDefaultURL41 envtools.DefaultBaseURL = s.origDefaultURL
47}42}
4843
49// UploadFakeTools uploads fake tools of the architectures in
50// s.UploadArches for each LTS release to the specified storage.
51func (s *ToolsFixture) UploadFakeTools(c *gc.C, stor storage.Storage) {
52 arches := s.UploadArches
53 if len(arches) == 0 {
54 arches = []string{version.Current.Arch}
55 }
56 var versions []version.Binary
57 for _, arch := range arches {
58 v := version.Current
59 v.Arch = arch
60 for _, series := range bootstrap.ToolsLtsSeries {
61 v.Series = series
62 versions = append(versions, v)
63 }
64 }
65 _, err := UploadFakeToolsVersions(stor, versions...)
66 c.Assert(err, gc.IsNil)
67}
68
69// RemoveFakeToolsMetadata deletes the fake simplestreams tools metadata from the supplied storage.44// RemoveFakeToolsMetadata deletes the fake simplestreams tools metadata from the supplied storage.
70func RemoveFakeToolsMetadata(c *gc.C, stor storage.Storage) {45func RemoveFakeToolsMetadata(c *gc.C, stor storage.Storage) {
71 files := []string{simplestreams.UnsignedIndex, envtools.ProductMetadataPath}46 files := []string{simplestreams.UnsignedIndex, envtools.ProductMetadataPath}
7247
=== modified file 'environs/tools/build_test.go'
--- environs/tools/build_test.go 2014-05-20 04:27:02 +0000
+++ environs/tools/build_test.go 2014-05-22 14:33:28 +0000
@@ -12,11 +12,11 @@
12 gc "launchpad.net/gocheck"12 gc "launchpad.net/gocheck"
1313
14 "launchpad.net/juju-core/environs/tools"14 "launchpad.net/juju-core/environs/tools"
15 "launchpad.net/juju-core/testing"15 "launchpad.net/juju-core/testing/testbase"
16)16)
1717
18type buildSuite struct {18type buildSuite struct {
19 testing.BaseSuite19 testbase.LoggingSuite
20 restore func()20 restore func()
21 cwd string21 cwd string
22 filePath string22 filePath string
@@ -25,7 +25,7 @@
25var _ = gc.Suite(&buildSuite{})25var _ = gc.Suite(&buildSuite{})
2626
27func (b *buildSuite) SetUpTest(c *gc.C) {27func (b *buildSuite) SetUpTest(c *gc.C) {
28 b.BaseSuite.SetUpTest(c)28 b.LoggingSuite.SetUpTest(c)
2929
30 dir1 := c.MkDir()30 dir1 := c.MkDir()
31 dir2 := c.MkDir()31 dir2 := c.MkDir()
@@ -59,7 +59,7 @@
5959
60func (b *buildSuite) TearDownTest(c *gc.C) {60func (b *buildSuite) TearDownTest(c *gc.C) {
61 b.restore()61 b.restore()
62 b.BaseSuite.TearDownTest(c)62 b.LoggingSuite.TearDownTest(c)
63}63}
6464
65func (b *buildSuite) TestFindExecutable(c *gc.C) {65func (b *buildSuite) TestFindExecutable(c *gc.C) {
6666
=== modified file 'environs/tools/storage_test.go'
--- environs/tools/storage_test.go 2014-05-20 04:27:02 +0000
+++ environs/tools/storage_test.go 2014-05-22 14:33:28 +0000
@@ -13,21 +13,21 @@
13 envtools "launchpad.net/juju-core/environs/tools"13 envtools "launchpad.net/juju-core/environs/tools"
14 "launchpad.net/juju-core/provider/dummy"14 "launchpad.net/juju-core/provider/dummy"
15 "launchpad.net/juju-core/testing"15 "launchpad.net/juju-core/testing"
16 coretesting "launchpad.net/juju-core/testing"16 "launchpad.net/juju-core/testing/testbase"
17 coretools "launchpad.net/juju-core/tools"17 coretools "launchpad.net/juju-core/tools"
18 "launchpad.net/juju-core/version"18 "launchpad.net/juju-core/version"
19)19)
2020
21type StorageSuite struct {21type StorageSuite struct {
22 env environs.Environ22 env environs.Environ
23 coretesting.BaseSuite23 testbase.LoggingSuite
24 dataDir string24 dataDir string
25}25}
2626
27var _ = gc.Suite(&StorageSuite{})27var _ = gc.Suite(&StorageSuite{})
2828
29func (s *StorageSuite) SetUpTest(c *gc.C) {29func (s *StorageSuite) SetUpTest(c *gc.C) {
30 s.BaseSuite.SetUpTest(c)30 s.LoggingSuite.SetUpTest(c)
31 cfg, err := config.New(config.NoDefaults, dummy.SampleConfig())31 cfg, err := config.New(config.NoDefaults, dummy.SampleConfig())
32 c.Assert(err, gc.IsNil)32 c.Assert(err, gc.IsNil)
33 s.env, err = environs.Prepare(cfg, testing.Context(c), configstore.NewMem())33 s.env, err = environs.Prepare(cfg, testing.Context(c), configstore.NewMem())
@@ -37,7 +37,7 @@
3737
38func (s *StorageSuite) TearDownTest(c *gc.C) {38func (s *StorageSuite) TearDownTest(c *gc.C) {
39 dummy.Reset()39 dummy.Reset()
40 s.BaseSuite.TearDownTest(c)40 s.LoggingSuite.TearDownTest(c)
41}41}
4242
43func (s *StorageSuite) TestStorageName(c *gc.C) {43func (s *StorageSuite) TestStorageName(c *gc.C) {
4444
=== modified file 'environs/tools/tools_test.go'
--- environs/tools/tools_test.go 2014-05-21 22:15:10 +0000
+++ environs/tools/tools_test.go 2014-05-22 14:33:28 +0000
@@ -21,14 +21,14 @@
21 toolstesting "launchpad.net/juju-core/environs/tools/testing"21 toolstesting "launchpad.net/juju-core/environs/tools/testing"
22 "launchpad.net/juju-core/provider/dummy"22 "launchpad.net/juju-core/provider/dummy"
23 "launchpad.net/juju-core/testing"23 "launchpad.net/juju-core/testing"
24 coretesting "launchpad.net/juju-core/testing"24 "launchpad.net/juju-core/testing/testbase"
25 coretools "launchpad.net/juju-core/tools"25 coretools "launchpad.net/juju-core/tools"
26 "launchpad.net/juju-core/version"26 "launchpad.net/juju-core/version"
27)27)
2828
29type SimpleStreamsToolsSuite struct {29type SimpleStreamsToolsSuite struct {
30 env environs.Environ30 env environs.Environ
31 coretesting.BaseSuite31 testbase.LoggingSuite
32 envtesting.ToolsFixture32 envtesting.ToolsFixture
33 origCurrentVersion version.Binary33 origCurrentVersion version.Binary
34 customToolsDir string34 customToolsDir string
@@ -40,14 +40,14 @@
40}40}
4141
42func (s *SimpleStreamsToolsSuite) SetUpSuite(c *gc.C) {42func (s *SimpleStreamsToolsSuite) SetUpSuite(c *gc.C) {
43 s.BaseSuite.SetUpSuite(c)43 s.LoggingSuite.SetUpSuite(c)
44 s.customToolsDir = c.MkDir()44 s.customToolsDir = c.MkDir()
45 s.publicToolsDir = c.MkDir()45 s.publicToolsDir = c.MkDir()
46}46}
4747
48func (s *SimpleStreamsToolsSuite) SetUpTest(c *gc.C) {48func (s *SimpleStreamsToolsSuite) SetUpTest(c *gc.C) {
49 s.ToolsFixture.DefaultBaseURL = "file://" + s.publicToolsDir49 s.ToolsFixture.DefaultBaseURL = "file://" + s.publicToolsDir
50 s.BaseSuite.SetUpTest(c)50 s.LoggingSuite.SetUpTest(c)
51 s.ToolsFixture.SetUpTest(c)51 s.ToolsFixture.SetUpTest(c)
52 s.origCurrentVersion = version.Current52 s.origCurrentVersion = version.Current
53 s.reset(c, nil)53 s.reset(c, nil)
@@ -57,7 +57,7 @@
57 dummy.Reset()57 dummy.Reset()
58 version.Current = s.origCurrentVersion58 version.Current = s.origCurrentVersion
59 s.ToolsFixture.TearDownTest(c)59 s.ToolsFixture.TearDownTest(c)
60 s.BaseSuite.TearDownTest(c)60 s.LoggingSuite.TearDownTest(c)
61}61}
6262
63func (s *SimpleStreamsToolsSuite) reset(c *gc.C, attrs map[string]interface{}) {63func (s *SimpleStreamsToolsSuite) reset(c *gc.C, attrs map[string]interface{}) {
6464
=== modified file 'environs/tools/urls_test.go'
--- environs/tools/urls_test.go 2014-05-15 05:14:01 +0000
+++ environs/tools/urls_test.go 2014-05-22 14:33:28 +0000
@@ -17,18 +17,21 @@
17 "launchpad.net/juju-core/environs/tools"17 "launchpad.net/juju-core/environs/tools"
18 "launchpad.net/juju-core/provider/dummy"18 "launchpad.net/juju-core/provider/dummy"
19 "launchpad.net/juju-core/testing"19 "launchpad.net/juju-core/testing"
20 coretesting "launchpad.net/juju-core/testing"
21)20)
2221
23type URLsSuite struct {22type URLsSuite struct {
24 coretesting.BaseSuite23 home *testing.FakeHome
25}24}
2625
27var _ = gc.Suite(&URLsSuite{})26var _ = gc.Suite(&URLsSuite{})
2827
28func (s *URLsSuite) SetUpTest(c *gc.C) {
29 s.home = testing.MakeEmptyFakeHome(c)
30}
31
29func (s *URLsSuite) TearDownTest(c *gc.C) {32func (s *URLsSuite) TearDownTest(c *gc.C) {
33 s.home.Restore()
30 dummy.Reset()34 dummy.Reset()
31 s.BaseSuite.TearDownTest(c)
32}35}
3336
34func (s *URLsSuite) env(c *gc.C, toolsMetadataURL string) environs.Environ {37func (s *URLsSuite) env(c *gc.C, toolsMetadataURL string) environs.Environ {
3538
=== modified file 'environs/tools/validation_test.go'
--- environs/tools/validation_test.go 2014-05-20 04:27:02 +0000
+++ environs/tools/validation_test.go 2014-05-22 14:33:28 +0000
@@ -10,12 +10,12 @@
1010
11 "launchpad.net/juju-core/environs/filestorage"11 "launchpad.net/juju-core/environs/filestorage"
12 "launchpad.net/juju-core/environs/simplestreams"12 "launchpad.net/juju-core/environs/simplestreams"
13 "launchpad.net/juju-core/testing"13 "launchpad.net/juju-core/testing/testbase"
14 "launchpad.net/juju-core/utils"14 "launchpad.net/juju-core/utils"
15)15)
1616
17type ValidateSuite struct {17type ValidateSuite struct {
18 testing.BaseSuite18 testbase.LoggingSuite
19 metadataDir string19 metadataDir string
20}20}
2121
@@ -40,7 +40,7 @@
40}40}
4141
42func (s *ValidateSuite) SetUpTest(c *gc.C) {42func (s *ValidateSuite) SetUpTest(c *gc.C) {
43 s.BaseSuite.SetUpTest(c)43 s.LoggingSuite.SetUpTest(c)
44 s.metadataDir = c.MkDir()44 s.metadataDir = c.MkDir()
45}45}
4646
4747
=== modified file 'instance/address_test.go'
--- instance/address_test.go 2014-05-20 04:27:02 +0000
+++ instance/address_test.go 2014-05-22 14:33:28 +0000
@@ -7,11 +7,11 @@
7 jc "github.com/juju/testing/checkers"7 jc "github.com/juju/testing/checkers"
8 gc "launchpad.net/gocheck"8 gc "launchpad.net/gocheck"
99
10 "launchpad.net/juju-core/testing"10 "launchpad.net/juju-core/testing/testbase"
11)11)
1212
13type AddressSuite struct {13type AddressSuite struct {
14 testing.BaseSuite14 testbase.LoggingSuite
15}15}
1616
17var _ = gc.Suite(&AddressSuite{})17var _ = gc.Suite(&AddressSuite{})
1818
=== modified file 'juju/apiconn_test.go'
--- juju/apiconn_test.go 2014-05-16 01:33:13 +0000
+++ juju/apiconn_test.go 2014-05-22 14:33:28 +0000
@@ -23,24 +23,25 @@
23 "launchpad.net/juju-core/provider/dummy"23 "launchpad.net/juju-core/provider/dummy"
24 "launchpad.net/juju-core/state/api"24 "launchpad.net/juju-core/state/api"
25 coretesting "launchpad.net/juju-core/testing"25 coretesting "launchpad.net/juju-core/testing"
26 "launchpad.net/juju-core/testing/testbase"
26)27)
2728
28type NewAPIConnSuite struct {29type NewAPIConnSuite struct {
29 coretesting.FakeJujuHomeSuite30 testbase.LoggingSuite
30 envtesting.ToolsFixture31 envtesting.ToolsFixture
31}32}
3233
33var _ = gc.Suite(&NewAPIConnSuite{})34var _ = gc.Suite(&NewAPIConnSuite{})
3435
35func (cs *NewAPIConnSuite) SetUpTest(c *gc.C) {36func (cs *NewAPIConnSuite) SetUpTest(c *gc.C) {
36 cs.FakeJujuHomeSuite.SetUpTest(c)37 cs.LoggingSuite.SetUpTest(c)
37 cs.ToolsFixture.SetUpTest(c)38 cs.ToolsFixture.SetUpTest(c)
38}39}
3940
40func (cs *NewAPIConnSuite) TearDownTest(c *gc.C) {41func (cs *NewAPIConnSuite) TearDownTest(c *gc.C) {
41 dummy.Reset()42 dummy.Reset()
42 cs.ToolsFixture.TearDownTest(c)43 cs.ToolsFixture.TearDownTest(c)
43 cs.FakeJujuHomeSuite.TearDownTest(c)44 cs.LoggingSuite.TearDownTest(c)
44}45}
4546
46func (*NewAPIConnSuite) TestNewConn(c *gc.C) {47func (*NewAPIConnSuite) TestNewConn(c *gc.C) {
@@ -75,18 +76,18 @@
75}76}
7677
77type NewAPIClientSuite struct {78type NewAPIClientSuite struct {
78 coretesting.FakeJujuHomeSuite79 testbase.LoggingSuite
79}80}
8081
81var _ = gc.Suite(&NewAPIClientSuite{})82var _ = gc.Suite(&NewAPIClientSuite{})
8283
83func (cs *NewAPIClientSuite) TearDownTest(c *gc.C) {84func (cs *NewAPIClientSuite) TearDownTest(c *gc.C) {
84 dummy.Reset()85 dummy.Reset()
85 cs.FakeJujuHomeSuite.TearDownTest(c)86 cs.LoggingSuite.TearDownTest(c)
86}87}
8788
88func (s *NewAPIClientSuite) TestNameDefault(c *gc.C) {89func (s *NewAPIClientSuite) TestNameDefault(c *gc.C) {
89 coretesting.WriteEnvironments(c, coretesting.MultipleEnvConfig)90 defer coretesting.MakeMultipleEnvHome(c).Restore()
90 // The connection logic should not delay the config connection91 // The connection logic should not delay the config connection
91 // at all when there is no environment info available.92 // at all when there is no environment info available.
92 // Make sure of that by providing a suitably long delay93 // Make sure of that by providing a suitably long delay
@@ -106,7 +107,7 @@
106}107}
107108
108func (*NewAPIClientSuite) TestNameNotDefault(c *gc.C) {109func (*NewAPIClientSuite) TestNameNotDefault(c *gc.C) {
109 coretesting.WriteEnvironments(c, coretesting.MultipleEnvConfig)110 defer coretesting.MakeMultipleEnvHome(c).Restore()
110 envName := coretesting.SampleCertName + "-2"111 envName := coretesting.SampleCertName + "-2"
111 bootstrapEnv(c, envName, defaultConfigStore(c))112 bootstrapEnv(c, envName, defaultConfigStore(c))
112 apiclient, err := juju.NewAPIClientFromName(envName)113 apiclient, err := juju.NewAPIClientFromName(envName)
@@ -116,6 +117,7 @@
116}117}
117118
118func (s *NewAPIClientSuite) TestWithInfoOnly(c *gc.C) {119func (s *NewAPIClientSuite) TestWithInfoOnly(c *gc.C) {
120 defer coretesting.MakeEmptyFakeHome(c).Restore()
119 store := newConfigStore("noconfig", dummyStoreInfo)121 store := newConfigStore("noconfig", dummyStoreInfo)
120122
121 called := 0123 called := 0
@@ -155,7 +157,7 @@
155}157}
156158
157func (s *NewAPIClientSuite) TestWithConfigAndNoInfo(c *gc.C) {159func (s *NewAPIClientSuite) TestWithConfigAndNoInfo(c *gc.C) {
158 coretesting.MakeSampleJujuHome(c)160 defer coretesting.MakeSampleHome(c).Restore()
159161
160 store := newConfigStore(coretesting.SampleEnvName, &environInfo{162 store := newConfigStore(coretesting.SampleEnvName, &environInfo{
161 bootstrapConfig: map[string]interface{}{163 bootstrapConfig: map[string]interface{}{
@@ -208,6 +210,7 @@
208}210}
209211
210func (s *NewAPIClientSuite) TestWithInfoError(c *gc.C) {212func (s *NewAPIClientSuite) TestWithInfoError(c *gc.C) {
213 defer coretesting.MakeEmptyFakeHome(c).Restore()
211 expectErr := fmt.Errorf("an error")214 expectErr := fmt.Errorf("an error")
212 store := newConfigStoreWithError(expectErr)215 store := newConfigStoreWithError(expectErr)
213 client, err := juju.NewAPIFromStore("noconfig", store, panicAPIOpen)216 client, err := juju.NewAPIFromStore("noconfig", store, panicAPIOpen)
@@ -216,6 +219,7 @@
216}219}
217220
218func (s *NewAPIClientSuite) TestWithInfoNoAddresses(c *gc.C) {221func (s *NewAPIClientSuite) TestWithInfoNoAddresses(c *gc.C) {
222 defer coretesting.MakeEmptyFakeHome(c).Restore()
219 store := newConfigStore("noconfig", &environInfo{223 store := newConfigStore("noconfig", &environInfo{
220 endpoint: configstore.APIEndpoint{224 endpoint: configstore.APIEndpoint{
221 Addresses: []string{},225 Addresses: []string{},
@@ -228,6 +232,7 @@
228}232}
229233
230func (s *NewAPIClientSuite) TestWithInfoAPIOpenError(c *gc.C) {234func (s *NewAPIClientSuite) TestWithInfoAPIOpenError(c *gc.C) {
235 defer coretesting.MakeEmptyFakeHome(c).Restore()
231 store := newConfigStore("noconfig", &environInfo{236 store := newConfigStore("noconfig", &environInfo{
232 endpoint: configstore.APIEndpoint{237 endpoint: configstore.APIEndpoint{
233 Addresses: []string{"foo.invalid"},238 Addresses: []string{"foo.invalid"},
@@ -244,7 +249,7 @@
244}249}
245250
246func (s *NewAPIClientSuite) TestWithSlowInfoConnect(c *gc.C) {251func (s *NewAPIClientSuite) TestWithSlowInfoConnect(c *gc.C) {
247 coretesting.MakeSampleJujuHome(c)252 defer coretesting.MakeSampleHome(c).Restore()
248 store := configstore.NewMem()253 store := configstore.NewMem()
249 bootstrapEnv(c, coretesting.SampleEnvName, store)254 bootstrapEnv(c, coretesting.SampleEnvName, store)
250 setEndpointAddress(c, store, coretesting.SampleEnvName, "infoapi.invalid")255 setEndpointAddress(c, store, coretesting.SampleEnvName, "infoapi.invalid")
@@ -328,7 +333,7 @@
328}333}
329334
330func (s *NewAPIClientSuite) TestWithSlowConfigConnect(c *gc.C) {335func (s *NewAPIClientSuite) TestWithSlowConfigConnect(c *gc.C) {
331 coretesting.MakeSampleJujuHome(c)336 defer coretesting.MakeSampleHome(c).Restore()
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to status/vote changes: