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
1=== modified file 'agent/agent_test.go'
2--- agent/agent_test.go 2014-05-20 04:27:02 +0000
3+++ agent/agent_test.go 2014-05-22 14:33:28 +0000
4@@ -15,12 +15,12 @@
5 "launchpad.net/juju-core/state"
6 "launchpad.net/juju-core/state/api"
7 "launchpad.net/juju-core/state/api/params"
8- "launchpad.net/juju-core/testing"
9+ "launchpad.net/juju-core/testing/testbase"
10 "launchpad.net/juju-core/version"
11 )
12
13 type suite struct {
14- testing.BaseSuite
15+ testbase.LoggingSuite
16 }
17
18 var _ = gc.Suite(&suite{})
19
20=== modified file 'agent/bootstrap_test.go'
21--- agent/bootstrap_test.go 2014-05-20 04:27:02 +0000
22+++ agent/bootstrap_test.go 2014-05-22 14:33:28 +0000
23@@ -16,35 +16,36 @@
24 "launchpad.net/juju-core/state"
25 "launchpad.net/juju-core/state/api/params"
26 "launchpad.net/juju-core/testing"
27+ "launchpad.net/juju-core/testing/testbase"
28 "launchpad.net/juju-core/utils"
29 "launchpad.net/juju-core/version"
30 )
31
32 type bootstrapSuite struct {
33- testing.BaseSuite
34+ testbase.LoggingSuite
35 testing.MgoSuite
36 }
37
38 var _ = gc.Suite(&bootstrapSuite{})
39
40 func (s *bootstrapSuite) SetUpSuite(c *gc.C) {
41- s.BaseSuite.SetUpSuite(c)
42+ s.LoggingSuite.SetUpSuite(c)
43 s.MgoSuite.SetUpSuite(c)
44 }
45
46 func (s *bootstrapSuite) TearDownSuite(c *gc.C) {
47 s.MgoSuite.TearDownSuite(c)
48- s.BaseSuite.TearDownSuite(c)
49+ s.LoggingSuite.TearDownSuite(c)
50 }
51
52 func (s *bootstrapSuite) SetUpTest(c *gc.C) {
53- s.BaseSuite.SetUpTest(c)
54+ s.LoggingSuite.SetUpTest(c)
55 s.MgoSuite.SetUpTest(c)
56 }
57
58 func (s *bootstrapSuite) TearDownTest(c *gc.C) {
59 s.MgoSuite.TearDownTest(c)
60- s.BaseSuite.TearDownTest(c)
61+ s.LoggingSuite.TearDownTest(c)
62 }
63
64 func (s *bootstrapSuite) TestInitializeState(c *gc.C) {
65
66=== modified file 'agent/format-1.16_whitebox_test.go'
67--- agent/format-1.16_whitebox_test.go 2014-05-20 04:27:02 +0000
68+++ agent/format-1.16_whitebox_test.go 2014-05-22 14:33:28 +0000
69@@ -14,13 +14,13 @@
70 jc "github.com/juju/testing/checkers"
71
72 gc "launchpad.net/gocheck"
73- "launchpad.net/juju-core/testing"
74+ "launchpad.net/juju-core/testing/testbase"
75 "launchpad.net/juju-core/utils"
76 "launchpad.net/juju-core/version"
77 )
78
79 type format_1_16Suite struct {
80- testing.BaseSuite
81+ testbase.LoggingSuite
82 }
83
84 var _ = gc.Suite(&format_1_16Suite{})
85
86=== modified file 'agent/format-1.18_whitebox_test.go'
87--- agent/format-1.18_whitebox_test.go 2014-05-20 04:27:02 +0000
88+++ agent/format-1.18_whitebox_test.go 2014-05-22 14:33:28 +0000
89@@ -14,13 +14,13 @@
90
91 gc "launchpad.net/gocheck"
92 "launchpad.net/juju-core/state/api/params"
93- "launchpad.net/juju-core/testing"
94+ "launchpad.net/juju-core/testing/testbase"
95 "launchpad.net/juju-core/utils"
96 "launchpad.net/juju-core/version"
97 )
98
99 type format_1_18Suite struct {
100- testing.BaseSuite
101+ testbase.LoggingSuite
102 }
103
104 var _ = gc.Suite(&format_1_18Suite{})
105
106=== modified file 'agent/format_whitebox_test.go'
107--- agent/format_whitebox_test.go 2014-05-20 04:27:02 +0000
108+++ agent/format_whitebox_test.go 2014-05-22 14:33:28 +0000
109@@ -11,12 +11,12 @@
110 gc "launchpad.net/gocheck"
111
112 "launchpad.net/juju-core/state/api/params"
113- "launchpad.net/juju-core/testing"
114+ "launchpad.net/juju-core/testing/testbase"
115 "launchpad.net/juju-core/version"
116 )
117
118 type formatSuite struct {
119- testing.BaseSuite
120+ testbase.LoggingSuite
121 }
122
123 var _ = gc.Suite(&formatSuite{})
124
125=== modified file 'agent/identity_test.go'
126--- agent/identity_test.go 2014-05-20 04:27:02 +0000
127+++ agent/identity_test.go 2014-05-22 14:33:28 +0000
128@@ -10,12 +10,12 @@
129 gc "launchpad.net/gocheck"
130
131 "launchpad.net/juju-core/state/api/params"
132- "launchpad.net/juju-core/testing"
133+ "launchpad.net/juju-core/testing/testbase"
134 "launchpad.net/juju-core/version"
135 )
136
137 type identitySuite struct {
138- testing.BaseSuite
139+ testbase.LoggingSuite
140 mongodConfigPath string
141 mongodPath string
142 }
143
144=== removed file 'agent/mongo/export_test.go'
145--- agent/mongo/export_test.go 2014-05-20 08:29:58 +0000
146+++ agent/mongo/export_test.go 1970-01-01 00:00:00 +0000
147@@ -1,18 +0,0 @@
148-// Copyright 2014 Canonical Ltd.
149-// Licensed under the AGPLv3, see LICENCE file for details.
150-
151-package mongo
152-
153-var (
154- MakeJournalDirs = makeJournalDirs
155- MongoConfigPath = &mongoConfigPath
156- NoauthCommand = noauthCommand
157- ProcessSignal = &processSignal
158- SharedSecretPath = sharedSecretPath
159- SSLKeyPath = sslKeyPath
160- UpstartConfInstall = &upstartConfInstall
161- UpstartService = upstartService
162- UpstartServiceStopAndRemove = &upstartServiceStopAndRemove
163- UpstartServiceStop = &upstartServiceStop
164- UpstartServiceStart = &upstartServiceStart
165-)
166
167=== modified file 'agent/mongo/mongo.go'
168--- agent/mongo/mongo.go 2014-05-14 11:38:13 +0000
169+++ agent/mongo/mongo.go 2014-05-22 14:33:28 +0000
170@@ -285,7 +285,6 @@
171 " --noprealloc" +
172 " --syslog" +
173 " --smallfiles" +
174- " --journal" +
175 " --keyFile " + utils.ShQuote(sharedSecretPath(dataDir))
176 if withHA {
177 mongoCmd += " --replSet " + ReplicaSetName
178@@ -374,7 +373,6 @@
179 "--noprealloc",
180 "--syslog",
181 "--smallfiles",
182- "--journal",
183 )
184 return cmd, nil
185 }
186
187=== modified file 'agent/mongo/mongo_test.go'
188--- agent/mongo/mongo_test.go 2014-05-20 08:29:58 +0000
189+++ agent/mongo/mongo_test.go 2014-05-22 14:33:28 +0000
190@@ -1,7 +1,7 @@
191 // Copyright 2014 Canonical Ltd.
192 // Licensed under the AGPLv3, see LICENCE file for details.
193
194-package mongo_test
195+package mongo
196
197 import (
198 "encoding/base64"
199@@ -18,10 +18,9 @@
200 jc "github.com/juju/testing/checkers"
201 gc "launchpad.net/gocheck"
202
203- "launchpad.net/juju-core/agent/mongo"
204 "launchpad.net/juju-core/instance"
205 "launchpad.net/juju-core/state/api/params"
206- coretesting "launchpad.net/juju-core/testing"
207+ "launchpad.net/juju-core/testing/testbase"
208 "launchpad.net/juju-core/upstart"
209 "launchpad.net/juju-core/utils"
210 "launchpad.net/juju-core/version"
211@@ -30,7 +29,7 @@
212 func Test(t *stdtesting.T) { gc.TestingT(t) }
213
214 type MongoSuite struct {
215- coretesting.BaseSuite
216+ testbase.LoggingSuite
217 mongodConfigPath string
218 mongodPath string
219
220@@ -51,24 +50,24 @@
221 }
222
223 func (s *MongoSuite) SetUpTest(c *gc.C) {
224- s.BaseSuite.SetUpTest(c)
225+ s.LoggingSuite.SetUpTest(c)
226 // Try to make sure we don't execute any commands accidentally.
227 s.PatchEnvironment("PATH", "")
228
229 s.mongodPath = filepath.Join(c.MkDir(), "mongod")
230 err := ioutil.WriteFile(s.mongodPath, []byte("#!/bin/bash\n\nprintf %s 'db version v2.4.9'\n"), 0755)
231 c.Assert(err, gc.IsNil)
232- s.PatchValue(&mongo.JujuMongodPath, s.mongodPath)
233+ s.PatchValue(&JujuMongodPath, s.mongodPath)
234
235 testPath := c.MkDir()
236 s.mongodConfigPath = filepath.Join(testPath, "mongodConfig")
237- s.PatchValue(mongo.MongoConfigPath, s.mongodConfigPath)
238+ s.PatchValue(&mongoConfigPath, s.mongodConfigPath)
239
240- s.PatchValue(mongo.UpstartConfInstall, func(conf *upstart.Conf) error {
241+ s.PatchValue(&upstartConfInstall, func(conf *upstart.Conf) error {
242 s.installed = append(s.installed, *conf)
243 return s.installError
244 })
245- s.PatchValue(mongo.UpstartServiceStopAndRemove, func(svc *upstart.Service) error {
246+ s.PatchValue(&upstartServiceStopAndRemove, func(svc *upstart.Service) error {
247 s.removed = append(s.removed, *svc)
248 return s.removeError
249 })
250@@ -80,23 +79,23 @@
251 }
252
253 func (s *MongoSuite) TestJujuMongodPath(c *gc.C) {
254- obtained, err := mongo.Path()
255+ obtained, err := Path()
256 c.Check(err, gc.IsNil)
257 c.Check(obtained, gc.Equals, s.mongodPath)
258 }
259
260 func (s *MongoSuite) TestDefaultMongodPath(c *gc.C) {
261- s.PatchValue(&mongo.JujuMongodPath, "/not/going/to/exist/mongod")
262+ s.PatchValue(&JujuMongodPath, "/not/going/to/exist/mongod")
263 s.PatchEnvPathPrepend(filepath.Dir(s.mongodPath))
264
265- obtained, err := mongo.Path()
266+ obtained, err := Path()
267 c.Check(err, gc.IsNil)
268 c.Check(obtained, gc.Equals, s.mongodPath)
269 }
270
271 func (s *MongoSuite) TestMakeJournalDirs(c *gc.C) {
272 dir := c.MkDir()
273- err := mongo.MakeJournalDirs(dir)
274+ err := makeJournalDirs(dir)
275 c.Assert(err, gc.IsNil)
276
277 testJournalDirs(dir, c)
278@@ -127,7 +126,7 @@
279
280 mockShellCommand(c, &s.CleanupSuite, "apt-get")
281
282- err := mongo.EnsureServer(dataDir, namespace, testInfo, mongo.WithHA)
283+ err := EnsureServer(dataDir, namespace, testInfo, WithHA)
284 c.Assert(err, gc.IsNil)
285
286 testJournalDirs(dbDir, c)
287@@ -148,17 +147,17 @@
288 c.Assert(err, gc.IsNil)
289 c.Assert(contents, jc.DeepEquals, []byte("ENABLE_MONGODB=no"))
290
291- contents, err = ioutil.ReadFile(mongo.SSLKeyPath(dataDir))
292+ contents, err = ioutil.ReadFile(sslKeyPath(dataDir))
293 c.Assert(err, gc.IsNil)
294 c.Assert(string(contents), gc.Equals, testInfo.Cert+"\n"+testInfo.PrivateKey)
295
296- contents, err = ioutil.ReadFile(mongo.SharedSecretPath(dataDir))
297+ contents, err = ioutil.ReadFile(sharedSecretPath(dataDir))
298 c.Assert(err, gc.IsNil)
299 c.Assert(string(contents), gc.Equals, testInfo.SharedSecret)
300
301 s.installed = nil
302 // now check we can call it multiple times without error
303- err = mongo.EnsureServer(dataDir, namespace, testInfo, mongo.WithHA)
304+ err = EnsureServer(dataDir, namespace, testInfo, WithHA)
305 c.Assert(err, gc.IsNil)
306 assertInstalled()
307
308@@ -194,7 +193,7 @@
309
310 s.PatchValue(&version.Current.Series, test.series)
311
312- err := mongo.EnsureServer(dataDir, namespace, testInfo, mongo.WithHA)
313+ err := EnsureServer(dataDir, namespace, testInfo, WithHA)
314 c.Assert(err, gc.IsNil)
315
316 cmds := getMockShellCalls(c, output)
317@@ -215,40 +214,17 @@
318 func (s *MongoSuite) TestUpstartServiceWithHA(c *gc.C) {
319 dataDir := c.MkDir()
320
321- svc, _, err := mongo.UpstartService("", dataDir, dataDir, 1234, mongo.WithHA)
322+ svc, _, err := upstartService("", dataDir, dataDir, 1234, WithHA)
323 c.Assert(err, gc.IsNil)
324 c.Assert(strings.Contains(svc.Cmd, "--replSet"), jc.IsTrue)
325
326- svc, _, err = mongo.UpstartService("", dataDir, dataDir, 1234, mongo.WithoutHA)
327+ svc, _, err = upstartService("", dataDir, dataDir, 1234, WithoutHA)
328 c.Assert(err, gc.IsNil)
329 c.Assert(strings.Contains(svc.Cmd, "--replSet"), jc.IsFalse)
330 }
331
332-func (s *MongoSuite) TestUpstartServiceWithJournal(c *gc.C) {
333- dataDir := c.MkDir()
334-
335- svc, _, err := mongo.UpstartService("", dataDir, dataDir, 1234, mongo.WithHA)
336- c.Assert(err, gc.IsNil)
337- journalPresent := strings.Contains(svc.Cmd, " --journal ") || strings.HasSuffix(svc.Cmd, " --journal")
338- c.Assert(journalPresent, jc.IsTrue)
339-}
340-
341-func (s *MongoSuite) TestNoAuthCommandWithJournal(c *gc.C) {
342- dataDir := c.MkDir()
343-
344- cmd, err := mongo.NoauthCommand(dataDir, 1234)
345- c.Assert(err, gc.IsNil)
346- var isJournalPresent bool
347- for _, value := range cmd.Args {
348- if value == "--journal" {
349- isJournalPresent = true
350- }
351- }
352- c.Assert(isJournalPresent, jc.IsTrue)
353-}
354-
355 func (s *MongoSuite) TestRemoveService(c *gc.C) {
356- err := mongo.RemoveService("namespace")
357+ err := RemoveService("namespace")
358 c.Assert(err, gc.IsNil)
359 c.Assert(s.removed, jc.DeepEquals, []upstart.Service{{
360 Name: "juju-db-namespace",
361@@ -265,11 +241,11 @@
362 // test that we call add-apt-repository only for quantal (and that if it
363 // fails, we return the error)
364 s.PatchValue(&version.Current.Series, "quantal")
365- err := mongo.EnsureServer(dir, "", testInfo, mongo.WithHA)
366+ err := EnsureServer(dir, "", testInfo, WithHA)
367 c.Assert(err, gc.ErrorMatches, "cannot install mongod: cannot add apt repository: exit status 1.*")
368
369 s.PatchValue(&version.Current.Series, "trusty")
370- err = mongo.EnsureServer(dir, "", testInfo, mongo.WithHA)
371+ err = EnsureServer(dir, "", testInfo, WithHA)
372 c.Assert(err, gc.IsNil)
373 }
374
375@@ -278,7 +254,7 @@
376 // created.
377 mockShellCommand(c, &s.CleanupSuite, "apt-get")
378 dataDir := filepath.Join(c.MkDir(), "dir", "data")
379- err := mongo.EnsureServer(dataDir, "", testInfo, mongo.WithHA)
380+ err := EnsureServer(dataDir, "", testInfo, WithHA)
381 c.Check(err, gc.IsNil)
382
383 _, err = os.Stat(filepath.Join(dataDir, "db"))
384@@ -286,9 +262,9 @@
385 }
386
387 func (s *MongoSuite) TestServiceName(c *gc.C) {
388- name := mongo.ServiceName("foo")
389+ name := ServiceName("foo")
390 c.Assert(name, gc.Equals, "juju-db-foo")
391- name = mongo.ServiceName("")
392+ name = ServiceName("")
393 c.Assert(name, gc.Equals, "juju-db")
394 }
395
396@@ -303,7 +279,7 @@
397 NetworkName: "public",
398 NetworkScope: instance.NetworkPublic}}
399
400- address := mongo.SelectPeerAddress(addresses)
401+ address := SelectPeerAddress(addresses)
402 c.Assert(address, gc.Equals, "10.0.0.1")
403 }
404
405@@ -325,12 +301,12 @@
406 },
407 Port: 37017}}
408
409- address := mongo.SelectPeerHostPort(hostPorts)
410+ address := SelectPeerHostPort(hostPorts)
411 c.Assert(address, gc.Equals, "10.0.0.1:37017")
412 }
413
414 func (s *MongoSuite) TestGenerateSharedSecret(c *gc.C) {
415- secret, err := mongo.GenerateSharedSecret()
416+ secret, err := GenerateSharedSecret()
417 c.Assert(err, gc.IsNil)
418 c.Assert(secret, gc.HasLen, 1024)
419 _, err = base64.StdEncoding.DecodeString(secret)
420@@ -344,7 +320,7 @@
421 s.PatchValue(&version.Current.Series, "quantal")
422
423 dataDir := c.MkDir()
424- err := mongo.EnsureServer(dataDir, "", testInfo, mongo.WithHA)
425+ err := EnsureServer(dataDir, "", testInfo, WithHA)
426 c.Assert(err, gc.IsNil)
427
428 c.Assert(getMockShellCalls(c, addAptRepoOut), gc.DeepEquals, [][]string{{
429
430=== modified file 'agent/mongo/upgrade.go'
431--- agent/mongo/upgrade.go 2014-05-22 00:56:59 +0000
432+++ agent/mongo/upgrade.go 2014-05-22 14:33:28 +0000
433@@ -8,15 +8,12 @@
434 "os"
435 "os/exec"
436 "syscall"
437- "time"
438
439 "labix.org/v2/mgo"
440
441 "launchpad.net/juju-core/upstart"
442 )
443
444-const mongoSocketTimeout = 10 * time.Second
445-
446 var (
447 processSignal = (*os.Process).Signal
448 )
449@@ -54,13 +51,11 @@
450 if err != nil {
451 return false, fmt.Errorf("can't dial mongo to ensure admin user: %v", err)
452 }
453- session.SetSocketTimeout(mongoSocketTimeout)
454 err = session.DB("admin").Login(p.User, p.Password)
455 session.Close()
456 if err == nil {
457 return false, nil
458 }
459- logger.Debugf("admin login failed: %v", err)
460
461 // Login failed, so we need to add the user.
462 // Stop mongo, so we can start it in --noauth mode.
463
464=== modified file 'agent/mongo/upgrade_test.go'
465--- agent/mongo/upgrade_test.go 2014-05-22 09:52:11 +0000
466+++ agent/mongo/upgrade_test.go 2014-05-22 14:33:28 +0000
467@@ -1,45 +1,35 @@
468 // Copyright 2014 Canonical Ltd.
469 // Licensed under the AGPLv3, see LICENCE file for details.
470
471-package mongo_test
472+package mongo
473
474 import (
475 "net"
476- "os"
477- "path/filepath"
478 "strconv"
479
480- jujutesting "github.com/juju/testing"
481 jc "github.com/juju/testing/checkers"
482 "labix.org/v2/mgo"
483 gc "launchpad.net/gocheck"
484
485- "launchpad.net/juju-core/agent/mongo"
486 coretesting "launchpad.net/juju-core/testing"
487+ "launchpad.net/juju-core/testing/testbase"
488 "launchpad.net/juju-core/upstart"
489 )
490
491 type EnsureAdminSuite struct {
492- coretesting.BaseSuite
493- serviceStarts int
494- serviceStops int
495+ testbase.LoggingSuite
496 }
497
498 var _ = gc.Suite(&EnsureAdminSuite{})
499
500 func (s *EnsureAdminSuite) SetUpTest(c *gc.C) {
501- s.BaseSuite.SetUpTest(c)
502- s.serviceStarts = 0
503- s.serviceStops = 0
504- s.PatchValue(mongo.UpstartConfInstall, func(conf *upstart.Conf) error {
505- return nil
506- })
507- s.PatchValue(mongo.UpstartServiceStart, func(svc *upstart.Service) error {
508- s.serviceStarts++
509- return nil
510- })
511- s.PatchValue(mongo.UpstartServiceStop, func(svc *upstart.Service) error {
512- s.serviceStops++
513+ s.PatchValue(&upstartConfInstall, func(conf *upstart.Conf) error {
514+ return nil
515+ })
516+ s.PatchValue(&upstartServiceStart, func(svc *upstart.Service) error {
517+ return nil
518+ })
519+ s.PatchValue(&upstartServiceStop, func(svc *upstart.Service) error {
520 return nil
521 })
522 }
523@@ -50,50 +40,14 @@
524 c.Assert(err, gc.IsNil)
525 defer inst.DestroyWithLog()
526 dialInfo := inst.DialInfo()
527-
528- // Mock out mongod, so the --noauth execution doesn't
529- // do anything nasty. Also mock out the Signal method.
530- jujutesting.PatchExecutableAsEchoArgs(c, s, "mongod")
531- mongodDir := filepath.SplitList(os.Getenv("PATH"))[0]
532- s.PatchValue(&mongo.JujuMongodPath, filepath.Join(mongodDir, "mongod"))
533- s.PatchValue(mongo.ProcessSignal, func(*os.Process, os.Signal) error {
534- return nil
535- })
536-
537 // First call succeeds, as there are no users yet.
538 added, err := s.ensureAdminUser(c, dialInfo, "whomever", "whatever")
539 c.Assert(err, gc.IsNil)
540 c.Assert(added, jc.IsTrue)
541-
542- // EnsureAdminUser should have stopped the mongo service,
543- // started a new mongod with --noauth, and then finally
544- // started the service back up.
545- c.Assert(s.serviceStarts, gc.Equals, 1)
546- c.Assert(s.serviceStops, gc.Equals, 1)
547- _, portString, err := net.SplitHostPort(dialInfo.Addrs[0])
548- c.Assert(err, gc.IsNil)
549- jujutesting.AssertEchoArgs(c, "mongod",
550- "--noauth",
551- "--dbpath", "db",
552- "--sslOnNormalPorts",
553- "--sslPEMKeyFile", "server.pem",
554- "--sslPEMKeyPassword", "ignored",
555- "--bind_ip", "127.0.0.1",
556- "--port", portString,
557- "--noprealloc",
558- "--syslog",
559- "--smallfiles",
560- "--journal",
561- )
562-
563 // Second call succeeds, as the admin user is already there.
564 added, err = s.ensureAdminUser(c, dialInfo, "whomever", "whatever")
565 c.Assert(err, gc.IsNil)
566 c.Assert(added, jc.IsFalse)
567-
568- // There should have been no additional start/stop.
569- c.Assert(s.serviceStarts, gc.Equals, 1)
570- c.Assert(s.serviceStops, gc.Equals, 1)
571 }
572
573 func (s *EnsureAdminSuite) TestEnsureAdminUserError(c *gc.C) {
574@@ -119,7 +73,7 @@
575 c.Assert(err, gc.IsNil)
576 port, err := strconv.Atoi(portString)
577 c.Assert(err, gc.IsNil)
578- return mongo.EnsureAdminUser(mongo.EnsureAdminUserParams{
579+ return EnsureAdminUser(EnsureAdminUserParams{
580 DialInfo: dialInfo,
581 Port: port,
582 User: user,
583
584=== modified file 'agent/tools/diskmanager_test.go'
585--- agent/tools/diskmanager_test.go 2014-05-20 04:27:02 +0000
586+++ agent/tools/diskmanager_test.go 2014-05-22 14:33:28 +0000
587@@ -13,6 +13,7 @@
588
589 agenttools "launchpad.net/juju-core/agent/tools"
590 coretesting "launchpad.net/juju-core/testing"
591+ "launchpad.net/juju-core/testing/testbase"
592 coretools "launchpad.net/juju-core/tools"
593 "launchpad.net/juju-core/version"
594 )
595@@ -22,13 +23,13 @@
596 var _ agenttools.ToolsManager = (*agenttools.DiskManager)(nil)
597
598 type DiskManagerSuite struct {
599- coretesting.BaseSuite
600+ testbase.LoggingSuite
601 dataDir string
602 manager agenttools.ToolsManager
603 }
604
605 func (s *DiskManagerSuite) SetUpTest(c *gc.C) {
606- s.BaseSuite.SetUpTest(c)
607+ s.LoggingSuite.SetUpTest(c)
608 s.dataDir = c.MkDir()
609 s.manager = agenttools.NewDiskManager(s.dataDir)
610 }
611
612=== modified file 'agent/tools/tools_test.go'
613--- agent/tools/tools_test.go 2014-05-20 04:27:02 +0000
614+++ agent/tools/tools_test.go 2014-05-22 14:33:28 +0000
615@@ -21,14 +21,14 @@
616 )
617
618 type ToolsSuite struct {
619- testing.BaseSuite
620+ testbase.LoggingSuite
621 dataDir string
622 }
623
624 var _ = gc.Suite(&ToolsSuite{})
625
626 func (t *ToolsSuite) SetUpTest(c *gc.C) {
627- t.BaseSuite.SetUpTest(c)
628+ t.LoggingSuite.SetUpTest(c)
629 t.dataDir = c.MkDir()
630 }
631
632
633=== modified file 'bzr/bzr_test.go'
634--- bzr/bzr_test.go 2014-05-20 04:27:02 +0000
635+++ bzr/bzr_test.go 2014-05-22 14:33:28 +0000
636@@ -8,22 +8,22 @@
637 "os"
638 "os/exec"
639 "path/filepath"
640- stdtesting "testing"
641+ "testing"
642
643 gc "launchpad.net/gocheck"
644
645 "launchpad.net/juju-core/bzr"
646- "launchpad.net/juju-core/testing"
647+ "launchpad.net/juju-core/testing/testbase"
648 )
649
650-func Test(t *stdtesting.T) {
651+func Test(t *testing.T) {
652 gc.TestingT(t)
653 }
654
655 var _ = gc.Suite(&BzrSuite{})
656
657 type BzrSuite struct {
658- testing.BaseSuite
659+ testbase.LoggingSuite
660 b *bzr.Branch
661 }
662
663@@ -32,7 +32,7 @@
664 `
665
666 func (s *BzrSuite) SetUpTest(c *gc.C) {
667- s.BaseSuite.SetUpTest(c)
668+ s.LoggingSuite.SetUpTest(c)
669 bzrdir := c.MkDir()
670 s.PatchEnvironment("BZR_HOME", bzrdir)
671 err := os.Mkdir(filepath.Join(bzrdir, ".bazaar"), 0755)
672
673=== modified file 'charm/dir_test.go'
674--- charm/dir_test.go 2014-05-20 04:27:02 +0000
675+++ charm/dir_test.go 2014-05-22 14:33:28 +0000
676@@ -17,10 +17,11 @@
677
678 "launchpad.net/juju-core/charm"
679 "launchpad.net/juju-core/testing"
680+ "launchpad.net/juju-core/testing/testbase"
681 )
682
683 type DirSuite struct {
684- testing.BaseSuite
685+ testbase.LoggingSuite
686 }
687
688 var _ = gc.Suite(&DirSuite{})
689
690=== modified file 'cloudinit/cloudinit_test.go'
691--- cloudinit/cloudinit_test.go 2014-05-20 04:27:02 +0000
692+++ cloudinit/cloudinit_test.go 2014-05-22 14:33:28 +0000
693@@ -10,14 +10,14 @@
694 gc "launchpad.net/gocheck"
695
696 "launchpad.net/juju-core/cloudinit"
697- coretesting "launchpad.net/juju-core/testing"
698+ "launchpad.net/juju-core/testing/testbase"
699 sshtesting "launchpad.net/juju-core/utils/ssh/testing"
700 )
701
702 // TODO integration tests, but how?
703
704 type S struct {
705- coretesting.BaseSuite
706+ testbase.LoggingSuite
707 }
708
709 var _ = gc.Suite(S{})
710
711=== modified file 'cloudinit/sshinit/configure_test.go'
712--- cloudinit/sshinit/configure_test.go 2014-05-20 04:27:02 +0000
713+++ cloudinit/sshinit/configure_test.go 2014-05-22 14:33:28 +0000
714@@ -17,12 +17,13 @@
715 envtools "launchpad.net/juju-core/environs/tools"
716 "launchpad.net/juju-core/state/api/params"
717 coretesting "launchpad.net/juju-core/testing"
718+ "launchpad.net/juju-core/testing/testbase"
719 "launchpad.net/juju-core/tools"
720 "launchpad.net/juju-core/version"
721 )
722
723 type configureSuite struct {
724- coretesting.BaseSuite
725+ testbase.LoggingSuite
726 }
727
728 var _ = gc.Suite(&configureSuite{})
729
730=== modified file 'cmd/charm-admin/config_test.go'
731--- cmd/charm-admin/config_test.go 2014-05-20 04:27:02 +0000
732+++ cmd/charm-admin/config_test.go 2014-05-22 14:33:28 +0000
733@@ -12,10 +12,11 @@
734
735 "launchpad.net/juju-core/cmd"
736 "launchpad.net/juju-core/testing"
737+ "launchpad.net/juju-core/testing/testbase"
738 )
739
740 type ConfigSuite struct {
741- testing.BaseSuite
742+ testbase.LoggingSuite
743 }
744
745 var _ = gc.Suite(&ConfigSuite{})
746@@ -27,11 +28,11 @@
747 `
748
749 func (s *ConfigSuite) SetUpSuite(c *gc.C) {
750- s.BaseSuite.SetUpSuite(c)
751+ s.LoggingSuite.SetUpSuite(c)
752 }
753
754 func (s *ConfigSuite) TearDownSuite(c *gc.C) {
755- s.BaseSuite.TearDownSuite(c)
756+ s.LoggingSuite.TearDownSuite(c)
757 }
758
759 type SomeConfigCommand struct {
760
761=== modified file 'cmd/charm-admin/deletecharm_test.go'
762--- cmd/charm-admin/deletecharm_test.go 2014-05-20 04:27:02 +0000
763+++ cmd/charm-admin/deletecharm_test.go 2014-05-22 14:33:28 +0000
764@@ -13,10 +13,11 @@
765 "launchpad.net/juju-core/charm"
766 "launchpad.net/juju-core/store"
767 "launchpad.net/juju-core/testing"
768+ "launchpad.net/juju-core/testing/testbase"
769 )
770
771 type DeleteCharmSuite struct {
772- testing.BaseSuite
773+ testbase.LoggingSuite
774 }
775
776 var _ = gc.Suite(&DeleteCharmSuite{})
777@@ -26,11 +27,11 @@
778 `
779
780 func (s *DeleteCharmSuite) SetUpSuite(c *gc.C) {
781- s.BaseSuite.SetUpSuite(c)
782+ s.LoggingSuite.SetUpSuite(c)
783 }
784
785 func (s *DeleteCharmSuite) TearDownSuite(c *gc.C) {
786- s.BaseSuite.TearDownSuite(c)
787+ s.LoggingSuite.TearDownSuite(c)
788 }
789
790 func (s *DeleteCharmSuite) TestInit(c *gc.C) {
791
792=== modified file 'cmd/envcmd/environmentcommand_test.go'
793--- cmd/envcmd/environmentcommand_test.go 2014-05-16 01:33:13 +0000
794+++ cmd/envcmd/environmentcommand_test.go 2014-05-22 14:33:28 +0000
795@@ -20,13 +20,21 @@
796 )
797
798 type EnvironmentCommandSuite struct {
799- coretesting.FakeJujuHomeSuite
800+ home *coretesting.FakeHome
801 }
802
803 var _ = gc.Suite(&EnvironmentCommandSuite{})
804
805 func Test(t *testing.T) { gc.TestingT(t) }
806
807+func (s *EnvironmentCommandSuite) SetUpTest(c *gc.C) {
808+ s.home = coretesting.MakeEmptyFakeHome(c)
809+}
810+
811+func (s *EnvironmentCommandSuite) TearDownTest(c *gc.C) {
812+ s.home.Restore()
813+}
814+
815 func (s *EnvironmentCommandSuite) TestReadCurrentEnvironmentUnset(c *gc.C) {
816 env := envcmd.ReadCurrentEnvironment()
817 c.Assert(env, gc.Equals, "")
818@@ -40,9 +48,6 @@
819 }
820
821 func (s *EnvironmentCommandSuite) TestGetDefaultEnvironmentNothingSet(c *gc.C) {
822- envPath := coretesting.HomePath(".juju", "environments.yaml")
823- err := os.Remove(envPath)
824- c.Assert(err, gc.IsNil)
825 env, err := envcmd.GetDefaultEnvironment()
826 c.Assert(env, gc.Equals, "")
827 c.Assert(err, jc.Satisfies, environs.IsNoEnv)
828@@ -95,12 +100,12 @@
829 c.Assert(*envName, gc.Equals, "explicit")
830
831 // Take environment name from the default.
832- coretesting.WriteEnvironments(c, coretesting.MultipleEnvConfig)
833+ defer coretesting.MakeFakeHome(c, coretesting.MultipleEnvConfig).Restore()
834 testEnsureEnvName(c, coretesting.SampleEnvName)
835
836 // Take environment name from the one and only environment,
837 // even if it is not explicitly marked as default.
838- coretesting.WriteEnvironments(c, coretesting.SingleEnvConfigNoDefault)
839+ defer coretesting.MakeFakeHome(c, coretesting.SingleEnvConfigNoDefault).Restore()
840 testEnsureEnvName(c, coretesting.SampleEnvName)
841
842 // If there is a current-environment file, use that.
843@@ -109,16 +114,13 @@
844 }
845
846 func (s *EnvironmentCommandSuite) TestEnvironCommandInitErrors(c *gc.C) {
847- envPath := coretesting.HomePath(".juju", "environments.yaml")
848- err := os.Remove(envPath)
849- c.Assert(err, gc.IsNil)
850 cmd, _ := prepareEnvCommand(c, "")
851- err = cmd.Init(nil)
852+ err := cmd.Init(nil)
853 c.Assert(err, jc.Satisfies, environs.IsNoEnv)
854
855 // If there are multiple environments but no default,
856 // an error should be returned.
857- coretesting.WriteEnvironments(c, coretesting.MultipleEnvConfigNoDefault)
858+ defer coretesting.MakeFakeHome(c, coretesting.MultipleEnvConfigNoDefault).Restore()
859 cmd, _ = prepareEnvCommand(c, "")
860 err = cmd.Init(nil)
861 c.Assert(err, gc.Equals, envcmd.ErrNoEnvironmentSpecified)
862
863=== modified file 'cmd/filevar_test.go'
864--- cmd/filevar_test.go 2014-05-16 01:33:13 +0000
865+++ cmd/filevar_test.go 2014-05-22 14:33:28 +0000
866@@ -17,7 +17,6 @@
867 )
868
869 type FileVarSuite struct {
870- testing.FakeHomeSuite
871 ctx *cmd.Context
872 ValidPath string
873 InvalidPath string // invalid path refers to a file which is not readable
874@@ -26,7 +25,6 @@
875 var _ = gc.Suite(&FileVarSuite{})
876
877 func (s *FileVarSuite) SetUpTest(c *gc.C) {
878- s.FakeHomeSuite.SetUpTest(c)
879 s.ctx = testing.Context(c)
880 s.ValidPath = s.ctx.AbsPath("valid.yaml")
881 s.InvalidPath = s.ctx.AbsPath("invalid.yaml")
882@@ -41,6 +39,7 @@
883 }
884
885 func (s *FileVarSuite) TestTildeFileVar(c *gc.C) {
886+ defer testing.MakeEmptyFakeHome(c).Restore()
887 path := filepath.Join(osenv.Home(), "config.yaml")
888 err := ioutil.WriteFile(path, []byte("abc"), 0644)
889 c.Assert(err, gc.IsNil)
890
891=== renamed file 'cmd/juju/user_add.go' => 'cmd/juju/adduser.go'
892=== renamed file 'cmd/juju/user_add_test.go' => 'cmd/juju/adduser_test.go'
893=== modified file 'cmd/juju/authorizedkeys_test.go'
894--- cmd/juju/authorizedkeys_test.go 2014-05-16 04:20:04 +0000
895+++ cmd/juju/authorizedkeys_test.go 2014-05-22 14:33:28 +0000
896@@ -15,11 +15,13 @@
897 keymanagerserver "launchpad.net/juju-core/state/apiserver/keymanager"
898 keymanagertesting "launchpad.net/juju-core/state/apiserver/keymanager/testing"
899 coretesting "launchpad.net/juju-core/testing"
900+ "launchpad.net/juju-core/testing/testbase"
901 sshtesting "launchpad.net/juju-core/utils/ssh/testing"
902 )
903
904 type AuthorizedKeysSuite struct {
905- coretesting.FakeJujuHomeSuite
906+ testbase.LoggingSuite
907+ jujuHome *coretesting.FakeHome
908 }
909
910 var _ = gc.Suite(&AuthorizedKeysSuite{})
911@@ -32,6 +34,16 @@
912 "list",
913 }
914
915+func (s *AuthorizedKeysSuite) SetUpTest(c *gc.C) {
916+ s.LoggingSuite.SetUpTest(c)
917+ s.jujuHome = coretesting.MakeEmptyFakeHome(c)
918+}
919+
920+func (s *AuthorizedKeysSuite) TearDownTest(c *gc.C) {
921+ s.jujuHome.Restore()
922+ s.LoggingSuite.TearDownTest(c)
923+}
924+
925 func (s *AuthorizedKeysSuite) TestHelpCommands(c *gc.C) {
926 // Check that we have correctly registered all the sub commands
927 // by checking the help output.
928
929=== modified file 'cmd/juju/bootstrap_test.go'
930--- cmd/juju/bootstrap_test.go 2014-05-21 22:15:10 +0000
931+++ cmd/juju/bootstrap_test.go 2014-05-22 14:33:28 +0000
932@@ -5,7 +5,6 @@
933
934 import (
935 "fmt"
936- "os"
937 "strings"
938
939 "github.com/juju/errors"
940@@ -31,12 +30,13 @@
941 "launchpad.net/juju-core/juju/arch"
942 "launchpad.net/juju-core/provider/dummy"
943 coretesting "launchpad.net/juju-core/testing"
944+ "launchpad.net/juju-core/testing/testbase"
945 coretools "launchpad.net/juju-core/tools"
946 "launchpad.net/juju-core/version"
947 )
948
949 type BootstrapSuite struct {
950- coretesting.FakeJujuHomeSuite
951+ testbase.LoggingSuite
952 coretesting.MgoSuite
953 envtesting.ToolsFixture
954 }
955@@ -44,12 +44,12 @@
956 var _ = gc.Suite(&BootstrapSuite{})
957
958 func (s *BootstrapSuite) SetUpSuite(c *gc.C) {
959- s.FakeJujuHomeSuite.SetUpSuite(c)
960+ s.LoggingSuite.SetUpSuite(c)
961 s.MgoSuite.SetUpSuite(c)
962 }
963
964 func (s *BootstrapSuite) SetUpTest(c *gc.C) {
965- s.FakeJujuHomeSuite.SetUpTest(c)
966+ s.LoggingSuite.SetUpTest(c)
967 s.MgoSuite.SetUpTest(c)
968 s.ToolsFixture.SetUpTest(c)
969
970@@ -62,13 +62,13 @@
971
972 func (s *BootstrapSuite) TearDownSuite(c *gc.C) {
973 s.MgoSuite.TearDownSuite(c)
974- s.FakeJujuHomeSuite.TearDownSuite(c)
975+ s.LoggingSuite.TearDownSuite(c)
976 }
977
978 func (s *BootstrapSuite) TearDownTest(c *gc.C) {
979 s.ToolsFixture.TearDownTest(c)
980 s.MgoSuite.TearDownTest(c)
981- s.FakeJujuHomeSuite.TearDownTest(c)
982+ s.LoggingSuite.TearDownTest(c)
983 dummy.Reset()
984 }
985
986@@ -130,7 +130,8 @@
987 toolsVersions = append(toolsVersions, testVersion)
988 }
989 }
990- resetJujuHome(c)
991+ _, fake := makeEmptyFakeHome(c)
992+ defer fake.Restore()
993 sourceDir := createToolsSource(c, toolsVersions)
994 s.PatchValue(&envtools.DefaultBaseURL, sourceDir)
995
996@@ -176,7 +177,8 @@
997 func (test bootstrapTest) run(c *gc.C) {
998 // Create home with dummy provider and remove all
999 // of its envtools.
1000- env := resetJujuHome(c)
1001+ env, fake := makeEmptyFakeHome(c)
1002+ defer fake.Restore()
1003
1004 if test.version != "" {
1005 useVersion := strings.Replace(test.version, "%LTS%", config.LatestLtsSeries(), 1)
1006@@ -368,7 +370,8 @@
1007 }}
1008
1009 func (s *BootstrapSuite) TestBootstrapTwice(c *gc.C) {
1010- env := resetJujuHome(c)
1011+ env, fake := makeEmptyFakeHome(c)
1012+ defer fake.Restore()
1013 defaultSeriesVersion := version.Current
1014 defaultSeriesVersion.Series = config.PreferredSeries(env.Config())
1015 // Force a dev version by having an odd minor version number.
1016@@ -400,7 +403,8 @@
1017 s.PatchValue(&getBootstrapFuncs, func() BootstrapInterface {
1018 return _bootstrap
1019 })
1020- resetJujuHome(c)
1021+ _, fake := makeEmptyFakeHome(c)
1022+ defer fake.Restore()
1023
1024 ctx, err := coretesting.RunCommand(c, envcmd.Wrap(&BootstrapCommand{}),
1025 []string{"--upload-tools", argVariant, "foo,bar"})
1026@@ -411,7 +415,8 @@
1027 }
1028
1029 func (s *BootstrapSuite) TestBootstrapJenvWarning(c *gc.C) {
1030- env := resetJujuHome(c)
1031+ env, fake := makeEmptyFakeHome(c)
1032+ defer fake.Restore()
1033 defaultSeriesVersion := version.Current
1034 defaultSeriesVersion.Series = config.PreferredSeries(env.Config())
1035 // Force a dev version by having an odd minor version number.
1036@@ -437,7 +442,8 @@
1037
1038 func (s *BootstrapSuite) TestInvalidLocalSource(c *gc.C) {
1039 s.PatchValue(&version.Current.Number, version.MustParse("1.2.0"))
1040- env := resetJujuHome(c)
1041+ env, fake := makeEmptyFakeHome(c)
1042+ defer fake.Restore()
1043
1044 // Bootstrap the environment with an invalid source.
1045 // The command returns with an error.
1046@@ -485,7 +491,8 @@
1047
1048 func (s *BootstrapSuite) TestUploadLocalImageMetadata(c *gc.C) {
1049 sourceDir, expected := createImageMetadata(c)
1050- env := resetJujuHome(c)
1051+ env, fake := makeEmptyFakeHome(c)
1052+ defer fake.Restore()
1053
1054 // Bootstrap the environment with the valid source.
1055 // Force a dev version by having an odd minor version number.
1056@@ -506,7 +513,8 @@
1057 func (s *BootstrapSuite) TestAutoSyncLocalSource(c *gc.C) {
1058 sourceDir := createToolsSource(c, vAll)
1059 s.PatchValue(&version.Current.Number, version.MustParse("1.2.0"))
1060- env := resetJujuHome(c)
1061+ env, fake := makeEmptyFakeHome(c)
1062+ defer fake.Restore()
1063
1064 // Bootstrap the environment with the valid source.
1065 // The bootstrapping has to show no error, because the tools
1066@@ -534,7 +542,9 @@
1067
1068 // Create home with dummy provider and remove all
1069 // of its envtools.
1070- return resetJujuHome(c)
1071+ env, fake := makeEmptyFakeHome(c)
1072+ s.AddCleanup(func(*gc.C) { fake.Restore() })
1073+ return env
1074 }
1075
1076 func (s *BootstrapSuite) TestAutoUploadAfterFailedSync(c *gc.C) {
1077@@ -602,7 +612,8 @@
1078 }
1079
1080 func (s *BootstrapSuite) TestBootstrapDestroy(c *gc.C) {
1081- resetJujuHome(c)
1082+ _, fake := makeEmptyFakeHome(c)
1083+ defer fake.Restore()
1084 devVersion := version.Current
1085 // Force a dev version by having an odd minor version number.
1086 // This is because we have not uploaded any tools and auto
1087@@ -640,19 +651,16 @@
1088 return source
1089 }
1090
1091-// resetJujuHome restores an new, clean Juju home environment without tools.
1092-func resetJujuHome(c *gc.C) environs.Environ {
1093- jenvDir := coretesting.HomePath(".juju", "environments")
1094- err := os.RemoveAll(jenvDir)
1095- c.Assert(err, gc.IsNil)
1096- coretesting.WriteEnvironments(c, envConfig)
1097+// makeEmptyFakeHome creates a faked home without envtools.
1098+func makeEmptyFakeHome(c *gc.C) (environs.Environ, *coretesting.FakeHome) {
1099+ fake := coretesting.MakeFakeHome(c, envConfig)
1100 dummy.Reset()
1101 store, err := configstore.Default()
1102 c.Assert(err, gc.IsNil)
1103 env, err := environs.PrepareFromName("peckham", nullContext(c), store)
1104 c.Assert(err, gc.IsNil)
1105 envtesting.RemoveAllTools(c, env)
1106- return env
1107+ return env, fake
1108 }
1109
1110 // checkTools check if the environment contains the passed envtools.
1111
1112=== modified file 'cmd/juju/cmd_test.go'
1113--- cmd/juju/cmd_test.go 2014-05-16 01:33:13 +0000
1114+++ cmd/juju/cmd_test.go 2014-05-22 14:33:28 +0000
1115@@ -22,6 +22,7 @@
1116
1117 type CmdSuite struct {
1118 testing.JujuConnSuite
1119+ home *coretesting.FakeHome
1120 }
1121
1122 var _ = gc.Suite(&CmdSuite{})
1123@@ -49,10 +50,11 @@
1124
1125 func (s *CmdSuite) SetUpTest(c *gc.C) {
1126 s.JujuConnSuite.SetUpTest(c)
1127- coretesting.WriteEnvironments(c, envConfig, "peckham", "walthamstow", "brokenenv")
1128+ s.home = coretesting.MakeFakeHome(c, envConfig, "peckham", "walthamstow", "brokenenv")
1129 }
1130
1131 func (s *CmdSuite) TearDownTest(c *gc.C) {
1132+ s.home.Restore()
1133 s.JujuConnSuite.TearDownTest(c)
1134 }
1135
1136
1137=== modified file 'cmd/juju/debuglog_test.go'
1138--- cmd/juju/debuglog_test.go 2014-05-15 05:14:01 +0000
1139+++ cmd/juju/debuglog_test.go 2014-05-22 14:33:28 +0000
1140@@ -21,7 +21,7 @@
1141 )
1142
1143 type DebugLogSuite struct {
1144- testing.FakeJujuHomeSuite
1145+ testing.FakeHomeSuite
1146 }
1147
1148 var _ = gc.Suite(&DebugLogSuite{})
1149
1150=== modified file 'cmd/juju/deploy.go'
1151--- cmd/juju/deploy.go 2014-05-15 10:12:36 +0000
1152+++ cmd/juju/deploy.go 2014-05-22 14:33:28 +0000
1153@@ -66,32 +66,6 @@
1154 by set-constraints).
1155
1156 Charms can be deployed to a specific machine using the --to argument.
1157-If the destination is an LXC container the default is to use lxc-clone
1158-to create the container where possible. For Ubuntu deployments, lxc-clone
1159-is supported for the trusty OS series and later. A 'template' container is
1160-created with the name
1161- juju-<series>-template
1162-where <series> is the OS series, for example 'juju-trusty-template'.
1163-
1164-You can override the use of clone by changing the provider configuration:
1165- lxc-clone: false
1166-
1167-If you have the main container directory mounted on a btrfs partition,
1168-then the clone will be using btrfs snapshots to create the containers.
1169-This means that clones use up much less disk space. If you do not have btrfs,
1170-lxc will attempt to use aufs (an overlay type filesystem). You can
1171-explicitly ask Juju to create full containers and not overlays by specifying
1172-the following in the provider configuration:
1173- lxc-clone-aufs: false
1174-
1175-Examples:
1176- juju deploy mysql --to 23 (deploy to machine 23)
1177- juju deploy mysql --to 24/lxc/3 (deploy to lxc container 3 on host machine 24)
1178- juju deploy mysql --to lxc:25 (deploy to a new lxc container on host machine 25)
1179-
1180- juju deploy mysql -n 5 --constraints mem=8G (deploy 5 instances of mysql with at least 8 GB of RAM each)
1181-
1182- juju deploy mysql --networks=storage,mynet --exclude-networks=logging
1183
1184 Like constraints, service-specific network requirements can be
1185 specified with --networks and --exclude-networks arguments, both can
1186@@ -101,6 +75,15 @@
1187 and to ensure none of the networks in --exclude-networks are added to
1188 the service's machines. Not supported on all providers.
1189
1190+Examples:
1191+ juju deploy mysql --to 23 (Deploy to machine 23)
1192+ juju deploy mysql --to 24/lxc/3 (Deploy to lxc container 3 on host machine 24)
1193+ juju deploy mysql --to lxc:25 (Deploy to a new lxc container on host machine 25)
1194+
1195+ juju deploy mysql -n 5 --constraints mem=8G (deploy 5 instances of mysql with at least 8 GB of RAM each)
1196+
1197+ juju deploy mysql --networks=storage,mynet --exclude-networks=logging
1198+
1199 See Also:
1200 juju help constraints
1201 juju help set-constraints
1202
1203=== modified file 'cmd/juju/help_topics.go'
1204--- cmd/juju/help_topics.go 2014-05-15 10:12:36 +0000
1205+++ cmd/juju/help_topics.go 2014-05-22 14:33:28 +0000
1206@@ -79,23 +79,22 @@
1207 juju deploy wordpress
1208 juju add-relation wordpress mysql
1209
1210-For Ubuntu deployments, the local provider will prefer to use lxc-clone to create
1211-the machines for the trusty OS series and later.
1212-A 'template' container is created with the name
1213+As of trusty, the local provider will prefer to use lxc-clone to create
1214+the machines. A 'template' container is created with the name
1215 juju-<series>-template
1216-where <series> is the OS series, for example 'juju-trusty-template'.
1217+where <series> is the OS series, for example 'juju-precise-template'.
1218 You can override the use of clone by specifying
1219- lxc-clone: true
1220+ use-clone: true
1221 or
1222- lxc-clone: false
1223+ use-clone: false
1224 in the configuration for your local provider. If you have the main container
1225 directory mounted on a btrfs partition, then the clone will be using btrfs
1226-snapshots to create the containers. This means that clones use up much
1227+snapshots to create the containers. This means that the clones use up much
1228 less disk space. If you do not have btrfs, lxc will attempt to use aufs
1229-(an overlay type filesystem). You can explicitly ask Juju to create
1230+(which is an overlay type filesystem). You can explicitly ask Juju to create
1231 full containers and not overlays by specifying the following in the provider
1232 configuration:
1233- lxc-clone-aufs: false
1234+ use-clone-aufs: false
1235
1236
1237 References:
1238
1239=== modified file 'cmd/juju/helptool_test.go'
1240--- cmd/juju/helptool_test.go 2014-05-16 04:20:04 +0000
1241+++ cmd/juju/helptool_test.go 2014-05-22 14:33:28 +0000
1242@@ -13,11 +13,19 @@
1243 )
1244
1245 type HelpToolSuite struct {
1246- testing.FakeJujuHomeSuite
1247+ home *testing.FakeHome
1248 }
1249
1250 var _ = gc.Suite(&HelpToolSuite{})
1251
1252+func (suite *HelpToolSuite) SetUpTest(c *gc.C) {
1253+ suite.home = testing.MakeSampleHome(c)
1254+}
1255+
1256+func (suite *HelpToolSuite) TearDownTest(c *gc.C) {
1257+ suite.home.Restore()
1258+}
1259+
1260 func (suite *HelpToolSuite) TestHelpToolHelp(c *gc.C) {
1261 output := badrun(c, 0, "help", "help-tool")
1262 c.Assert(output, gc.Equals, `usage: juju help-tool [tool]
1263
1264=== modified file 'cmd/juju/init_test.go'
1265--- cmd/juju/init_test.go 2014-05-16 04:20:04 +0000
1266+++ cmd/juju/init_test.go 2014-05-22 14:33:28 +0000
1267@@ -6,7 +6,6 @@
1268 import (
1269 "bytes"
1270 "io/ioutil"
1271- "os"
1272 "strings"
1273
1274 gc "launchpad.net/gocheck"
1275@@ -16,7 +15,6 @@
1276 )
1277
1278 type InitSuite struct {
1279- testing.FakeJujuHomeSuite
1280 }
1281
1282 var _ = gc.Suite(&InitSuite{})
1283@@ -24,9 +22,7 @@
1284 // The environments.yaml is created by default if it
1285 // does not already exist.
1286 func (*InitSuite) TestBoilerPlateEnvironment(c *gc.C) {
1287- envPath := testing.HomePath(".juju", "environments.yaml")
1288- err := os.Remove(envPath)
1289- c.Assert(err, gc.IsNil)
1290+ defer testing.MakeEmptyFakeHome(c).Restore()
1291 ctx := testing.Context(c)
1292 code := cmd.Main(&InitCommand{}, ctx, nil)
1293 c.Check(code, gc.Equals, 0)
1294@@ -43,9 +39,7 @@
1295 // The boilerplate is sent to stdout with --show, and the environments.yaml
1296 // is not created.
1297 func (*InitSuite) TestBoilerPlatePrinted(c *gc.C) {
1298- envPath := testing.HomePath(".juju", "environments.yaml")
1299- err := os.Remove(envPath)
1300- c.Assert(err, gc.IsNil)
1301+ defer testing.MakeEmptyFakeHome(c).Restore()
1302 ctx := testing.Context(c)
1303 code := cmd.Main(&InitCommand{}, ctx, []string{"--show"})
1304 c.Check(code, gc.Equals, 0)
1305@@ -53,7 +47,7 @@
1306 strippedOut := strings.Replace(outStr, "\n", "", -1)
1307 c.Check(strippedOut, gc.Matches, ".*# This is the Juju config file, which you can use.*")
1308 environpath := testing.HomePath(".juju", "environments.yaml")
1309- _, err = ioutil.ReadFile(environpath)
1310+ _, err := ioutil.ReadFile(environpath)
1311 c.Assert(err, gc.NotNil)
1312 }
1313
1314@@ -68,7 +62,7 @@
1315 // An existing environments.yaml will not be overwritten without
1316 // the explicit -f option.
1317 func (*InitSuite) TestExistingEnvironmentNotOverwritten(c *gc.C) {
1318- testing.WriteEnvironments(c, existingEnv)
1319+ defer testing.MakeFakeHome(c, existingEnv, "existing").Restore()
1320
1321 ctx := testing.Context(c)
1322 code := cmd.Main(&InitCommand{}, ctx, nil)
1323@@ -85,7 +79,7 @@
1324 // An existing environments.yaml will be overwritten when -f is
1325 // given explicitly.
1326 func (*InitSuite) TestExistingEnvironmentOverwritten(c *gc.C) {
1327- testing.WriteEnvironments(c, existingEnv)
1328+ defer testing.MakeFakeHome(c, existingEnv, "existing").Restore()
1329
1330 ctx := testing.Context(c)
1331 code := cmd.Main(&InitCommand{}, ctx, []string{"-f"})
1332
1333=== modified file 'cmd/juju/main.go'
1334--- cmd/juju/main.go 2014-05-20 01:23:55 +0000
1335+++ cmd/juju/main.go 2014-05-22 14:33:28 +0000
1336@@ -141,9 +141,6 @@
1337 // Manage authorized ssh keys.
1338 r.Register(NewAuthorizedKeysCommand())
1339
1340- // Manage users and access
1341- r.Register(NewUserCommand())
1342-
1343 // Manage state server availability.
1344 r.Register(wrapEnvCommand(&EnsureAvailabilityCommand{}))
1345
1346
1347=== modified file 'cmd/juju/main_test.go'
1348--- cmd/juju/main_test.go 2014-05-20 01:23:55 +0000
1349+++ cmd/juju/main_test.go 2014-05-22 14:33:28 +0000
1350@@ -31,7 +31,7 @@
1351 }
1352
1353 type MainSuite struct {
1354- testing.FakeJujuHomeSuite
1355+ testing.FakeHomeSuite
1356 }
1357
1358 var _ = gc.Suite(&MainSuite{})
1359@@ -79,6 +79,7 @@
1360 }
1361
1362 func (s *MainSuite) TestRunMain(c *gc.C) {
1363+ defer testing.MakeSampleHome(c).Restore()
1364 // The test array structure needs to be inline here as some of the
1365 // expected values below use deployHelpText(). This constructs the deploy
1366 // command and runs gets the help for it. When the deploy command is
1367@@ -183,6 +184,7 @@
1368
1369 func (s *MainSuite) TestActualRunJujuArgsBeforeCommand(c *gc.C) {
1370 c.Skip("breaks test isolation: lp:1233601")
1371+ defer testing.MakeFakeHomeNoEnvironments(c, "one").Restore()
1372 // Check global args work when specified before command
1373 msg := breakJuju(c, "Bootstrap")
1374 logpath := filepath.Join(c.MkDir(), "log")
1375@@ -196,6 +198,7 @@
1376
1377 func (s *MainSuite) TestActualRunJujuArgsAfterCommand(c *gc.C) {
1378 c.Skip("breaks test isolation: lp:1233601")
1379+ defer testing.MakeFakeHomeNoEnvironments(c, "one").Restore()
1380 // Check global args work when specified after command
1381 msg := breakJuju(c, "Bootstrap")
1382 logpath := filepath.Join(c.MkDir(), "log")
1383@@ -259,7 +262,6 @@
1384 "unset-environment",
1385 "upgrade-charm",
1386 "upgrade-juju",
1387- "user",
1388 "version",
1389 }
1390
1391
1392=== modified file 'cmd/juju/plugin_test.go'
1393--- cmd/juju/plugin_test.go 2014-05-15 05:14:01 +0000
1394+++ cmd/juju/plugin_test.go 2014-05-22 14:33:28 +0000
1395@@ -15,24 +15,28 @@
1396 gc "launchpad.net/gocheck"
1397
1398 "launchpad.net/juju-core/testing"
1399+ "launchpad.net/juju-core/testing/testbase"
1400 )
1401
1402 type PluginSuite struct {
1403- testing.FakeJujuHomeSuite
1404+ testbase.LoggingSuite
1405 oldPath string
1406+ home *testing.FakeHome
1407 }
1408
1409 var _ = gc.Suite(&PluginSuite{})
1410
1411 func (suite *PluginSuite) SetUpTest(c *gc.C) {
1412- suite.FakeJujuHomeSuite.SetUpTest(c)
1413+ suite.LoggingSuite.SetUpTest(c)
1414 suite.oldPath = os.Getenv("PATH")
1415+ suite.home = testing.MakeSampleHome(c)
1416 os.Setenv("PATH", "/bin:"+testing.HomePath())
1417 }
1418
1419 func (suite *PluginSuite) TearDownTest(c *gc.C) {
1420+ suite.home.Restore()
1421 os.Setenv("PATH", suite.oldPath)
1422- suite.FakeJujuHomeSuite.TearDownTest(c)
1423+ suite.LoggingSuite.TearDownTest(c)
1424 }
1425
1426 func (*PluginSuite) TestFindPlugins(c *gc.C) {
1427
1428=== modified file 'cmd/juju/publish_test.go'
1429--- cmd/juju/publish_test.go 2014-05-15 05:14:01 +0000
1430+++ cmd/juju/publish_test.go 2014-05-22 14:33:28 +0000
1431@@ -14,14 +14,16 @@
1432 "launchpad.net/juju-core/cmd"
1433 "launchpad.net/juju-core/cmd/envcmd"
1434 "launchpad.net/juju-core/testing"
1435+ "launchpad.net/juju-core/testing/testbase"
1436 )
1437
1438 // Sadly, this is a very slow test suite, heavily dominated by calls to bzr.
1439
1440 type PublishSuite struct {
1441- testing.FakeJujuHomeSuite
1442+ testbase.LoggingSuite
1443 testing.HTTPSuite
1444
1445+ home *testing.FakeHome
1446 dir string
1447 oldBaseURL string
1448 branch *bzr.Branch
1449@@ -57,7 +59,7 @@
1450 const pollDelay = testing.ShortWait
1451
1452 func (s *PublishSuite) SetUpSuite(c *gc.C) {
1453- s.FakeJujuHomeSuite.SetUpSuite(c)
1454+ s.LoggingSuite.SetUpSuite(c)
1455 s.HTTPSuite.SetUpSuite(c)
1456
1457 s.oldBaseURL = charm.Store.BaseURL
1458@@ -65,16 +67,16 @@
1459 }
1460
1461 func (s *PublishSuite) TearDownSuite(c *gc.C) {
1462- s.FakeJujuHomeSuite.TearDownSuite(c)
1463+ s.LoggingSuite.TearDownSuite(c)
1464 s.HTTPSuite.TearDownSuite(c)
1465
1466 charm.Store.BaseURL = s.oldBaseURL
1467 }
1468
1469 func (s *PublishSuite) SetUpTest(c *gc.C) {
1470- s.FakeJujuHomeSuite.SetUpTest(c)
1471+ s.LoggingSuite.SetUpTest(c)
1472 s.HTTPSuite.SetUpTest(c)
1473- s.FakeJujuHomeSuite.Home.AddFiles(c, testing.TestFile{
1474+ s.home = testing.MakeSampleHome(c, testing.TestFile{
1475 Name: ".bazaar/bazaar.conf",
1476 Data: "[DEFAULT]\nemail = Test <testing@testing.invalid>\n",
1477 })
1478@@ -86,8 +88,9 @@
1479 }
1480
1481 func (s *PublishSuite) TearDownTest(c *gc.C) {
1482+ s.home.Restore()
1483 s.HTTPSuite.TearDownTest(c)
1484- s.FakeJujuHomeSuite.TearDownTest(c)
1485+ s.LoggingSuite.TearDownTest(c)
1486 }
1487
1488 func (s *PublishSuite) TestNoBranch(c *gc.C) {
1489
1490=== modified file 'cmd/juju/run_test.go'
1491--- cmd/juju/run_test.go 2014-05-15 05:14:01 +0000
1492+++ cmd/juju/run_test.go 2014-05-22 14:33:28 +0000
1493@@ -18,7 +18,7 @@
1494 )
1495
1496 type RunSuite struct {
1497- testing.FakeJujuHomeSuite
1498+ testing.FakeHomeSuite
1499 }
1500
1501 var _ = gc.Suite(&RunSuite{})
1502
1503=== modified file 'cmd/juju/switch_test.go'
1504--- cmd/juju/switch_test.go 2014-05-16 04:20:04 +0000
1505+++ cmd/juju/switch_test.go 2014-05-22 14:33:28 +0000
1506@@ -14,51 +14,50 @@
1507 )
1508
1509 type SwitchSimpleSuite struct {
1510- testing.FakeJujuHomeSuite
1511 }
1512
1513 var _ = gc.Suite(&SwitchSimpleSuite{})
1514
1515 func (*SwitchSimpleSuite) TestNoEnvironment(c *gc.C) {
1516- envPath := testing.HomePath(".juju", "environments.yaml")
1517- err := os.Remove(envPath)
1518- c.Assert(err, gc.IsNil)
1519- _, err = testing.RunCommand(c, &SwitchCommand{}, nil)
1520+ defer testing.MakeEmptyFakeHome(c).Restore()
1521+ _, err := testing.RunCommand(c, &SwitchCommand{}, nil)
1522 c.Assert(err, gc.ErrorMatches, "couldn't read the environment")
1523 }
1524
1525 func (*SwitchSimpleSuite) TestNoDefault(c *gc.C) {
1526- testing.WriteEnvironments(c, testing.MultipleEnvConfigNoDefault)
1527+ defer testing.MakeFakeHome(c, testing.MultipleEnvConfigNoDefault).Restore()
1528 _, err := testing.RunCommand(c, &SwitchCommand{}, nil)
1529 c.Assert(err, gc.ErrorMatches, "no currently specified environment")
1530 }
1531
1532 func (*SwitchSimpleSuite) TestShowsDefault(c *gc.C) {
1533- testing.WriteEnvironments(c, testing.MultipleEnvConfig)
1534+ defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
1535 context, err := testing.RunCommand(c, &SwitchCommand{}, nil)
1536 c.Assert(err, gc.IsNil)
1537 c.Assert(testing.Stdout(context), gc.Equals, "erewhemos\n")
1538 }
1539
1540-func (s *SwitchSimpleSuite) TestCurrentEnvironmentHasPrecidence(c *gc.C) {
1541- testing.WriteEnvironments(c, testing.MultipleEnvConfig)
1542- s.FakeHomeSuite.Home.AddFiles(c, testing.TestFile{".juju/current-environment", "fubar"})
1543+func (*SwitchSimpleSuite) TestCurrentEnvironmentHasPrecidence(c *gc.C) {
1544+ home := testing.MakeFakeHome(c, testing.MultipleEnvConfig)
1545+ defer home.Restore()
1546+ home.AddFiles(c, []testing.TestFile{{".juju/current-environment", "fubar"}})
1547 context, err := testing.RunCommand(c, &SwitchCommand{}, nil)
1548 c.Assert(err, gc.IsNil)
1549 c.Assert(testing.Stdout(context), gc.Equals, "fubar\n")
1550 }
1551
1552 func (*SwitchSimpleSuite) TestShowsJujuEnv(c *gc.C) {
1553- testing.WriteEnvironments(c, testing.MultipleEnvConfig)
1554+ defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
1555 os.Setenv("JUJU_ENV", "using-env")
1556 context, err := testing.RunCommand(c, &SwitchCommand{}, nil)
1557 c.Assert(err, gc.IsNil)
1558 c.Assert(testing.Stdout(context), gc.Equals, "using-env\n")
1559 }
1560
1561-func (s *SwitchSimpleSuite) TestJujuEnvOverCurrentEnvironment(c *gc.C) {
1562- testing.WriteEnvironments(c, testing.MultipleEnvConfig)
1563- s.FakeHomeSuite.Home.AddFiles(c, testing.TestFile{".juju/current-environment", "fubar"})
1564+func (*SwitchSimpleSuite) TestJujuEnvOverCurrentEnvironment(c *gc.C) {
1565+ home := testing.MakeFakeHome(c, testing.MultipleEnvConfig)
1566+ defer home.Restore()
1567+ home.AddFiles(c, []testing.TestFile{{".juju/current-environment", "fubar"}})
1568 os.Setenv("JUJU_ENV", "using-env")
1569 context, err := testing.RunCommand(c, &SwitchCommand{}, nil)
1570 c.Assert(err, gc.IsNil)
1571@@ -66,7 +65,7 @@
1572 }
1573
1574 func (*SwitchSimpleSuite) TestSettingWritesFile(c *gc.C) {
1575- testing.WriteEnvironments(c, testing.MultipleEnvConfig)
1576+ defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
1577 context, err := testing.RunCommand(c, &SwitchCommand{}, []string{"erewhemos-2"})
1578 c.Assert(err, gc.IsNil)
1579 c.Assert(testing.Stdout(context), gc.Equals, "erewhemos -> erewhemos-2\n")
1580@@ -74,13 +73,13 @@
1581 }
1582
1583 func (*SwitchSimpleSuite) TestSettingToUnknown(c *gc.C) {
1584- testing.WriteEnvironments(c, testing.MultipleEnvConfig)
1585+ defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
1586 _, err := testing.RunCommand(c, &SwitchCommand{}, []string{"unknown"})
1587 c.Assert(err, gc.ErrorMatches, `"unknown" is not a name of an existing defined environment`)
1588 }
1589
1590 func (*SwitchSimpleSuite) TestSettingWhenJujuEnvSet(c *gc.C) {
1591- testing.WriteEnvironments(c, testing.MultipleEnvConfig)
1592+ defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
1593 os.Setenv("JUJU_ENV", "using-env")
1594 _, err := testing.RunCommand(c, &SwitchCommand{}, []string{"erewhemos-2"})
1595 c.Assert(err, gc.ErrorMatches, `cannot switch when JUJU_ENV is overriding the environment \(set to "using-env"\)`)
1596@@ -91,14 +90,14 @@
1597 `
1598
1599 func (*SwitchSimpleSuite) TestListEnvironments(c *gc.C) {
1600- testing.WriteEnvironments(c, testing.MultipleEnvConfig)
1601+ defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
1602 context, err := testing.RunCommand(c, &SwitchCommand{}, []string{"--list"})
1603 c.Assert(err, gc.IsNil)
1604 c.Assert(testing.Stdout(context), gc.Equals, expectedEnvironments)
1605 }
1606
1607 func (*SwitchSimpleSuite) TestListEnvironmentsOSJujuEnvSet(c *gc.C) {
1608- testing.WriteEnvironments(c, testing.MultipleEnvConfig)
1609+ defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
1610 os.Setenv("JUJU_ENV", "using-env")
1611 context, err := testing.RunCommand(c, &SwitchCommand{}, []string{"--list"})
1612 c.Assert(err, gc.IsNil)
1613@@ -106,13 +105,13 @@
1614 }
1615
1616 func (*SwitchSimpleSuite) TestListEnvironmentsAndChange(c *gc.C) {
1617- testing.WriteEnvironments(c, testing.MultipleEnvConfig)
1618+ defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
1619 _, err := testing.RunCommand(c, &SwitchCommand{}, []string{"--list", "erewhemos-2"})
1620 c.Assert(err, gc.ErrorMatches, "cannot switch and list at the same time")
1621 }
1622
1623 func (*SwitchSimpleSuite) TestTooManyParams(c *gc.C) {
1624- testing.WriteEnvironments(c, testing.MultipleEnvConfig)
1625+ defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
1626 _, err := testing.RunCommand(c, &SwitchCommand{}, []string{"foo", "bar"})
1627 c.Assert(err, gc.ErrorMatches, `unrecognized args: ."bar".`)
1628 }
1629
1630=== modified file 'cmd/juju/synctools_test.go'
1631--- cmd/juju/synctools_test.go 2014-05-16 04:20:04 +0000
1632+++ cmd/juju/synctools_test.go 2014-05-22 14:33:28 +0000
1633@@ -18,10 +18,12 @@
1634 "launchpad.net/juju-core/environs/sync"
1635 "launchpad.net/juju-core/provider/dummy"
1636 coretesting "launchpad.net/juju-core/testing"
1637+ "launchpad.net/juju-core/testing/testbase"
1638 )
1639
1640 type syncToolsSuite struct {
1641- coretesting.FakeJujuHomeSuite
1642+ testbase.LoggingSuite
1643+ home *coretesting.FakeHome
1644 configStore configstore.Storage
1645 localStorage string
1646
1647@@ -31,10 +33,10 @@
1648 var _ = gc.Suite(&syncToolsSuite{})
1649
1650 func (s *syncToolsSuite) SetUpTest(c *gc.C) {
1651- s.FakeJujuHomeSuite.SetUpTest(c)
1652+ s.LoggingSuite.SetUpTest(c)
1653
1654 // Create a target environments.yaml and make sure its environment is empty.
1655- coretesting.WriteEnvironments(c, `
1656+ s.home = coretesting.MakeFakeHome(c, `
1657 environments:
1658 test-target:
1659 type: dummy
1660@@ -50,7 +52,8 @@
1661 func (s *syncToolsSuite) TearDownTest(c *gc.C) {
1662 syncTools = s.origSyncTools
1663 dummy.Reset()
1664- s.FakeJujuHomeSuite.TearDownTest(c)
1665+ s.home.Restore()
1666+ s.LoggingSuite.TearDownTest(c)
1667 }
1668
1669 func (s *syncToolsSuite) Reset(c *gc.C) {
1670
1671=== removed file 'cmd/juju/user.go'
1672--- cmd/juju/user.go 2014-05-20 04:27:21 +0000
1673+++ cmd/juju/user.go 1970-01-01 00:00:00 +0000
1674@@ -1,35 +0,0 @@
1675-// Copyright 2014 Canonical Ltd.
1676-// Licensed under the AGPLv3, see LICENCE file for details.
1677-
1678-package main
1679-
1680-import (
1681- "launchpad.net/juju-core/cmd"
1682- "launchpad.net/juju-core/cmd/envcmd"
1683-)
1684-
1685-type UserCommand struct {
1686- *cmd.SuperCommand
1687-}
1688-
1689-const userCommandDoc = `
1690-"juju user" is used to manage the user accounts and access control in
1691-the Juju environment.
1692-`
1693-
1694-const userCommandPurpose = "manage user accounts and access control"
1695-
1696-func NewUserCommand() cmd.Command {
1697- usercmd := &UserCommand{
1698- SuperCommand: cmd.NewSuperCommand(cmd.SuperCommandParams{
1699- Name: "user",
1700- Doc: userCommandDoc,
1701- UsagePrefix: "juju",
1702- Purpose: userCommandPurpose,
1703- }),
1704- }
1705- // Define each subcommand in a separate "user_FOO.go" source file
1706- // (with tests in user_FOO_test.go) and wire in here.
1707- usercmd.Register(envcmd.Wrap(&UserAddCommand{}))
1708- return usercmd
1709-}
1710
1711=== removed file 'cmd/juju/user_test.go'
1712--- cmd/juju/user_test.go 2014-05-20 02:41:00 +0000
1713+++ cmd/juju/user_test.go 1970-01-01 00:00:00 +0000
1714@@ -1,42 +0,0 @@
1715-// Copyright 2014 Canonical Ltd.
1716-// Licensed under the AGPLv3, see LICENCE file for details.
1717-
1718-package main
1719-
1720-import (
1721- "strings"
1722-
1723- gc "launchpad.net/gocheck"
1724- coretesting "launchpad.net/juju-core/testing"
1725-)
1726-
1727-type UserCommandSuite struct {
1728- coretesting.BaseSuite
1729-}
1730-
1731-var _ = gc.Suite(&UserCommandSuite{})
1732-
1733-var expectedUserCommmandNames = []string{
1734- "add",
1735- "help",
1736-}
1737-
1738-func (s *UserCommandSuite) TestHelp(c *gc.C) {
1739- // Check the help output
1740- ctx, err := coretesting.RunCommand(c, NewUserCommand(), []string{"--help"})
1741- c.Assert(err, gc.IsNil)
1742- c.Assert(coretesting.Stdout(ctx), gc.Matches,
1743- "(?s)usage: user <command> .+"+
1744- userCommandPurpose+".+"+
1745- userCommandDoc+".+")
1746-
1747- // Check that we have registered all the sub commands by
1748- // inspecting the help output.
1749- var namesFound []string
1750- commandHelp := strings.SplitAfter(coretesting.Stdout(ctx), "commands:")[1]
1751- commandHelp = strings.TrimSpace(commandHelp)
1752- for _, line := range strings.Split(commandHelp, "\n") {
1753- namesFound = append(namesFound, strings.TrimSpace(strings.Split(line, " - ")[0]))
1754- }
1755- c.Assert(namesFound, gc.DeepEquals, expectedUserCommmandNames)
1756-}
1757
1758=== modified file 'cmd/jujud/agent_test.go'
1759--- cmd/jujud/agent_test.go 2014-05-20 04:27:02 +0000
1760+++ cmd/jujud/agent_test.go 2014-05-22 14:33:28 +0000
1761@@ -25,6 +25,7 @@
1762 "launchpad.net/juju-core/state/api"
1763 "launchpad.net/juju-core/state/api/params"
1764 coretesting "launchpad.net/juju-core/testing"
1765+ "launchpad.net/juju-core/testing/testbase"
1766 coretools "launchpad.net/juju-core/tools"
1767 "launchpad.net/juju-core/version"
1768 "launchpad.net/juju-core/worker"
1769@@ -34,7 +35,7 @@
1770 var _ = gc.Suite(&toolSuite{})
1771
1772 type toolSuite struct {
1773- coretesting.BaseSuite
1774+ testbase.LoggingSuite
1775 }
1776
1777 var errorImportanceTests = []error{
1778@@ -89,7 +90,7 @@
1779 }
1780
1781 type apiOpenSuite struct {
1782- coretesting.BaseSuite
1783+ testbase.LoggingSuite
1784 }
1785
1786 type fakeAPIOpenConfig struct {
1787
1788=== modified file 'cmd/jujud/bootstrap_test.go'
1789--- cmd/jujud/bootstrap_test.go 2014-05-20 04:27:02 +0000
1790+++ cmd/jujud/bootstrap_test.go 2014-05-22 14:33:28 +0000
1791@@ -27,6 +27,7 @@
1792 "launchpad.net/juju-core/state"
1793 "launchpad.net/juju-core/state/api/params"
1794 "launchpad.net/juju-core/testing"
1795+ "launchpad.net/juju-core/testing/testbase"
1796 "launchpad.net/juju-core/utils"
1797 "launchpad.net/juju-core/version"
1798 "launchpad.net/juju-core/worker/peergrouper"
1799@@ -37,7 +38,7 @@
1800 // We don't want to use JujuConnSuite because it gives us
1801 // an already-bootstrapped environment.
1802 type BootstrapSuite struct {
1803- testing.BaseSuite
1804+ testbase.LoggingSuite
1805 testing.MgoSuite
1806 envcfg string
1807 instanceId instance.Id
1808@@ -76,19 +77,19 @@
1809 s.PatchValue(&ensureMongoServer, s.fakeEnsureMongo.fakeEnsureMongo)
1810 s.PatchValue(&maybeInitiateMongoServer, s.fakeEnsureMongo.fakeInitiateMongo)
1811
1812- s.BaseSuite.SetUpSuite(c)
1813+ s.LoggingSuite.SetUpSuite(c)
1814 s.MgoSuite.SetUpSuite(c)
1815 s.makeTestEnv(c)
1816 }
1817
1818 func (s *BootstrapSuite) TearDownSuite(c *gc.C) {
1819 s.MgoSuite.TearDownSuite(c)
1820- s.BaseSuite.TearDownSuite(c)
1821+ s.LoggingSuite.TearDownSuite(c)
1822 dummy.Reset()
1823 }
1824
1825 func (s *BootstrapSuite) SetUpTest(c *gc.C) {
1826- s.BaseSuite.SetUpTest(c)
1827+ s.LoggingSuite.SetUpTest(c)
1828 s.MgoSuite.SetUpTest(c)
1829 s.dataDir = c.MkDir()
1830 s.logDir = c.MkDir()
1831@@ -97,7 +98,7 @@
1832
1833 func (s *BootstrapSuite) TearDownTest(c *gc.C) {
1834 s.MgoSuite.TearDownTest(c)
1835- s.BaseSuite.TearDownTest(c)
1836+ s.LoggingSuite.TearDownTest(c)
1837 }
1838
1839 var testPassword = "my-admin-secret"
1840
1841=== modified file 'cmd/jujud/machine.go'
1842--- cmd/jujud/machine.go 2014-05-19 12:59:11 +0000
1843+++ cmd/jujud/machine.go 2014-05-22 14:33:28 +0000
1844@@ -450,11 +450,9 @@
1845 a.startWorkerAfterUpgrade(runner, "instancepoller", func() (worker.Worker, error) {
1846 return instancepoller.NewWorker(st), nil
1847 })
1848- if shouldEnableHA(agentConfig) {
1849- a.startWorkerAfterUpgrade(runner, "peergrouper", func() (worker.Worker, error) {
1850- return peergrouperNew(st)
1851- })
1852- }
1853+ runner.StartWorker("peergrouper", func() (worker.Worker, error) {
1854+ return peergrouperNew(st)
1855+ })
1856 runner.StartWorker("apiserver", func() (worker.Worker, error) {
1857 // If the configuration does not have the required information,
1858 // it is currently not a recoverable error, so we kill the whole
1859
1860=== modified file 'cmd/jujud/machine_test.go'
1861--- cmd/jujud/machine_test.go 2014-05-19 13:07:51 +0000
1862+++ cmd/jujud/machine_test.go 2014-05-22 14:33:28 +0000
1863@@ -13,6 +13,7 @@
1864 "time"
1865
1866 "github.com/juju/errors"
1867+ "github.com/juju/testing"
1868 jc "github.com/juju/testing/checkers"
1869 gc "launchpad.net/gocheck"
1870
1871@@ -64,7 +65,8 @@
1872 func (s *commonMachineSuite) SetUpSuite(c *gc.C) {
1873 s.agentSuite.SetUpSuite(c)
1874 s.TestSuite.SetUpSuite(c)
1875- s.agentSuite.PatchValue(&charm.CacheDir, c.MkDir())
1876+ restore := testing.PatchValue(&charm.CacheDir, c.MkDir())
1877+ s.AddSuiteCleanup(func(*gc.C) { restore() })
1878 }
1879
1880 func (s *commonMachineSuite) TearDownSuite(c *gc.C) {
1881@@ -77,26 +79,28 @@
1882 s.TestSuite.SetUpTest(c)
1883
1884 os.Remove(jujuRun) // ignore error; may not exist
1885- // Patch ssh user to avoid touching ~ubuntu/.ssh/authorized_keys.
1886- s.agentSuite.PatchValue(&authenticationworker.SSHUser, "")
1887+ // Fake $HOME, and ssh user to avoid touching ~ubuntu/.ssh/authorized_keys.
1888+ fakeHome := coretesting.MakeEmptyFakeHomeWithoutJuju(c)
1889+ s.AddCleanup(func(*gc.C) { fakeHome.Restore() })
1890+ s.PatchValue(&authenticationworker.SSHUser, "")
1891
1892 testpath := c.MkDir()
1893- s.agentSuite.PatchEnvPathPrepend(testpath)
1894+ s.PatchEnvPathPrepend(testpath)
1895 // mock out the start method so we can fake install services without sudo
1896 fakeCmd(filepath.Join(testpath, "start"))
1897 fakeCmd(filepath.Join(testpath, "stop"))
1898
1899- s.agentSuite.PatchValue(&upstart.InitDir, c.MkDir())
1900+ s.PatchValue(&upstart.InitDir, c.MkDir())
1901
1902 s.singularRecord = &singularRunnerRecord{}
1903- s.agentSuite.PatchValue(&newSingularRunner, s.singularRecord.newSingularRunner)
1904- s.agentSuite.PatchValue(&peergrouperNew, func(st *state.State) (worker.Worker, error) {
1905+ testing.PatchValue(&newSingularRunner, s.singularRecord.newSingularRunner)
1906+ testing.PatchValue(&peergrouperNew, func(st *state.State) (worker.Worker, error) {
1907 return newDummyWorker(), nil
1908 })
1909
1910 s.fakeEnsureMongo = fakeEnsure{}
1911- s.agentSuite.PatchValue(&ensureMongoServer, s.fakeEnsureMongo.fakeEnsureMongo)
1912- s.agentSuite.PatchValue(&maybeInitiateMongoServer, s.fakeEnsureMongo.fakeInitiateMongo)
1913+ s.PatchValue(&ensureMongoServer, s.fakeEnsureMongo.fakeEnsureMongo)
1914+ s.PatchValue(&maybeInitiateMongoServer, s.fakeEnsureMongo.fakeInitiateMongo)
1915 }
1916
1917 func fakeCmd(path string) {
1918@@ -404,7 +408,7 @@
1919 }
1920
1921 func (s *MachineSuite) TestManageEnvironRunsInstancePoller(c *gc.C) {
1922- s.agentSuite.PatchValue(&instancepoller.ShortPoll, 500*time.Millisecond)
1923+ s.PatchValue(&instancepoller.ShortPoll, 500*time.Millisecond)
1924 usefulVersion := version.Current
1925 usefulVersion.Series = "quantal" // to match the charm created below
1926 envtesting.AssertUploadFakeToolsVersions(c, s.Conn.Environ.Storage(), usefulVersion)
1927@@ -445,7 +449,7 @@
1928
1929 func (s *MachineSuite) TestManageEnvironRunsPeergrouper(c *gc.C) {
1930 started := make(chan struct{}, 1)
1931- s.agentSuite.PatchValue(&peergrouperNew, func(st *state.State) (worker.Worker, error) {
1932+ testing.PatchValue(&peergrouperNew, func(st *state.State) (worker.Worker, error) {
1933 c.Check(st, gc.NotNil)
1934 select {
1935 case started <- struct{}{}:
1936@@ -466,33 +470,6 @@
1937 }
1938 }
1939
1940-func (s *MachineSuite) TestEnsureLocalEnvironDoesntRunPeergrouper(c *gc.C) {
1941- started := make(chan struct{}, 1)
1942- s.agentSuite.PatchValue(&peergrouperNew, func(st *state.State) (worker.Worker, error) {
1943- c.Check(st, gc.NotNil)
1944- select {
1945- case started <- struct{}{}:
1946- default:
1947- }
1948- return newDummyWorker(), nil
1949- })
1950- m, _, _ := s.primeAgent(c, version.Current, state.JobManageEnviron)
1951- a := s.newAgent(c, m)
1952- err := a.ChangeConfig(func(config agent.ConfigSetter) {
1953- config.SetValue(agent.ProviderType, "local")
1954- })
1955- c.Assert(err, gc.IsNil)
1956- defer func() { c.Check(a.Stop(), gc.IsNil) }()
1957- go func() {
1958- c.Check(a.Run(nil), gc.IsNil)
1959- }()
1960- select {
1961- case <-started:
1962- c.Fatalf("local environment should not start peergrouper")
1963- case <-time.After(coretesting.ShortWait):
1964- }
1965-}
1966-
1967 func (s *MachineSuite) TestManageEnvironCallsUseMultipleCPUs(c *gc.C) {
1968 // If it has been enabled, the JobManageEnviron agent should call utils.UseMultipleCPUs
1969 usefulVersion := version.Current
1970@@ -500,7 +477,7 @@
1971 envtesting.AssertUploadFakeToolsVersions(c, s.Conn.Environ.Storage(), usefulVersion)
1972 m, _, _ := s.primeAgent(c, version.Current, state.JobManageEnviron)
1973 calledChan := make(chan struct{}, 1)
1974- s.agentSuite.PatchValue(&useMultipleCPUs, func() { calledChan <- struct{}{} })
1975+ s.PatchValue(&useMultipleCPUs, func() { calledChan <- struct{}{} })
1976 // Now, start the agent, and observe that a JobManageEnviron agent
1977 // calls UseMultipleCPUs
1978 a := s.newAgent(c, m)
1979@@ -653,7 +630,7 @@
1980 // need to check for that here, like in assertJobWithState.
1981
1982 agentAPIs := make(chan eitherState, 1)
1983- s.agentSuite.PatchValue(reportOpened, func(st eitherState) {
1984+ s.PatchValue(reportOpened, func(st eitherState) {
1985 select {
1986 case agentAPIs <- st:
1987 default:
1988@@ -853,8 +830,8 @@
1989
1990 func (s *MachineSuite) TestMachineEnvironWorker(c *gc.C) {
1991 proxyDir := c.MkDir()
1992- s.agentSuite.PatchValue(&machineenvironmentworker.ProxyDirectory, proxyDir)
1993- s.agentSuite.PatchValue(&utils.AptConfFile, filepath.Join(proxyDir, "juju-apt-proxy"))
1994+ s.PatchValue(&machineenvironmentworker.ProxyDirectory, proxyDir)
1995+ s.PatchValue(&utils.AptConfFile, filepath.Join(proxyDir, "juju-apt-proxy"))
1996
1997 s.primeAgent(c, version.Current, state.JobHostUnits)
1998 // Make sure there are some proxy settings to write.
1999@@ -911,7 +888,7 @@
2000
2001 func (s *MachineSuite) testMachineAgentRsyslogConfigWorker(c *gc.C, job state.MachineJob, expectedMode rsyslog.RsyslogMode) {
2002 created := make(chan rsyslog.RsyslogMode, 1)
2003- s.agentSuite.PatchValue(&newRsyslogConfigWorker, func(_ *apirsyslog.State, _ agent.Config, mode rsyslog.RsyslogMode) (worker.Worker, error) {
2004+ s.PatchValue(&newRsyslogConfigWorker, func(_ *apirsyslog.State, _ agent.Config, mode rsyslog.RsyslogMode) (worker.Worker, error) {
2005 created <- mode
2006 return newDummyWorker(), nil
2007 })
2008@@ -959,14 +936,14 @@
2009 err = s.State.MongoSession().DB("admin").RemoveUser(m.Tag())
2010 c.Assert(err, gc.IsNil)
2011
2012- s.agentSuite.PatchValue(&ensureMongoAdminUser, func(p mongo.EnsureAdminUserParams) (bool, error) {
2013+ s.PatchValue(&ensureMongoAdminUser, func(p mongo.EnsureAdminUserParams) (bool, error) {
2014 err := s.State.MongoSession().DB("admin").AddUser(p.User, p.Password, false)
2015 c.Assert(err, gc.IsNil)
2016 return true, nil
2017 })
2018
2019 stateOpened := make(chan eitherState, 1)
2020- s.agentSuite.PatchValue(&reportOpenedState, func(st eitherState) {
2021+ s.PatchValue(&reportOpenedState, func(st eitherState) {
2022 select {
2023 case stateOpened <- st:
2024 default:
2025
2026=== modified file 'cmd/jujud/run_test.go'
2027--- cmd/jujud/run_test.go 2014-05-20 04:27:02 +0000
2028+++ cmd/jujud/run_test.go 2014-05-22 14:33:28 +0000
2029@@ -15,13 +15,14 @@
2030
2031 "launchpad.net/juju-core/cmd"
2032 "launchpad.net/juju-core/testing"
2033+ "launchpad.net/juju-core/testing/testbase"
2034 "launchpad.net/juju-core/utils/exec"
2035 "launchpad.net/juju-core/utils/fslock"
2036 "launchpad.net/juju-core/worker/uniter"
2037 )
2038
2039 type RunTestSuite struct {
2040- testing.BaseSuite
2041+ testbase.LoggingSuite
2042 }
2043
2044 var _ = gc.Suite(&RunTestSuite{})
2045
2046=== modified file 'cmd/jujud/upgrade_test.go'
2047--- cmd/jujud/upgrade_test.go 2014-05-16 04:20:04 +0000
2048+++ cmd/jujud/upgrade_test.go 2014-05-22 14:33:28 +0000
2049@@ -36,7 +36,7 @@
2050
2051 // Capture all apt commands.
2052 s.aptCmds = nil
2053- aptCmds := s.agentSuite.HookCommandOutput(&utils.AptCommandOutput, nil, nil)
2054+ aptCmds := s.HookCommandOutput(&utils.AptCommandOutput, nil, nil)
2055 go func() {
2056 for cmd := range aptCmds {
2057 s.aptCmds = append(s.aptCmds, cmd)
2058@@ -65,7 +65,7 @@
2059 }
2060
2061 func (s *UpgradeSuite) assertUpgradeSteps(c *gc.C, job state.MachineJob) {
2062- s.agentSuite.PatchValue(&version.Current, s.upgradeToVersion)
2063+ s.PatchValue(&version.Current, s.upgradeToVersion)
2064 err := s.State.SetEnvironAgentVersion(s.upgradeToVersion.Number)
2065 c.Assert(err, gc.IsNil)
2066
2067
2068=== modified file 'cmd/plugins/juju-metadata/imagemetadata_test.go'
2069--- cmd/plugins/juju-metadata/imagemetadata_test.go 2014-05-16 01:33:13 +0000
2070+++ cmd/plugins/juju-metadata/imagemetadata_test.go 2014-05-22 14:33:28 +0000
2071@@ -19,23 +19,26 @@
2072 "launchpad.net/juju-core/environs/config"
2073 "launchpad.net/juju-core/provider/dummy"
2074 "launchpad.net/juju-core/testing"
2075+ "launchpad.net/juju-core/testing/testbase"
2076 )
2077
2078 type ImageMetadataSuite struct {
2079- testing.FakeJujuHomeSuite
2080+ testbase.LoggingSuite
2081 environ []string
2082+ home *testing.FakeHome
2083 dir string
2084 }
2085
2086 var _ = gc.Suite(&ImageMetadataSuite{})
2087
2088 func (s *ImageMetadataSuite) SetUpSuite(c *gc.C) {
2089- s.FakeJujuHomeSuite.SetUpSuite(c)
2090+ s.LoggingSuite.SetUpSuite(c)
2091 s.environ = os.Environ()
2092 }
2093
2094 func (s *ImageMetadataSuite) SetUpTest(c *gc.C) {
2095- s.FakeJujuHomeSuite.SetUpTest(c)
2096+ s.LoggingSuite.SetUpTest(c)
2097+ os.Clearenv()
2098 s.dir = c.MkDir()
2099 // Create a fake certificate so azure test environment can be opened.
2100 certfile, err := ioutil.TempFile(s.dir, "")
2101@@ -44,11 +47,20 @@
2102 err = ioutil.WriteFile(filename, []byte("test certificate"), 0644)
2103 c.Assert(err, gc.IsNil)
2104 envConfig := strings.Replace(metadataTestEnvConfig, "/home/me/azure.pem", filename, -1)
2105- testing.WriteEnvironments(c, envConfig)
2106+ s.home = testing.MakeFakeHome(c, envConfig)
2107 s.PatchEnvironment("AWS_ACCESS_KEY_ID", "access")
2108 s.PatchEnvironment("AWS_SECRET_ACCESS_KEY", "secret")
2109 }
2110
2111+func (s *ImageMetadataSuite) TearDownTest(c *gc.C) {
2112+ for _, envstring := range s.environ {
2113+ kv := strings.SplitN(envstring, "=", 2)
2114+ os.Setenv(kv[0], kv[1])
2115+ }
2116+ s.home.Restore()
2117+ s.LoggingSuite.TearDownTest(c)
2118+}
2119+
2120 var seriesVersions map[string]string = map[string]string{
2121 "precise": "12.04",
2122 "raring": "13.04",
2123@@ -131,8 +143,6 @@
2124 }
2125
2126 func (s *ImageMetadataSuite) TestImageMetadataFilesLatestLts(c *gc.C) {
2127- envConfig := strings.Replace(metadataTestEnvConfig, "default-series: precise", "", -1)
2128- testing.WriteEnvironments(c, envConfig)
2129 ctx := testing.Context(c)
2130 code := cmd.Main(
2131 envcmd.Wrap(&ImageMetadataCommand{}), ctx, []string{
2132@@ -217,8 +227,9 @@
2133 }
2134
2135 func (s *ImageMetadataSuite) TestImageMetadataBadArgs(c *gc.C) {
2136- testing.MakeSampleJujuHome(c)
2137+ home := testing.MakeSampleHome(c)
2138 s.AddCleanup(func(*gc.C) {
2139+ home.Restore()
2140 dummy.Reset()
2141 })
2142 for i, t := range errTests {
2143
2144=== modified file 'cmd/plugins/juju-metadata/metadataplugin_test.go'
2145--- cmd/plugins/juju-metadata/metadataplugin_test.go 2014-05-16 01:33:13 +0000
2146+++ cmd/plugins/juju-metadata/metadataplugin_test.go 2014-05-22 14:33:28 +0000
2147@@ -22,7 +22,7 @@
2148 }
2149
2150 type MetadataSuite struct {
2151- testing.FakeJujuHomeSuite
2152+ jujuHome *testing.FakeHome
2153 }
2154
2155 var _ = gc.Suite(&MetadataSuite{})
2156@@ -36,6 +36,14 @@
2157 "validate-tools",
2158 }
2159
2160+func (s *MetadataSuite) SetUpTest(c *gc.C) {
2161+ s.jujuHome = testing.MakeEmptyFakeHome(c)
2162+}
2163+
2164+func (s *MetadataSuite) TearDownTest(c *gc.C) {
2165+ s.jujuHome.Restore()
2166+}
2167+
2168 var (
2169 flagRunMain = flag.Bool("run-main", false, "Run the application's main function for recursive testing")
2170 )
2171
2172=== modified file 'cmd/plugins/juju-metadata/toolsmetadata_test.go'
2173--- cmd/plugins/juju-metadata/toolsmetadata_test.go 2014-05-19 04:28:01 +0000
2174+++ cmd/plugins/juju-metadata/toolsmetadata_test.go 2014-05-22 14:33:28 +0000
2175@@ -23,11 +23,13 @@
2176 "launchpad.net/juju-core/juju/osenv"
2177 "launchpad.net/juju-core/provider/dummy"
2178 coretesting "launchpad.net/juju-core/testing"
2179+ "launchpad.net/juju-core/testing/testbase"
2180 "launchpad.net/juju-core/version"
2181 )
2182
2183 type ToolsMetadataSuite struct {
2184- coretesting.FakeJujuHomeSuite
2185+ testbase.LoggingSuite
2186+ home *coretesting.FakeHome
2187 env environs.Environ
2188 publicStorageDir string
2189 }
2190@@ -35,8 +37,10 @@
2191 var _ = gc.Suite(&ToolsMetadataSuite{})
2192
2193 func (s *ToolsMetadataSuite) SetUpTest(c *gc.C) {
2194- s.FakeJujuHomeSuite.SetUpTest(c)
2195+ s.LoggingSuite.SetUpTest(c)
2196+ s.home = coretesting.MakeSampleHome(c)
2197 s.AddCleanup(func(*gc.C) {
2198+ s.home.Restore()
2199 dummy.Reset()
2200 loggo.ResetLoggers()
2201 })
2202
2203=== modified file 'cmd/plugins/juju-metadata/validateimagemetadata_test.go'
2204--- cmd/plugins/juju-metadata/validateimagemetadata_test.go 2014-05-16 01:33:13 +0000
2205+++ cmd/plugins/juju-metadata/validateimagemetadata_test.go 2014-05-22 14:33:28 +0000
2206@@ -16,10 +16,12 @@
2207 "launchpad.net/juju-core/environs/imagemetadata"
2208 "launchpad.net/juju-core/environs/simplestreams"
2209 coretesting "launchpad.net/juju-core/testing"
2210+ "launchpad.net/juju-core/testing/testbase"
2211 )
2212
2213 type ValidateImageMetadataSuite struct {
2214- coretesting.FakeJujuHomeSuite
2215+ testbase.LoggingSuite
2216+ home *coretesting.FakeHome
2217 metadataDir string
2218 }
2219
2220@@ -104,13 +106,18 @@
2221 `
2222
2223 func (s *ValidateImageMetadataSuite) SetUpTest(c *gc.C) {
2224- s.FakeJujuHomeSuite.SetUpTest(c)
2225+ s.LoggingSuite.SetUpTest(c)
2226 s.metadataDir = c.MkDir()
2227- coretesting.WriteEnvironments(c, metadataTestEnvConfig)
2228+ s.home = coretesting.MakeFakeHome(c, metadataTestEnvConfig)
2229 s.PatchEnvironment("AWS_ACCESS_KEY_ID", "access")
2230 s.PatchEnvironment("AWS_SECRET_ACCESS_KEY", "secret")
2231 }
2232
2233+func (s *ValidateImageMetadataSuite) TearDownTest(c *gc.C) {
2234+ s.home.Restore()
2235+ s.LoggingSuite.TearDownTest(c)
2236+}
2237+
2238 func (s *ValidateImageMetadataSuite) setupEc2LocalMetadata(c *gc.C, region, stream string) {
2239 ec2Region, ok := aws.Regions[region]
2240 if !ok {
2241
2242=== modified file 'cmd/plugins/juju-metadata/validatetoolsmetadata_test.go'
2243--- cmd/plugins/juju-metadata/validatetoolsmetadata_test.go 2014-05-16 01:33:13 +0000
2244+++ cmd/plugins/juju-metadata/validatetoolsmetadata_test.go 2014-05-22 14:33:28 +0000
2245@@ -15,11 +15,13 @@
2246 "launchpad.net/juju-core/environs/filestorage"
2247 "launchpad.net/juju-core/environs/tools"
2248 coretesting "launchpad.net/juju-core/testing"
2249+ "launchpad.net/juju-core/testing/testbase"
2250 "launchpad.net/juju-core/version"
2251 )
2252
2253 type ValidateToolsMetadataSuite struct {
2254- coretesting.FakeJujuHomeSuite
2255+ testbase.LoggingSuite
2256+ home *coretesting.FakeHome
2257 metadataDir string
2258 }
2259
2260@@ -86,13 +88,18 @@
2261 }
2262
2263 func (s *ValidateToolsMetadataSuite) SetUpTest(c *gc.C) {
2264- s.FakeJujuHomeSuite.SetUpTest(c)
2265- coretesting.WriteEnvironments(c, metadataTestEnvConfig)
2266+ s.LoggingSuite.SetUpTest(c)
2267+ s.home = coretesting.MakeFakeHome(c, metadataTestEnvConfig)
2268 s.metadataDir = c.MkDir()
2269 s.PatchEnvironment("AWS_ACCESS_KEY_ID", "access")
2270 s.PatchEnvironment("AWS_SECRET_ACCESS_KEY", "secret")
2271 }
2272
2273+func (s *ValidateToolsMetadataSuite) TearDownTest(c *gc.C) {
2274+ s.home.Restore()
2275+ s.LoggingSuite.TearDownTest(c)
2276+}
2277+
2278 func (s *ValidateToolsMetadataSuite) setupEc2LocalMetadata(c *gc.C, region string) {
2279 ec2Region, ok := aws.Regions[region]
2280 if !ok {
2281
2282=== modified file 'cmd/plugins/local/main_test.go'
2283--- cmd/plugins/local/main_test.go 2014-05-20 04:27:02 +0000
2284+++ cmd/plugins/local/main_test.go 2014-05-22 14:33:28 +0000
2285@@ -15,10 +15,11 @@
2286 "launchpad.net/juju-core/cmd"
2287 "launchpad.net/juju-core/cmd/plugins/local"
2288 coretesting "launchpad.net/juju-core/testing"
2289+ "launchpad.net/juju-core/testing/testbase"
2290 )
2291
2292 type mainSuite struct {
2293- coretesting.BaseSuite
2294+ testbase.LoggingSuite
2295 }
2296
2297 var _ = gc.Suite(&mainSuite{})
2298
2299=== modified file 'constraints/validation_test.go'
2300--- constraints/validation_test.go 2014-05-20 05:33:59 +0000
2301+++ constraints/validation_test.go 2014-05-22 14:33:28 +0000
2302@@ -126,7 +126,7 @@
2303 unsupported, err := validator.Validate(cons)
2304 if t.err == "" {
2305 c.Assert(err, gc.IsNil)
2306- c.Assert(unsupported, jc.SameContents, t.unsupported)
2307+ c.Assert(unsupported, jc.DeepEquals, t.unsupported)
2308 } else {
2309 c.Assert(err, gc.ErrorMatches, t.err)
2310 }
2311
2312=== modified file 'container/directory_test.go'
2313--- container/directory_test.go 2014-05-20 04:27:02 +0000
2314+++ container/directory_test.go 2014-05-22 14:33:28 +0000
2315@@ -11,11 +11,11 @@
2316 gc "launchpad.net/gocheck"
2317
2318 "launchpad.net/juju-core/container"
2319- "launchpad.net/juju-core/testing"
2320+ "launchpad.net/juju-core/testing/testbase"
2321 )
2322
2323 type DirectorySuite struct {
2324- testing.BaseSuite
2325+ testbase.LoggingSuite
2326 containerDir string
2327 removedDir string
2328 }
2329@@ -23,7 +23,7 @@
2330 var _ = gc.Suite(&DirectorySuite{})
2331
2332 func (s *DirectorySuite) SetUpTest(c *gc.C) {
2333- s.BaseSuite.SetUpTest(c)
2334+ s.LoggingSuite.SetUpTest(c)
2335 s.containerDir = c.MkDir()
2336 s.PatchValue(&container.ContainerDir, s.containerDir)
2337 s.removedDir = c.MkDir()
2338
2339=== modified file 'container/factory/factory_test.go'
2340--- container/factory/factory_test.go 2014-05-20 04:27:02 +0000
2341+++ container/factory/factory_test.go 2014-05-22 14:33:28 +0000
2342@@ -9,11 +9,11 @@
2343 "launchpad.net/juju-core/container"
2344 "launchpad.net/juju-core/container/factory"
2345 "launchpad.net/juju-core/instance"
2346- "launchpad.net/juju-core/testing"
2347+ "launchpad.net/juju-core/testing/testbase"
2348 )
2349
2350 type factorySuite struct {
2351- testing.BaseSuite
2352+ testbase.LoggingSuite
2353 }
2354
2355 var _ = gc.Suite(&factorySuite{})
2356
2357=== modified file 'container/kvm/kvm_test.go'
2358--- container/kvm/kvm_test.go 2014-05-20 04:27:02 +0000
2359+++ container/kvm/kvm_test.go 2014-05-22 14:33:28 +0000
2360@@ -16,7 +16,7 @@
2361 kvmtesting "launchpad.net/juju-core/container/kvm/testing"
2362 containertesting "launchpad.net/juju-core/container/testing"
2363 "launchpad.net/juju-core/instance"
2364- coretesting "launchpad.net/juju-core/testing"
2365+ "launchpad.net/juju-core/testing/testbase"
2366 "launchpad.net/juju-core/version"
2367 )
2368
2369@@ -109,7 +109,7 @@
2370 }
2371
2372 type ConstraintsSuite struct {
2373- coretesting.BaseSuite
2374+ testbase.LoggingSuite
2375 }
2376
2377 var _ = gc.Suite(&ConstraintsSuite{})
2378
2379=== modified file 'container/kvm/live_test.go'
2380--- container/kvm/live_test.go 2014-05-20 04:27:02 +0000
2381+++ container/kvm/live_test.go 2014-05-22 14:33:28 +0000
2382@@ -19,12 +19,13 @@
2383 "launchpad.net/juju-core/instance"
2384 jujutesting "launchpad.net/juju-core/juju/testing"
2385 coretesting "launchpad.net/juju-core/testing"
2386+ "launchpad.net/juju-core/testing/testbase"
2387 "launchpad.net/juju-core/tools"
2388 "launchpad.net/juju-core/version"
2389 )
2390
2391 type LiveSuite struct {
2392- coretesting.BaseSuite
2393+ testbase.LoggingSuite
2394 ContainerDir string
2395 RemovedDir string
2396 }
2397@@ -32,7 +33,7 @@
2398 var _ = gc.Suite(&LiveSuite{})
2399
2400 func (s *LiveSuite) SetUpTest(c *gc.C) {
2401- s.BaseSuite.SetUpTest(c)
2402+ s.LoggingSuite.SetUpTest(c)
2403 // Skip if not linux
2404 if runtime.GOOS != "linux" {
2405 c.Skip("not running linux")
2406
2407=== modified file 'container/kvm/mock/mock-kvm_test.go'
2408--- container/kvm/mock/mock-kvm_test.go 2014-05-20 04:27:02 +0000
2409+++ container/kvm/mock/mock-kvm_test.go 2014-05-22 14:33:28 +0000
2410@@ -9,11 +9,11 @@
2411
2412 "launchpad.net/juju-core/container/kvm"
2413 "launchpad.net/juju-core/container/kvm/mock"
2414- "launchpad.net/juju-core/testing"
2415+ "launchpad.net/juju-core/testing/testbase"
2416 )
2417
2418 type MockSuite struct {
2419- testing.BaseSuite
2420+ testbase.LoggingSuite
2421 }
2422
2423 var _ = gc.Suite(&MockSuite{})
2424
2425=== modified file 'container/kvm/testing/test.go'
2426--- container/kvm/testing/test.go 2014-05-20 04:27:02 +0000
2427+++ container/kvm/testing/test.go 2014-05-22 14:33:28 +0000
2428@@ -13,20 +13,20 @@
2429 "launchpad.net/juju-core/container"
2430 "launchpad.net/juju-core/container/kvm"
2431 "launchpad.net/juju-core/container/kvm/mock"
2432- "launchpad.net/juju-core/testing"
2433+ "launchpad.net/juju-core/testing/testbase"
2434 )
2435
2436 // TestSuite replaces the kvm factory that the manager uses with a mock
2437 // implementation.
2438 type TestSuite struct {
2439- testing.BaseSuite
2440+ testbase.LoggingSuite
2441 Factory mock.ContainerFactory
2442 ContainerDir string
2443 RemovedDir string
2444 }
2445
2446 func (s *TestSuite) SetUpTest(c *gc.C) {
2447- s.BaseSuite.SetUpTest(c)
2448+ s.LoggingSuite.SetUpTest(c)
2449 s.ContainerDir = c.MkDir()
2450 s.PatchValue(&container.ContainerDir, s.ContainerDir)
2451 s.RemovedDir = c.MkDir()
2452
2453=== modified file 'container/lxc/export_test.go'
2454--- container/lxc/export_test.go 2014-05-13 12:57:53 +0000
2455+++ container/lxc/export_test.go 2014-05-22 14:33:28 +0000
2456@@ -3,18 +3,10 @@
2457
2458 package lxc
2459
2460-import "launchpad.net/juju-core/container"
2461-
2462 var (
2463 ContainerConfigFilename = containerConfigFilename
2464 ContainerDirFilesystem = containerDirFilesystem
2465 GenerateNetworkConfig = generateNetworkConfig
2466 NetworkConfigTemplate = networkConfigTemplate
2467 RestartSymlink = restartSymlink
2468- ReleaseVersion = &releaseVersion
2469- PreferFastLXC = preferFastLXC
2470 )
2471-
2472-func GetCreateWithCloneValue(mgr container.Manager) bool {
2473- return mgr.(*containerManager).createWithClone
2474-}
2475
2476=== modified file 'container/lxc/initialisation_test.go'
2477--- container/lxc/initialisation_test.go 2014-05-20 04:27:02 +0000
2478+++ container/lxc/initialisation_test.go 2014-05-22 14:33:28 +0000
2479@@ -6,12 +6,12 @@
2480 import (
2481 gc "launchpad.net/gocheck"
2482
2483- "launchpad.net/juju-core/testing"
2484+ "launchpad.net/juju-core/testing/testbase"
2485 "launchpad.net/juju-core/utils"
2486 )
2487
2488 type InitialiserSuite struct {
2489- testing.BaseSuite
2490+ testbase.LoggingSuite
2491 }
2492
2493 var _ = gc.Suite(&InitialiserSuite{})
2494
2495=== modified file 'container/lxc/lxc.go'
2496--- container/lxc/lxc.go 2014-05-15 10:31:08 +0000
2497+++ container/lxc/lxc.go 2014-05-22 14:33:28 +0000
2498@@ -88,19 +88,10 @@
2499 if logDir == "" {
2500 logDir = agent.DefaultLogDir
2501 }
2502- var useClone bool
2503- useCloneVal := conf.PopValue("use-clone")
2504- if useCloneVal != "" {
2505- // Explicitly ignore the error result from ParseBool.
2506- // If it fails to parse, the value is false, and this suits
2507- // us fine.
2508- useClone, _ = strconv.ParseBool(useCloneVal)
2509- } else {
2510- // If no lxc-clone value is explicitly set in config, then
2511- // see if the Ubuntu series we are running on supports it
2512- // and if it does, we will use clone.
2513- useClone = preferFastLXC(releaseVersion())
2514- }
2515+ // Explicitly ignore the error result from ParseBool.
2516+ // If it fails to parse, the value is false, and this suits
2517+ // us fine.
2518+ useClone, _ := strconv.ParseBool(conf.PopValue("use-clone"))
2519 useAUFS, _ := strconv.ParseBool(conf.PopValue("use-aufs"))
2520 backingFS, err := containerDirFilesystem()
2521 if err != nil {
2522@@ -121,23 +112,6 @@
2523 }, nil
2524 }
2525
2526-// releaseVersion is a function that returns a string representing the
2527-// DISTRIB_RELEASE from the /etc/lsb-release file.
2528-var releaseVersion = version.ReleaseVersion
2529-
2530-// preferFastLXC returns true if the host is capable of
2531-// LXC cloning from a template.
2532-func preferFastLXC(release string) bool {
2533- if release == "" {
2534- return false
2535- }
2536- value, err := strconv.ParseFloat(release, 64)
2537- if err != nil {
2538- return false
2539- }
2540- return value >= 14.04
2541-}
2542-
2543 func (manager *containerManager) CreateContainer(
2544 machineConfig *cloudinit.MachineConfig,
2545 series string,
2546
2547=== modified file 'container/lxc/lxc_test.go'
2548--- container/lxc/lxc_test.go 2014-05-20 04:27:02 +0000
2549+++ container/lxc/lxc_test.go 2014-05-22 14:33:28 +0000
2550@@ -26,7 +26,7 @@
2551 containertesting "launchpad.net/juju-core/container/testing"
2552 instancetest "launchpad.net/juju-core/instance/testing"
2553 "launchpad.net/juju-core/juju/osenv"
2554- coretesting "launchpad.net/juju-core/testing"
2555+ "launchpad.net/juju-core/testing/testbase"
2556 )
2557
2558 func Test(t *stdtesting.T) {
2559@@ -58,68 +58,6 @@
2560 s.TestSuite.TearDownTest(c)
2561 }
2562
2563-func (t *LxcSuite) TestPreferFastLXC(c *gc.C) {
2564- for i, test := range []struct {
2565- message string
2566- releaseVersion string
2567- expected bool
2568- }{{
2569- message: "missing release file",
2570- }, {
2571- message: "precise release",
2572- releaseVersion: "12.04",
2573- }, {
2574- message: "trusty release",
2575- releaseVersion: "14.04",
2576- expected: true,
2577- }, {
2578- message: "unstable unicorn",
2579- releaseVersion: "14.10",
2580- expected: true,
2581- }, {
2582- message: "lucid",
2583- releaseVersion: "10.04",
2584- }} {
2585- c.Logf("%v: %v", i, test.message)
2586- value := lxc.PreferFastLXC(test.releaseVersion)
2587- c.Assert(value, gc.Equals, test.expected)
2588- }
2589-}
2590-
2591-func (s *LxcSuite) TestContainerManagerLXCClone(c *gc.C) {
2592- type test struct {
2593- releaseVersion string
2594- useClone string
2595- expectClone bool
2596- }
2597- tests := []test{{
2598- releaseVersion: "12.04",
2599- useClone: "true",
2600- expectClone: true,
2601- }, {
2602- releaseVersion: "14.04",
2603- expectClone: true,
2604- }, {
2605- releaseVersion: "12.04",
2606- useClone: "false",
2607- }, {
2608- releaseVersion: "14.04",
2609- useClone: "false",
2610- }}
2611-
2612- for i, test := range tests {
2613- c.Logf("test %d: %v", i, test)
2614- s.PatchValue(lxc.ReleaseVersion, func() string { return test.releaseVersion })
2615-
2616- mgr, err := lxc.NewContainerManager(container.ManagerConfig{
2617- container.ConfigName: "juju",
2618- "use-clone": test.useClone,
2619- })
2620- c.Assert(err, gc.IsNil)
2621- c.Check(lxc.GetCreateWithCloneValue(mgr), gc.Equals, test.expectClone)
2622- }
2623-}
2624-
2625 func (s *LxcSuite) TestContainerDirFilesystem(c *gc.C) {
2626 for i, test := range []struct {
2627 message string
2628@@ -155,9 +93,9 @@
2629 params := container.ManagerConfig{
2630 container.ConfigName: name,
2631 }
2632- // Need to ensure use-clone is explicitly set to avoid it
2633- // being set based on the OS version.
2634- params["use-clone"] = fmt.Sprintf("%v", s.useClone)
2635+ if s.useClone {
2636+ params["use-clone"] = "true"
2637+ }
2638 if s.useAUFS {
2639 params["use-aufs"] = "true"
2640 }
2641@@ -447,7 +385,7 @@
2642 }
2643
2644 type NetworkSuite struct {
2645- coretesting.BaseSuite
2646+ testbase.LoggingSuite
2647 }
2648
2649 var _ = gc.Suite(&NetworkSuite{})
2650
2651=== modified file 'container/lxc/testing/test.go'
2652--- container/lxc/testing/test.go 2014-05-16 01:33:13 +0000
2653+++ container/lxc/testing/test.go 2014-05-22 14:33:28 +0000
2654@@ -9,13 +9,13 @@
2655 "launchpad.net/juju-core/container"
2656 "launchpad.net/juju-core/container/lxc"
2657 "launchpad.net/juju-core/container/lxc/mock"
2658- "launchpad.net/juju-core/testing"
2659+ "launchpad.net/juju-core/testing/testbase"
2660 )
2661
2662 // TestSuite replaces the lxc factory that the broker uses with a mock
2663 // implementation.
2664 type TestSuite struct {
2665- testing.FakeJujuHomeSuite
2666+ testbase.LoggingSuite
2667 Factory mock.ContainerFactory
2668 ContainerDir string
2669 RemovedDir string
2670@@ -24,7 +24,7 @@
2671 }
2672
2673 func (s *TestSuite) SetUpTest(c *gc.C) {
2674- s.FakeJujuHomeSuite.SetUpTest(c)
2675+ s.LoggingSuite.SetUpTest(c)
2676 s.ContainerDir = c.MkDir()
2677 s.PatchValue(&container.ContainerDir, s.ContainerDir)
2678 s.RemovedDir = c.MkDir()
2679
2680=== removed file 'doc.go'
2681--- doc.go 2014-05-20 01:56:13 +0000
2682+++ doc.go 1970-01-01 00:00:00 +0000
2683@@ -1,10 +0,0 @@
2684-// Copyright 2013 Canonical Ltd.
2685-// Licensed under the AGPLv3, see LICENCE file for details.
2686-
2687-// Juju is devops distilled.
2688-//
2689-// Project homepage: https://launchpad.net/juju-core
2690-//
2691-// For more information please refer to the README file
2692-// in this directory.
2693-package juju
2694
2695=== modified file 'doc/how-to-write-tests.txt'
2696--- doc/how-to-write-tests.txt 2014-05-16 01:33:13 +0000
2697+++ doc/how-to-write-tests.txt 2014-05-22 14:33:28 +0000
2698@@ -140,28 +140,23 @@
2699 set-up and tear-down logic. Suites are often composed of other suites
2700 that provide specific set-up and tear-down behaviour.
2701
2702-There are four main suites:
2703+There are three main suites:
2704
2705- * /testing.BaseSuite (testing/base.go)
2706+ * /testing/testbase.LoggingSuite (testing/testbase/log.go)
2707 * /testing.FakeHomeSuite (testing/environ.go)
2708- * /testing.FakeJujuHomeSuite (testing/environ.go)
2709 * /juju/testing.JujuConnSuite (juju/testing/conn.go)
2710
2711-The last three have the BaseSuite functionality included through
2712-composition. The BaseSuite isolates a user's home directory from accidental
2713-modification (by setting $HOME to "") and errors if there is an attempt to do
2714-outgoing http access. It also clears the relevant $JUJU_* environment variables.
2715-The BaseSuite is also composed of the core LoggingSuite, and also LoggingSuite
2716-from github.com/juju/testing, which brings in the CleanupSuite from the same.
2717-The CleanupSuite has the functionality around patching environment variables
2718-and normal variables for the duration of a test. It also provides a clean-up
2719-stack that gets called when the test teardown happens.
2720-
2721-All test suites should embedd BaseSuite. Those that need the extra functionality
2722-can instead embedd one of the fake home suites:
2723-
2724-* FakeHomeSuite: creates a fake home directory with ~/.ssh and fake ssh keys.
2725-* FakeJujuHomeSuite: as above but also sets up a ~/.juju with a fake environment.
2726+The second two have the LoggingSuite functionality included through
2727+composition. The LoggingSuite is also composed of the LoggingSuite from
2728+github.com/juju/testing, which brings in the CleanupSuite from the same.
2729+The CleanupSuite has the functionality around patching environment
2730+variables and normal variables for the duration of a test. It also
2731+provides a clean-up stack that gets called when the test teardown happens.
2732+
2733+The FakeHomeSuite creates a temporary directory and sets the HOME environment
2734+variable to it. It also creates ~/.juju and a simple environments.yaml file,
2735+~/.ssh with a fake id_rsa.pub key, it isolates the test from the JUJU_HOME,
2736+JUJU_ENV, and JUJU_LOGGING_CONFIG environment variables.
2737
2738 The JujuConnSuite does this and more. It also sets up a state server and api
2739 server. This is one problem with the JujuConnSuite, it almost always does a
2740@@ -174,7 +169,7 @@
2741
2742 ```go
2743 type ToolsSuite struct {
2744- testing.BaseSuite
2745+ testbase.LoggingSuite
2746 dataDir string
2747 }
2748
2749@@ -191,21 +186,19 @@
2750
2751 ```go
2752 func (t *ToolsSuite) SetUpTest(c *gc.C) {
2753- t.BaseSuite.SetUpTest(c)
2754+ t.LoggingSuite.SetUpTest(c)
2755 t.dataDir = c.MkDir()
2756 }
2757 ```
2758
2759 If the test suite has multiple contained suites, please call them in the
2760 order that they are defined, and make sure something that is composed from
2761-the BaseSuite is first. They should be torn down in the reverse order.
2762+the LoggingSuite is first. They should be torn down in the reverse order.
2763
2764-Even if the code that is being tested currently has no logging or outbound
2765-network access in it, it is a good idea to use the BaseSuite as a base:
2766- * it isolates the user's home directory against accidental modification
2767- * if someone does add outbound network access later, it will be caught
2768+Even if the code that is being tested currently has no logging in it, it
2769+is a good idea to use the LoggingSuite as a base for two reasons:
2770 * it brings in something composed of the CleanupSuite
2771- * if someone does add logging later, it is captured and doesn't pollute
2772+ * if someone does add logging later, it is captured and doesn't polute
2773 the logging output
2774
2775
2776
2777=== modified file 'downloader/downloader_test.go'
2778--- downloader/downloader_test.go 2014-05-20 04:27:02 +0000
2779+++ downloader/downloader_test.go 2014-05-22 14:33:28 +0000
2780@@ -14,32 +14,33 @@
2781
2782 "launchpad.net/juju-core/downloader"
2783 "launchpad.net/juju-core/testing"
2784+ "launchpad.net/juju-core/testing/testbase"
2785 "launchpad.net/juju-core/utils"
2786 )
2787
2788 type suite struct {
2789- testing.BaseSuite
2790+ testbase.LoggingSuite
2791 testing.HTTPSuite
2792 }
2793
2794 func (s *suite) SetUpSuite(c *gc.C) {
2795- s.BaseSuite.SetUpSuite(c)
2796+ s.LoggingSuite.SetUpSuite(c)
2797 s.HTTPSuite.SetUpSuite(c)
2798 }
2799
2800 func (s *suite) TearDownSuite(c *gc.C) {
2801 s.HTTPSuite.TearDownSuite(c)
2802- s.BaseSuite.TearDownSuite(c)
2803+ s.LoggingSuite.TearDownSuite(c)
2804 }
2805
2806 func (s *suite) SetUpTest(c *gc.C) {
2807- s.BaseSuite.SetUpTest(c)
2808+ s.LoggingSuite.SetUpTest(c)
2809 s.HTTPSuite.SetUpTest(c)
2810 }
2811
2812 func (s *suite) TearDownTest(c *gc.C) {
2813 s.HTTPSuite.TearDownTest(c)
2814- s.BaseSuite.TearDownTest(c)
2815+ s.LoggingSuite.TearDownTest(c)
2816 }
2817
2818 var _ = gc.Suite(&suite{})
2819
2820=== modified file 'environs/bootstrap/bootstrap_test.go'
2821--- environs/bootstrap/bootstrap_test.go 2014-05-19 04:28:01 +0000
2822+++ environs/bootstrap/bootstrap_test.go 2014-05-22 14:33:28 +0000
2823@@ -24,6 +24,7 @@
2824 "launchpad.net/juju-core/juju/arch"
2825 "launchpad.net/juju-core/provider/dummy"
2826 coretesting "launchpad.net/juju-core/testing"
2827+ "launchpad.net/juju-core/testing/testbase"
2828 "launchpad.net/juju-core/tools"
2829 "launchpad.net/juju-core/version"
2830 )
2831@@ -38,20 +39,23 @@
2832 )
2833
2834 type bootstrapSuite struct {
2835- coretesting.BaseSuite
2836+ home *coretesting.FakeHome
2837+ testbase.LoggingSuite
2838 envtesting.ToolsFixture
2839 }
2840
2841 var _ = gc.Suite(&bootstrapSuite{})
2842
2843 func (s *bootstrapSuite) SetUpTest(c *gc.C) {
2844- s.BaseSuite.SetUpTest(c)
2845+ s.LoggingSuite.SetUpTest(c)
2846 s.ToolsFixture.SetUpTest(c)
2847+ s.home = coretesting.MakeFakeHomeNoEnvironments(c, "foo")
2848 }
2849
2850 func (s *bootstrapSuite) TearDownTest(c *gc.C) {
2851+ s.home.Restore()
2852 s.ToolsFixture.TearDownTest(c)
2853- s.BaseSuite.TearDownTest(c)
2854+ s.LoggingSuite.TearDownTest(c)
2855 }
2856
2857 func (s *bootstrapSuite) TestBootstrapNeedsSettings(c *gc.C) {
2858
2859=== modified file 'environs/bootstrap/interruptiblestorage_test.go'
2860--- environs/bootstrap/interruptiblestorage_test.go 2014-05-20 04:27:02 +0000
2861+++ environs/bootstrap/interruptiblestorage_test.go 2014-05-22 14:33:28 +0000
2862@@ -10,11 +10,11 @@
2863
2864 "launchpad.net/juju-core/environs/bootstrap"
2865 envtesting "launchpad.net/juju-core/environs/testing"
2866- coretesting "launchpad.net/juju-core/testing"
2867+ "launchpad.net/juju-core/testing/testbase"
2868 )
2869
2870 type interruptibleStorageSuite struct {
2871- coretesting.BaseSuite
2872+ testbase.LoggingSuite
2873 }
2874
2875 var _ = gc.Suite(&interruptibleStorageSuite{})
2876
2877=== modified file 'environs/bootstrap/state_test.go'
2878--- environs/bootstrap/state_test.go 2014-05-20 04:27:02 +0000
2879+++ environs/bootstrap/state_test.go 2014-05-22 14:33:28 +0000
2880@@ -19,11 +19,11 @@
2881 "launchpad.net/juju-core/environs/storage"
2882 envtesting "launchpad.net/juju-core/environs/testing"
2883 "launchpad.net/juju-core/instance"
2884- coretesting "launchpad.net/juju-core/testing"
2885+ "launchpad.net/juju-core/testing/testbase"
2886 )
2887
2888 type StateSuite struct {
2889- coretesting.BaseSuite
2890+ testbase.LoggingSuite
2891 }
2892
2893 var _ = gc.Suite(&StateSuite{})
2894
2895=== modified file 'environs/cloudinit/cloudinit_test.go'
2896--- environs/cloudinit/cloudinit_test.go 2014-05-20 04:27:02 +0000
2897+++ environs/cloudinit/cloudinit_test.go 2014-05-22 14:33:28 +0000
2898@@ -24,6 +24,7 @@
2899 "launchpad.net/juju-core/state/api"
2900 "launchpad.net/juju-core/state/api/params"
2901 "launchpad.net/juju-core/testing"
2902+ "launchpad.net/juju-core/testing/testbase"
2903 "launchpad.net/juju-core/tools"
2904 "launchpad.net/juju-core/version"
2905 )
2906@@ -31,7 +32,7 @@
2907 // Use local suite since this file lives in the ec2 package
2908 // for testing internals.
2909 type cloudinitSuite struct {
2910- testing.BaseSuite
2911+ testbase.LoggingSuite
2912 }
2913
2914 var _ = gc.Suite(&cloudinitSuite{})
2915
2916=== modified file 'environs/cloudinit_test.go'
2917--- environs/cloudinit_test.go 2014-05-20 04:27:02 +0000
2918+++ environs/cloudinit_test.go 2014-05-22 14:33:28 +0000
2919@@ -23,6 +23,7 @@
2920 "launchpad.net/juju-core/state/api"
2921 "launchpad.net/juju-core/state/api/params"
2922 "launchpad.net/juju-core/testing"
2923+ "launchpad.net/juju-core/testing/testbase"
2924 "launchpad.net/juju-core/tools"
2925 "launchpad.net/juju-core/utils"
2926 "launchpad.net/juju-core/version"
2927@@ -38,7 +39,7 @@
2928 }
2929
2930 type CloudInitSuite struct {
2931- testing.BaseSuite
2932+ testbase.LoggingSuite
2933 }
2934
2935 var _ = gc.Suite(&CloudInitSuite{})
2936
2937=== modified file 'environs/config.go'
2938--- environs/config.go 2014-05-15 10:31:08 +0000
2939+++ environs/config.go 2014-05-22 14:33:28 +0000
2940@@ -98,14 +98,6 @@
2941 )
2942 }
2943
2944- // lxc-use-clone has been renamed to lxc-clone
2945- if _, ok := attrs["lxc-use-clone"]; ok {
2946- logger.Warningf(
2947- "Config attribute \"lxc-use-clone\" has been renamed to \"lxc-clone\".\n" +
2948- "Please update your environment configuration.",
2949- )
2950- }
2951-
2952 cfg, err := config.New(config.UseDefaults, attrs)
2953 if err != nil {
2954 return nil, err
2955
2956=== modified file 'environs/config/authkeys_test.go'
2957--- environs/config/authkeys_test.go 2014-05-20 04:27:02 +0000
2958+++ environs/config/authkeys_test.go 2014-05-22 14:33:28 +0000
2959@@ -13,19 +13,19 @@
2960
2961 "launchpad.net/juju-core/environs/config"
2962 "launchpad.net/juju-core/juju/osenv"
2963- "launchpad.net/juju-core/testing"
2964+ "launchpad.net/juju-core/testing/testbase"
2965 "launchpad.net/juju-core/utils/ssh"
2966 )
2967
2968 type AuthKeysSuite struct {
2969- testing.BaseSuite
2970+ testbase.LoggingSuite
2971 dotssh string // ~/.ssh
2972 }
2973
2974 var _ = gc.Suite(&AuthKeysSuite{})
2975
2976 func (s *AuthKeysSuite) SetUpTest(c *gc.C) {
2977- s.BaseSuite.SetUpTest(c)
2978+ s.LoggingSuite.SetUpTest(c)
2979 old := osenv.Home()
2980 newhome := c.MkDir()
2981 osenv.SetHome(newhome)
2982@@ -37,7 +37,7 @@
2983
2984 func (s *AuthKeysSuite) TearDownTest(c *gc.C) {
2985 ssh.ClearClientKeys()
2986- s.BaseSuite.TearDownTest(c)
2987+ s.LoggingSuite.TearDownTest(c)
2988 }
2989
2990 func (s *AuthKeysSuite) TestReadAuthorizedKeysErrors(c *gc.C) {
2991
2992=== modified file 'environs/config/config.go'
2993--- environs/config/config.go 2014-05-15 10:31:08 +0000
2994+++ environs/config/config.go 2014-05-22 14:33:28 +0000
2995@@ -258,16 +258,6 @@
2996 // Even if the user has edited their environment yaml to remove the deprecated tools-url value,
2997 // we still want it in the config for upgrades.
2998 cfg.defined["tools-url"], _ = cfg.ToolsURL()
2999-
3000- // Copy across lxc-use-clone to lxc-clone.
3001- if lxcUseClone, ok := cfg.defined["lxc-use-clone"]; ok {
3002- _, newValSpecified := cfg.LXCUseClone()
3003- // Ensure the new attribute name "lxc-clone" is set.
3004- if !newValSpecified {
3005- cfg.defined["lxc-clone"] = lxcUseClone
3006- }
3007- }
3008-
3009 // Update the provider type from null to manual.
3010 if cfg.Type() == "null" {
3011 cfg.defined["type"] = "manual"
3012@@ -710,16 +700,9 @@
3013
3014 // LXCUseClone reports whether the LXC provisioner should create a
3015 // template and use cloning to speed up container provisioning.
3016-func (c *Config) LXCUseClone() (bool, bool) {
3017- v, ok := c.defined["lxc-clone"].(bool)
3018- return v, ok
3019-}
3020-
3021-// LXCUseCloneAUFS reports whether the LXC provisioner should create a
3022-// lxc clone using aufs if available.
3023-func (c *Config) LXCUseCloneAUFS() (bool, bool) {
3024- v, ok := c.defined["lxc-clone-aufs"].(bool)
3025- return v, ok
3026+func (c *Config) LXCUseClone() bool {
3027+ v, _ := c.defined["lxc-use-clone"].(bool)
3028+ return v
3029 }
3030
3031 // UnknownAttrs returns a copy of the raw configuration attributes
3032@@ -798,12 +781,10 @@
3033 "bootstrap-addresses-delay": schema.ForceInt(),
3034 "test-mode": schema.Bool(),
3035 "proxy-ssh": schema.Bool(),
3036- "lxc-clone": schema.Bool(),
3037- "lxc-clone-aufs": schema.Bool(),
3038+ "lxc-use-clone": schema.Bool(),
3039
3040 // Deprecated fields, retain for backwards compatibility.
3041- "tools-url": schema.String(),
3042- "lxc-use-clone": schema.Bool(),
3043+ "tools-url": schema.String(),
3044 }
3045
3046 // alwaysOptional holds configuration defaults for attributes that may
3047@@ -834,11 +815,9 @@
3048 "apt-http-proxy": schema.Omit,
3049 "apt-https-proxy": schema.Omit,
3050 "apt-ftp-proxy": schema.Omit,
3051- "lxc-clone": schema.Omit,
3052
3053 // Deprecated fields, retain for backwards compatibility.
3054- "tools-url": "",
3055- "lxc-use-clone": schema.Omit,
3056+ "tools-url": "",
3057
3058 // For backward compatibility reasons, the following
3059 // attributes default to empty strings rather than being
3060@@ -860,10 +839,10 @@
3061 // Authentication string sent with requests to the charm store
3062 "charm-store-auth": "",
3063 // Previously image-stream could be set to an empty value
3064- "image-stream": "",
3065- "test-mode": false,
3066- "proxy-ssh": false,
3067- "lxc-clone-aufs": false,
3068+ "image-stream": "",
3069+ "test-mode": false,
3070+ "proxy-ssh": false,
3071+ "lxc-use-clone": false,
3072 }
3073
3074 func allowEmpty(attr string) bool {
3075@@ -924,8 +903,7 @@
3076 "bootstrap-timeout",
3077 "bootstrap-retry-delay",
3078 "bootstrap-addresses-delay",
3079- "lxc-clone",
3080- "lxc-clone-aufs",
3081+ "lxc-use-clone",
3082 }
3083
3084 var (
3085
3086=== modified file 'environs/config/config_test.go'
3087--- environs/config/config_test.go 2014-05-16 04:57:59 +0000
3088+++ environs/config/config_test.go 2014-05-22 14:33:28 +0000
3089@@ -18,6 +18,7 @@
3090 "launchpad.net/juju-core/juju/osenv"
3091 "launchpad.net/juju-core/schema"
3092 "launchpad.net/juju-core/testing"
3093+ "launchpad.net/juju-core/testing/testbase"
3094 "launchpad.net/juju-core/version"
3095 )
3096
3097@@ -26,14 +27,14 @@
3098 }
3099
3100 type ConfigSuite struct {
3101- testing.FakeJujuHomeSuite
3102+ testbase.LoggingSuite
3103 home string
3104 }
3105
3106 var _ = gc.Suite(&ConfigSuite{})
3107
3108 func (s *ConfigSuite) SetUpTest(c *gc.C) {
3109- s.FakeJujuHomeSuite.SetUpTest(c)
3110+ s.LoggingSuite.SetUpTest(c)
3111 // Make sure that the defaults are used, which
3112 // is <root>=WARNING
3113 loggo.ResetLoggers()
3114@@ -60,8 +61,7 @@
3115 type configTest struct {
3116 about string
3117 useDefaults config.Defaulting
3118- attrs testing.Attrs
3119- expected testing.Attrs
3120+ attrs map[string]interface{}
3121 err string
3122 }
3123
3124@@ -140,33 +140,6 @@
3125 "authorized-keys-path": "~/.ssh/authorized_keys2",
3126 },
3127 }, {
3128- about: "LXC clone values",
3129- useDefaults: config.UseDefaults,
3130- attrs: testing.Attrs{
3131- "type": "my-type",
3132- "name": "my-name",
3133- "default-series": "precise",
3134- "lxc-clone": true,
3135- "lxc-clone-aufs": true,
3136- },
3137- }, {
3138- about: "Deprecated lxc-use-clone used",
3139- useDefaults: config.UseDefaults,
3140- attrs: testing.Attrs{
3141- "type": "my-type",
3142- "name": "my-name",
3143- "lxc-use-clone": true,
3144- },
3145- }, {
3146- about: "Deprecated lxc-use-clone ignored",
3147- useDefaults: config.UseDefaults,
3148- attrs: testing.Attrs{
3149- "type": "my-type",
3150- "name": "my-name",
3151- "lxc-use-clone": false,
3152- "lxc-clone": true,
3153- },
3154- }, {
3155 about: "CA cert & key from path",
3156 useDefaults: config.UseDefaults,
3157 attrs: testing.Attrs{
3158@@ -723,7 +696,7 @@
3159 name, data string
3160 }
3161
3162-func (s *ConfigSuite) TestConfig(c *gc.C) {
3163+func (*ConfigSuite) TestConfig(c *gc.C) {
3164 files := []testing.TestFile{
3165 {".ssh/id_dsa.pub", "dsa"},
3166 {".ssh/id_rsa.pub", "rsa\n"},
3167@@ -738,10 +711,11 @@
3168 {"othercert.pem", caCert3},
3169 {"otherkey.pem", caKey3},
3170 }
3171- s.FakeHomeSuite.Home.AddFiles(c, files...)
3172+ h := testing.MakeFakeHomeWithFiles(c, files)
3173+ defer h.Restore()
3174 for i, test := range configTests {
3175 c.Logf("test %d. %s", i, test.about)
3176- test.check(c, s.FakeHomeSuite.Home)
3177+ test.check(c, h)
3178 }
3179 }
3180
3181@@ -767,10 +741,12 @@
3182 },
3183 }
3184
3185-func (s *ConfigSuite) TestConfigNoCertFiles(c *gc.C) {
3186+func (*ConfigSuite) TestConfigNoCertFiles(c *gc.C) {
3187+ h := testing.MakeEmptyFakeHome(c)
3188+ defer h.Restore()
3189 for i, test := range noCertFilesTests {
3190 c.Logf("test %d. %s", i, test.about)
3191- test.check(c, s.FakeHomeSuite.Home)
3192+ test.check(c, h)
3193 }
3194 }
3195
3196@@ -827,16 +803,17 @@
3197 }, */
3198 }
3199
3200-func (s *ConfigSuite) TestConfigEmptyCertFiles(c *gc.C) {
3201+func (*ConfigSuite) TestConfigEmptyCertFiles(c *gc.C) {
3202 files := []testing.TestFile{
3203 {".juju/my-name-cert.pem", ""},
3204 {".juju/my-name-private-key.pem", ""},
3205 }
3206- s.FakeHomeSuite.Home.AddFiles(c, files...)
3207+ h := testing.MakeFakeHomeWithFiles(c, files)
3208+ defer h.Restore()
3209
3210 for i, test := range emptyCertFilesTests {
3211 c.Logf("test %d. %s", i, test.about)
3212- test.check(c, s.FakeHomeSuite.Home)
3213+ test.check(c, h)
3214 }
3215 }
3216
3217@@ -1004,27 +981,6 @@
3218 c.Assert(oldURLAttrPresent, jc.IsFalse)
3219 c.Assert(oldToolsURL, gc.Equals, "")
3220 }
3221-
3222- useLxcClone, useLxcClonePresent := cfg.LXCUseClone()
3223- oldUseClone, oldUseClonePresent := cfg.AllAttrs()["lxc-use-clone"]
3224- if v, ok := test.attrs["lxc-clone"]; ok {
3225- c.Assert(useLxcClone, gc.Equals, v)
3226- c.Assert(useLxcClonePresent, jc.IsTrue)
3227- } else {
3228- if oldUseClonePresent {
3229- c.Assert(useLxcClonePresent, jc.IsTrue)
3230- c.Assert(useLxcClone, gc.Equals, oldUseClone)
3231- } else {
3232- c.Assert(useLxcClonePresent, jc.IsFalse)
3233- c.Assert(useLxcClone, gc.Equals, false)
3234- }
3235- }
3236- useLxcCloneAufs, ok := cfg.LXCUseCloneAUFS()
3237- if v, ok := test.attrs["lxc-clone-aufs"]; ok {
3238- c.Assert(useLxcCloneAufs, gc.Equals, v)
3239- } else {
3240- c.Assert(useLxcCloneAufs, gc.Equals, false)
3241- }
3242 }
3243
3244 func (test configTest) assertDuration(c *gc.C, name string, actual time.Duration, defaultInSeconds int) {
3245@@ -1072,7 +1028,7 @@
3246 attrs["tools-url"] = ""
3247 attrs["image-stream"] = ""
3248 attrs["proxy-ssh"] = false
3249- attrs["lxc-clone-aufs"] = false
3250+ attrs["lxc-use-clone"] = false
3251
3252 // Default firewall mode is instance
3253 attrs["firewall-mode"] = string(config.FwInstance)
3254@@ -1156,22 +1112,18 @@
3255 new: testing.Attrs{"bootstrap-timeout": 5},
3256 err: `cannot change bootstrap-timeout from 600 to 5`,
3257 }, {
3258- about: "Cannot change lxc-clone",
3259- old: testing.Attrs{"lxc-clone": false},
3260- new: testing.Attrs{"lxc-clone": true},
3261- err: `cannot change lxc-clone from false to true`,
3262-}, {
3263- about: "Cannot change lxc-clone-aufs",
3264- old: testing.Attrs{"lxc-clone-aufs": false},
3265- new: testing.Attrs{"lxc-clone-aufs": true},
3266- err: `cannot change lxc-clone-aufs from false to true`,
3267+ about: "Cannot change lxc-use-clone",
3268+ old: testing.Attrs{"lxc-use-clone": false},
3269+ new: testing.Attrs{"lxc-use-clone": true},
3270+ err: `cannot change lxc-use-clone from false to true`,
3271 }}
3272
3273-func (s *ConfigSuite) TestValidateChange(c *gc.C) {
3274+func (*ConfigSuite) TestValidateChange(c *gc.C) {
3275 files := []testing.TestFile{
3276 {".ssh/identity.pub", "identity"},
3277 }
3278- s.FakeHomeSuite.Home.AddFiles(c, files...)
3279+ h := testing.MakeFakeHomeWithFiles(c, files)
3280+ defer h.Restore()
3281
3282 for i, test := range validationTests {
3283 c.Logf("test %d: %s", i, test.about)
3284@@ -1179,23 +1131,23 @@
3285 oldConfig := newTestConfig(c, test.old)
3286 err := config.Validate(newConfig, oldConfig)
3287 if test.err == "" {
3288- c.Check(err, gc.IsNil)
3289+ c.Assert(err, gc.IsNil)
3290 } else {
3291- c.Check(err, gc.ErrorMatches, test.err)
3292+ c.Assert(err, gc.ErrorMatches, test.err)
3293 }
3294 }
3295 }
3296
3297-func (s *ConfigSuite) addJujuFiles(c *gc.C) {
3298- s.FakeHomeSuite.Home.AddFiles(c, []testing.TestFile{
3299+func makeFakeHome(c *gc.C) *testing.FakeHome {
3300+ return testing.MakeFakeHomeWithFiles(c, []testing.TestFile{
3301 {".ssh/id_rsa.pub", "rsa\n"},
3302 {".juju/myenv-cert.pem", caCert},
3303 {".juju/myenv-private-key.pem", caKey},
3304- }...)
3305+ })
3306 }
3307
3308-func (s *ConfigSuite) TestValidateUnknownAttrs(c *gc.C) {
3309- s.addJujuFiles(c)
3310+func (*ConfigSuite) TestValidateUnknownAttrs(c *gc.C) {
3311+ defer makeFakeHome(c).Restore()
3312 cfg, err := config.New(config.UseDefaults, map[string]interface{}{
3313 "name": "myenv",
3314 "type": "other",
3315@@ -1247,30 +1199,32 @@
3316 return result
3317 }
3318
3319-func (s *ConfigSuite) TestLoggingConfig(c *gc.C) {
3320- s.addJujuFiles(c)
3321+func (*ConfigSuite) TestLoggingConfig(c *gc.C) {
3322+ defer makeFakeHome(c).Restore()
3323+
3324 config := newTestConfig(c, testing.Attrs{
3325 "logging-config": "<root>=WARNING;juju=DEBUG"})
3326 c.Assert(config.LoggingConfig(), gc.Equals, "<root>=WARNING;juju=DEBUG;unit=DEBUG")
3327 }
3328
3329-func (s *ConfigSuite) TestLoggingConfigWithUnit(c *gc.C) {
3330- s.addJujuFiles(c)
3331+func (*ConfigSuite) TestLoggingConfigWithUnit(c *gc.C) {
3332+ defer makeFakeHome(c).Restore()
3333+
3334 config := newTestConfig(c, testing.Attrs{
3335 "logging-config": "<root>=WARNING;unit=INFO"})
3336 c.Assert(config.LoggingConfig(), gc.Equals, "<root>=WARNING;unit=INFO")
3337 }
3338
3339 func (s *ConfigSuite) TestLoggingConfigFromEnvironment(c *gc.C) {
3340- s.addJujuFiles(c)
3341+ defer makeFakeHome(c).Restore()
3342 s.PatchEnvironment(osenv.JujuLoggingConfigEnvKey, "<root>=INFO")
3343
3344 config := newTestConfig(c, nil)
3345 c.Assert(config.LoggingConfig(), gc.Equals, "<root>=INFO;unit=DEBUG")
3346 }
3347
3348-func (s *ConfigSuite) TestProxyValuesWithFallback(c *gc.C) {
3349- s.addJujuFiles(c)
3350+func (*ConfigSuite) TestProxyValuesWithFallback(c *gc.C) {
3351+ defer makeFakeHome(c).Restore()
3352
3353 config := newTestConfig(c, testing.Attrs{
3354 "http-proxy": "http://user@10.0.0.1",
3355@@ -1287,8 +1241,9 @@
3356 c.Assert(config.NoProxy(), gc.Equals, "localhost,10.0.3.1")
3357 }
3358
3359-func (s *ConfigSuite) TestProxyValues(c *gc.C) {
3360- s.addJujuFiles(c)
3361+func (*ConfigSuite) TestProxyValues(c *gc.C) {
3362+ defer makeFakeHome(c).Restore()
3363+
3364 config := newTestConfig(c, testing.Attrs{
3365 "http-proxy": "http://user@10.0.0.1",
3366 "https-proxy": "https://user@10.0.0.1",
3367@@ -1305,8 +1260,9 @@
3368 c.Assert(config.AptFtpProxy(), gc.Equals, "ftp://user@10.0.0.2")
3369 }
3370
3371-func (s *ConfigSuite) TestProxyValuesNotSet(c *gc.C) {
3372- s.addJujuFiles(c)
3373+func (*ConfigSuite) TestProxyValuesNotSet(c *gc.C) {
3374+ defer makeFakeHome(c).Restore()
3375+
3376 config := newTestConfig(c, testing.Attrs{})
3377 c.Assert(config.HttpProxy(), gc.Equals, "")
3378 c.Assert(config.AptHttpProxy(), gc.Equals, "")
3379@@ -1317,8 +1273,9 @@
3380 c.Assert(config.NoProxy(), gc.Equals, "")
3381 }
3382
3383-func (s *ConfigSuite) TestProxyConfigMap(c *gc.C) {
3384- s.addJujuFiles(c)
3385+func (*ConfigSuite) TestProxyConfigMap(c *gc.C) {
3386+ defer makeFakeHome(c).Restore()
3387+
3388 cfg := newTestConfig(c, testing.Attrs{})
3389 proxy := osenv.ProxySettings{
3390 Http: "http proxy",
3391@@ -1334,8 +1291,9 @@
3392 c.Assert(cfg.AptProxySettings(), gc.DeepEquals, proxy)
3393 }
3394
3395-func (s *ConfigSuite) TestAptProxyConfigMap(c *gc.C) {
3396- s.addJujuFiles(c)
3397+func (*ConfigSuite) TestAptProxyConfigMap(c *gc.C) {
3398+ defer makeFakeHome(c).Restore()
3399+
3400 cfg := newTestConfig(c, testing.Attrs{})
3401 proxy := osenv.ProxySettings{
3402 Http: "http proxy",
3403@@ -1349,9 +1307,12 @@
3404 c.Assert(cfg.AptProxySettings(), gc.DeepEquals, proxy)
3405 }
3406
3407-func (s *ConfigSuite) TestGenerateStateServerCertAndKey(c *gc.C) {
3408- // Add a cert.
3409- s.FakeHomeSuite.Home.AddFiles(c, testing.TestFile{".ssh/id_rsa.pub", "rsa\n"})
3410+func (*ConfigSuite) TestGenerateStateServerCertAndKey(c *gc.C) {
3411+ // In order to test missing certs, it checks the JUJU_HOME dir, so we need
3412+ // a fake home.
3413+ defer testing.MakeFakeHomeWithFiles(c, []testing.TestFile{
3414+ {".ssh/id_rsa.pub", "rsa\n"},
3415+ }).Restore()
3416
3417 for _, test := range []struct {
3418 configValues map[string]interface{}
3419
3420=== modified file 'environs/config_test.go'
3421--- environs/config_test.go 2014-05-16 04:57:59 +0000
3422+++ environs/config_test.go 2014-05-22 14:33:28 +0000
3423@@ -19,17 +19,18 @@
3424 "launchpad.net/juju-core/provider/dummy"
3425 _ "launchpad.net/juju-core/provider/manual"
3426 "launchpad.net/juju-core/testing"
3427+ "launchpad.net/juju-core/testing/testbase"
3428 )
3429
3430 type suite struct {
3431- testing.FakeJujuHomeSuite
3432+ testbase.LoggingSuite
3433 }
3434
3435 var _ = gc.Suite(&suite{})
3436
3437 func (s *suite) TearDownTest(c *gc.C) {
3438 dummy.Reset()
3439- s.FakeJujuHomeSuite.TearDownTest(c)
3440+ s.LoggingSuite.TearDownTest(c)
3441 }
3442
3443 var invalidConfigTests = []struct {
3444@@ -79,6 +80,7 @@
3445 }
3446
3447 func (*suite) TestInvalidEnv(c *gc.C) {
3448+ defer testing.MakeFakeHomeNoEnvironments(c, "only").Restore()
3449 for i, t := range invalidEnvTests {
3450 c.Logf("running test %v", i)
3451 es, err := environs.ReadEnvironsBytes([]byte(t.env))
3452@@ -95,6 +97,7 @@
3453 // However, we can only really trigger that when we have a deprecated
3454 // field. If support for the field is removed entirely, another
3455 // mechanism will need to be used
3456+ defer testing.MakeFakeHomeNoEnvironments(c, "only").Restore()
3457 content := `
3458 environments:
3459 valid:
3460@@ -104,7 +107,6 @@
3461 type: dummy
3462 state-server: false
3463 tools-url: aknowndeprecatedfield
3464- lxc-use-clone: true
3465 `
3466 tw := &loggo.TestWriter{}
3467 // we only capture Warning or above
3468@@ -126,12 +128,12 @@
3469 // Only once we grab the deprecated one do we see any warnings
3470 _, err = envs.Config("deprecated")
3471 c.Check(err, gc.IsNil)
3472- c.Check(tw.Log, gc.HasLen, 2)
3473+ c.Check(tw.Log, gc.HasLen, 1)
3474 }
3475
3476 func (*suite) TestNoHomeBeforeConfig(c *gc.C) {
3477 // Test that we don't actually need HOME set until we call envs.Config()
3478- os.Setenv("HOME", "")
3479+ // Because of this, we intentionally do *not* call testing.MakeFakeHomeNoEnvironments()
3480 content := `
3481 environments:
3482 valid:
3483@@ -144,9 +146,7 @@
3484 }
3485
3486 func (*suite) TestNoEnv(c *gc.C) {
3487- envPath := testing.HomePath(".juju", "environments.yaml")
3488- err := os.Remove(envPath)
3489- c.Assert(err, gc.IsNil)
3490+ defer testing.MakeFakeHomeNoEnvironments(c).Restore()
3491 es, err := environs.ReadEnvirons("")
3492 c.Assert(es, gc.IsNil)
3493 c.Assert(err, jc.Satisfies, environs.IsNoEnv)
3494@@ -197,6 +197,7 @@
3495 }
3496
3497 func (*suite) TestConfig(c *gc.C) {
3498+ defer testing.MakeFakeHomeNoEnvironments(c, "only", "valid", "one", "two").Restore()
3499 for i, t := range configTests {
3500 c.Logf("running test %v", i)
3501 envs, err := environs.ReadEnvironsBytes([]byte(t.env))
3502@@ -206,6 +207,8 @@
3503 }
3504
3505 func (*suite) TestDefaultConfigFile(c *gc.C) {
3506+ defer testing.MakeEmptyFakeHome(c).Restore()
3507+
3508 env := `
3509 environments:
3510 only:
3511@@ -225,8 +228,8 @@
3512 c.Assert(cfg.Name(), gc.Equals, "only")
3513 }
3514
3515-func (s *suite) TestConfigPerm(c *gc.C) {
3516- testing.MakeSampleJujuHome(c)
3517+func (*suite) TestConfigPerm(c *gc.C) {
3518+ defer testing.MakeSampleHome(c).Restore()
3519
3520 path := testing.HomePath(".juju")
3521 info, err := os.Lstat(path)
3522@@ -253,6 +256,7 @@
3523 }
3524
3525 func (*suite) TestNamedConfigFile(c *gc.C) {
3526+ defer testing.MakeFakeHomeNoEnvironments(c, "only").Restore()
3527
3528 env := `
3529 environments:
3530@@ -279,6 +283,7 @@
3531 }
3532
3533 func (*suite) TestBootstrapConfig(c *gc.C) {
3534+ defer testing.MakeFakeHomeNoEnvironments(c, "bladaam").Restore()
3535 attrs := dummySampleConfig().Merge(testing.Attrs{
3536 "agent-version": "1.2.3",
3537 })
3538@@ -405,6 +410,7 @@
3539 }
3540
3541 func (s *ConfigDeprecationSuite) checkDeprecationWarning(c *gc.C, attrs testing.Attrs, expectedMsg string) {
3542+ defer testing.MakeFakeHomeNoEnvironments(c, "only").Restore()
3543 content := `
3544 environments:
3545 deprecated:
3546@@ -449,9 +455,3 @@
3547 expected := `Provider type \"null\" has been renamed to \"manual\"\.Please update your environment configuration\.`
3548 s.checkDeprecationWarning(c, attrs, expected)
3549 }
3550-
3551-func (s *ConfigDeprecationSuite) TestDeprecatedLxcUseCloneWarning(c *gc.C) {
3552- attrs := testing.Attrs{"lxc-use-clone": true}
3553- expected := `Config attribute \"lxc-use-clone\" has been renamed to \"lxc-clone\".Please update your environment configuration\.`
3554- s.checkDeprecationWarning(c, attrs, expected)
3555-}
3556
3557=== modified file 'environs/configstore/disk_test.go'
3558--- environs/configstore/disk_test.go 2014-05-20 04:27:02 +0000
3559+++ environs/configstore/disk_test.go 2014-05-22 14:33:28 +0000
3560@@ -17,7 +17,7 @@
3561 gc "launchpad.net/gocheck"
3562
3563 "launchpad.net/juju-core/environs/configstore"
3564- "launchpad.net/juju-core/testing"
3565+ "launchpad.net/juju-core/testing/testbase"
3566 )
3567
3568 var _ = gc.Suite(&diskInterfaceSuite{})
3569@@ -63,7 +63,7 @@
3570 var _ = gc.Suite(&diskStoreSuite{})
3571
3572 type diskStoreSuite struct {
3573- testing.BaseSuite
3574+ testbase.LoggingSuite
3575 }
3576
3577 func (*diskStoreSuite) TestNewDisk(c *gc.C) {
3578
3579=== modified file 'environs/configstore/interface_test.go'
3580--- environs/configstore/interface_test.go 2014-05-20 04:27:02 +0000
3581+++ environs/configstore/interface_test.go 2014-05-22 14:33:28 +0000
3582@@ -8,7 +8,7 @@
3583 gc "launchpad.net/gocheck"
3584
3585 "launchpad.net/juju-core/environs/configstore"
3586- "launchpad.net/juju-core/testing"
3587+ "launchpad.net/juju-core/testing/testbase"
3588 )
3589
3590 // interfaceSuite defines a set of tests on a ConfigStorage
3591@@ -16,7 +16,7 @@
3592 // The NewStore field must be set up to return a ConfigStorage
3593 // instance of the type to be tested.
3594 type interfaceSuite struct {
3595- testing.BaseSuite
3596+ testbase.LoggingSuite
3597 NewStore func(c *gc.C) configstore.Storage
3598 }
3599
3600
3601=== modified file 'environs/emptystorage_test.go'
3602--- environs/emptystorage_test.go 2014-05-16 01:33:13 +0000
3603+++ environs/emptystorage_test.go 2014-05-22 14:33:28 +0000
3604@@ -14,10 +14,11 @@
3605 "launchpad.net/juju-core/environs/storage"
3606 "launchpad.net/juju-core/provider/dummy"
3607 "launchpad.net/juju-core/testing"
3608+ "launchpad.net/juju-core/testing/testbase"
3609 )
3610
3611 type EmptyStorageSuite struct {
3612- testing.FakeJujuHomeSuite
3613+ testbase.LoggingSuite
3614 }
3615
3616 var _ = gc.Suite(&EmptyStorageSuite{})
3617@@ -41,7 +42,7 @@
3618 }
3619
3620 type verifyStorageSuite struct {
3621- testing.FakeJujuHomeSuite
3622+ testbase.LoggingSuite
3623 }
3624
3625 var _ = gc.Suite(&verifyStorageSuite{})
3626@@ -54,17 +55,14 @@
3627 authorized-keys: i-am-a-key
3628 `
3629
3630-func (s *verifyStorageSuite) SetUpTest(c *gc.C) {
3631- s.FakeJujuHomeSuite.SetUpTest(c)
3632- testing.WriteEnvironments(c, existingEnv)
3633-}
3634-
3635 func (s *verifyStorageSuite) TearDownTest(c *gc.C) {
3636 dummy.Reset()
3637- s.FakeJujuHomeSuite.TearDownTest(c)
3638+ s.LoggingSuite.TearDownTest(c)
3639 }
3640
3641 func (s *verifyStorageSuite) TestVerifyStorage(c *gc.C) {
3642+ defer testing.MakeFakeHome(c, existingEnv, "existing").Restore()
3643+
3644 ctx := testing.Context(c)
3645 environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem())
3646 c.Assert(err, gc.IsNil)
3647@@ -81,6 +79,8 @@
3648 }
3649
3650 func (s *verifyStorageSuite) TestVerifyStorageFails(c *gc.C) {
3651+ defer testing.MakeFakeHome(c, existingEnv, "existing").Restore()
3652+
3653 ctx := testing.Context(c)
3654 environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem())
3655 c.Assert(err, gc.IsNil)
3656
3657=== modified file 'environs/httpstorage/backend_test.go'
3658--- environs/httpstorage/backend_test.go 2014-05-20 04:27:02 +0000
3659+++ environs/httpstorage/backend_test.go 2014-05-22 14:33:28 +0000
3660@@ -22,6 +22,7 @@
3661 "launchpad.net/juju-core/environs/filestorage"
3662 "launchpad.net/juju-core/environs/httpstorage"
3663 coretesting "launchpad.net/juju-core/testing"
3664+ "launchpad.net/juju-core/testing/testbase"
3665 "launchpad.net/juju-core/utils"
3666 )
3667
3668@@ -32,7 +33,7 @@
3669 }
3670
3671 type backendSuite struct {
3672- coretesting.BaseSuite
3673+ testbase.LoggingSuite
3674 }
3675
3676 var _ = gc.Suite(&backendSuite{})
3677
3678=== modified file 'environs/imagemetadata/generate_test.go'
3679--- environs/imagemetadata/generate_test.go 2014-05-20 04:27:02 +0000
3680+++ environs/imagemetadata/generate_test.go 2014-05-22 14:33:28 +0000
3681@@ -11,13 +11,13 @@
3682 "launchpad.net/juju-core/environs/imagemetadata/testing"
3683 "launchpad.net/juju-core/environs/simplestreams"
3684 "launchpad.net/juju-core/environs/storage"
3685- coretesting "launchpad.net/juju-core/testing"
3686+ "launchpad.net/juju-core/testing/testbase"
3687 )
3688
3689 var _ = gc.Suite(&generateSuite{})
3690
3691 type generateSuite struct {
3692- coretesting.BaseSuite
3693+ testbase.LoggingSuite
3694 }
3695
3696 func assertFetch(c *gc.C, stor storage.Storage, series, arch, region, endpoint, id string) {
3697
3698=== modified file 'environs/imagemetadata/marshal_test.go'
3699--- environs/imagemetadata/marshal_test.go 2014-05-20 04:27:02 +0000
3700+++ environs/imagemetadata/marshal_test.go 2014-05-22 14:33:28 +0000
3701@@ -10,13 +10,13 @@
3702
3703 "launchpad.net/juju-core/environs/imagemetadata"
3704 "launchpad.net/juju-core/environs/simplestreams"
3705- "launchpad.net/juju-core/testing"
3706+ "launchpad.net/juju-core/testing/testbase"
3707 )
3708
3709 var _ = gc.Suite(&marshalSuite{})
3710
3711 type marshalSuite struct {
3712- testing.BaseSuite
3713+ testbase.LoggingSuite
3714 }
3715
3716 var expectedIndex = `{
3717
3718=== modified file 'environs/imagemetadata/upload_test.go'
3719--- environs/imagemetadata/upload_test.go 2014-05-20 04:27:02 +0000
3720+++ environs/imagemetadata/upload_test.go 2014-05-22 14:33:28 +0000
3721@@ -17,13 +17,13 @@
3722 "launchpad.net/juju-core/environs/imagemetadata/testing"
3723 "launchpad.net/juju-core/environs/simplestreams"
3724 "launchpad.net/juju-core/environs/storage"
3725- coretesting "launchpad.net/juju-core/testing"
3726+ "launchpad.net/juju-core/testing/testbase"
3727 )
3728
3729 var _ = gc.Suite(&uploadSuite{})
3730
3731 type uploadSuite struct {
3732- coretesting.BaseSuite
3733+ testbase.LoggingSuite
3734 }
3735
3736 func createImageMetadata(c *gc.C) (sourceDir string, destDir string, destStor storage.Storage, metadata *imagemetadata.ImageMetadata) {
3737
3738=== modified file 'environs/imagemetadata/urls_test.go'
3739--- environs/imagemetadata/urls_test.go 2014-05-15 05:14:01 +0000
3740+++ environs/imagemetadata/urls_test.go 2014-05-22 14:33:28 +0000
3741@@ -15,18 +15,21 @@
3742 sstesting "launchpad.net/juju-core/environs/simplestreams/testing"
3743 "launchpad.net/juju-core/provider/dummy"
3744 "launchpad.net/juju-core/testing"
3745- coretesting "launchpad.net/juju-core/testing"
3746 )
3747
3748 type URLsSuite struct {
3749- coretesting.BaseSuite
3750+ home *testing.FakeHome
3751 }
3752
3753 var _ = gc.Suite(&URLsSuite{})
3754
3755+func (s *URLsSuite) SetUpTest(c *gc.C) {
3756+ s.home = testing.MakeEmptyFakeHome(c)
3757+}
3758+
3759 func (s *URLsSuite) TearDownTest(c *gc.C) {
3760 dummy.Reset()
3761- s.BaseSuite.TearDownTest(c)
3762+ s.home.Restore()
3763 }
3764
3765 func (s *URLsSuite) env(c *gc.C, imageMetadataURL, stream string) environs.Environ {
3766
3767=== modified file 'environs/imagemetadata/validation_test.go'
3768--- environs/imagemetadata/validation_test.go 2014-05-20 04:27:02 +0000
3769+++ environs/imagemetadata/validation_test.go 2014-05-22 14:33:28 +0000
3770@@ -12,12 +12,12 @@
3771 "launchpad.net/juju-core/environs/filestorage"
3772 "launchpad.net/juju-core/environs/imagemetadata"
3773 "launchpad.net/juju-core/environs/simplestreams"
3774- "launchpad.net/juju-core/testing"
3775+ "launchpad.net/juju-core/testing/testbase"
3776 "launchpad.net/juju-core/utils"
3777 )
3778
3779 type ValidateSuite struct {
3780- testing.BaseSuite
3781+ testbase.LoggingSuite
3782 metadataDir string
3783 }
3784
3785@@ -45,7 +45,7 @@
3786 }
3787
3788 func (s *ValidateSuite) SetUpTest(c *gc.C) {
3789- s.BaseSuite.SetUpTest(c)
3790+ s.LoggingSuite.SetUpTest(c)
3791 s.metadataDir = c.MkDir()
3792 }
3793
3794
3795=== modified file 'environs/instances/image.go'
3796--- environs/instances/image.go 2014-05-16 09:58:00 +0000
3797+++ environs/instances/image.go 2014-05-22 14:33:28 +0000
3798@@ -5,7 +5,6 @@
3799
3800 import (
3801 "fmt"
3802- "sort"
3803
3804 "launchpad.net/juju-core/constraints"
3805 "launchpad.net/juju-core/environs/imagemetadata"
3806@@ -45,8 +44,6 @@
3807 type InstanceSpec struct {
3808 InstanceType InstanceType
3809 Image Image
3810- // order is used to sort InstanceSpec based on the input InstanceTypes.
3811- order int
3812 }
3813
3814 // FindInstanceSpec returns an InstanceSpec satisfying the supplied InstanceConstraint.
3815@@ -86,17 +83,13 @@
3816 for _, itype := range matchingTypes {
3817 for _, image := range possibleImages {
3818 if image.match(itype) {
3819- specs = append(specs, &InstanceSpec{
3820- InstanceType: itype,
3821- Image: image,
3822- order: len(specs),
3823- })
3824+ specs = append(specs, &InstanceSpec{itype, image})
3825 }
3826 }
3827 }
3828- if len(specs) > 0 {
3829- sort.Sort(byArch(specs))
3830- return specs[0], nil
3831+
3832+ if spec := preferredSpec(specs); spec != nil {
3833+ return spec, nil
3834 }
3835
3836 names := make([]string, len(matchingTypes))
3837@@ -106,39 +99,21 @@
3838 return nil, fmt.Errorf("no %q images in %s matching instance types %v", ic.Series, ic.Region, names)
3839 }
3840
3841-// byArch sorts InstanceSpecs first by descending word-size, then
3842-// alphabetically by name, and choose the first spec in the sequence.
3843-type byArch []*InstanceSpec
3844-
3845-func (a byArch) Len() int {
3846- return len(a)
3847-}
3848-
3849-func (a byArch) Less(i, j int) bool {
3850- iArchName := a[i].Image.Arch
3851- jArchName := a[j].Image.Arch
3852- iArch := arch.Info[iArchName]
3853- jArch := arch.Info[jArchName]
3854- // Wider word-size first.
3855- switch {
3856- case iArch.WordSize > jArch.WordSize:
3857- return true
3858- case iArch.WordSize < jArch.WordSize:
3859- return false
3860- }
3861- // Alphabetically by arch name.
3862- switch {
3863- case iArchName < jArchName:
3864- return true
3865- case iArchName > jArchName:
3866- return false
3867- }
3868- // If word-size and name the same, keep stable.
3869- return a[i].order < a[j].order
3870-}
3871-
3872-func (a byArch) Swap(i, j int) {
3873- a[i], a[j] = a[j], a[i]
3874+// preferredSpec will if possible return a spec with arch matching that
3875+// of the host machine.
3876+func preferredSpec(specs []*InstanceSpec) *InstanceSpec {
3877+ if len(specs) > 1 {
3878+ hostArch := arch.HostArch()
3879+ for _, spec := range specs {
3880+ if spec.Image.Arch == hostArch {
3881+ return spec
3882+ }
3883+ }
3884+ }
3885+ if len(specs) > 0 {
3886+ return specs[0]
3887+ }
3888+ return nil
3889 }
3890
3891 // Image holds the attributes that vary amongst relevant images for
3892
3893=== modified file 'environs/instances/image_test.go'
3894--- environs/instances/image_test.go 2014-05-20 04:27:02 +0000
3895+++ environs/instances/image_test.go 2014-05-22 14:33:28 +0000
3896@@ -11,12 +11,13 @@
3897 "launchpad.net/juju-core/constraints"
3898 "launchpad.net/juju-core/environs/imagemetadata"
3899 "launchpad.net/juju-core/environs/simplestreams"
3900- coretesting "launchpad.net/juju-core/testing"
3901+ "launchpad.net/juju-core/juju/arch"
3902+ "launchpad.net/juju-core/testing/testbase"
3903 "launchpad.net/juju-core/utils"
3904 )
3905
3906 type imageSuite struct {
3907- coretesting.BaseSuite
3908+ testbase.LoggingSuite
3909 }
3910
3911 func Test(t *testing.T) {
3912@@ -90,10 +91,10 @@
3913 }
3914 }
3915 },
3916- "com.ubuntu.cloud:server:12.04:armhf": {
3917+ "com.ubuntu.cloud:server:12.04:arm": {
3918 "release": "precise",
3919 "version": "12.04",
3920- "arch": "armhf",
3921+ "arch": "arm",
3922 "versions": {
3923 "20121218": {
3924 "items": {
3925@@ -116,57 +117,7 @@
3926 "id": "ami-00000036"
3927 }
3928 },
3929- "pubname": "ubuntu-precise-12.04-armhf-server-20121218",
3930- "label": "release"
3931- }
3932- }
3933- },
3934- "com.ubuntu.cloud:server:12.04:i386": {
3935- "release": "precise",
3936- "version": "12.04",
3937- "arch": "i386",
3938- "versions": {
3939- "20121218": {
3940- "items": {
3941- "apne1pe": {
3942- "root_store": "ebs",
3943- "virt": "pv",
3944- "region": "ap-northeast-1",
3945- "id": "ami-b79b09b6"
3946- },
3947- "test1pe": {
3948- "root_store": "ebs",
3949- "virt": "pv",
3950- "region": "test",
3951- "id": "ami-b79b09b7"
3952- }
3953- },
3954- "pubname": "ubuntu-precise-12.04-i386-server-20121218",
3955- "label": "release"
3956- }
3957- }
3958- },
3959- "com.ubuntu.cloud:server:12.04:ppc64": {
3960- "release": "precise",
3961- "version": "12.04",
3962- "arch": "ppc64",
3963- "versions": {
3964- "20121218": {
3965- "items": {
3966- "apne1pe": {
3967- "root_store": "ebs",
3968- "virt": "pv",
3969- "region": "ap-northeast-1",
3970- "id": "ami-b79b09b8"
3971- },
3972- "test1pe": {
3973- "root_store": "ebs",
3974- "virt": "pv",
3975- "region": "test",
3976- "id": "ami-b79b09b9"
3977- }
3978- },
3979- "pubname": "ubuntu-precise-12.04-ppc64-server-20121218",
3980+ "pubname": "ubuntu-precise-12.04-arm-server-20121218",
3981 "label": "release"
3982 }
3983 }
3984@@ -216,10 +167,10 @@
3985
3986 func (p *instanceSpecTestParams) init() {
3987 if p.arches == nil {
3988- p.arches = []string{"amd64", "armhf"}
3989+ p.arches = []string{"amd64", "arm"}
3990 }
3991 if p.instanceTypes == nil {
3992- p.instanceTypes = []InstanceType{{Id: "1", Name: "it-1", Arches: []string{"amd64", "armhf"}}}
3993+ p.instanceTypes = []InstanceType{{Id: "1", Name: "it-1", Arches: []string{"amd64", "arm"}}}
3994 p.instanceTypeId = "1"
3995 p.instanceTypeName = "it-1"
3996 }
3997@@ -236,42 +187,6 @@
3998 },
3999 },
4000 {
4001- desc: "prefer amd64 over i386",
4002- region: "test",
4003- imageId: "ami-00000033",
4004- arches: []string{"amd64", "i386"},
4005- instanceTypes: []InstanceType{
4006- {Id: "1", Name: "it-1", Arches: []string{"i386", "amd64"}, VirtType: &pv, Mem: 512},
4007- },
4008- },
4009- {
4010- desc: "prefer armhf over i386 (first alphabetical wins)",
4011- region: "test",
4012- imageId: "ami-00000034",
4013- arches: []string{"armhf", "i386"},
4014- instanceTypes: []InstanceType{
4015- {Id: "1", Name: "it-1", Arches: []string{"armhf", "i386"}, VirtType: &pv, Mem: 512},
4016- },
4017- },
4018- {
4019- desc: "prefer ppc64 over i386 (64-bit trumps 32-bit, regardless of alphabetical order)",
4020- region: "test",
4021- imageId: "ami-b79b09b9",
4022- arches: []string{"ppc64", "i386"},
4023- instanceTypes: []InstanceType{
4024- {Id: "1", Name: "it-1", Arches: []string{"i386", "ppc64"}, VirtType: &pv, Mem: 512},
4025- },
4026- },
4027- {
4028- desc: "prefer amd64 over arm64 (first 64-bit alphabetical wins)",
4029- region: "test",
4030- imageId: "ami-00000033",
4031- arches: []string{"arm64", "amd64"},
4032- instanceTypes: []InstanceType{
4033- {Id: "1", Name: "it-1", Arches: []string{"arm64", "amd64"}, VirtType: &pv, Mem: 512},
4034- },
4035- },
4036- {
4037 desc: "explicit release stream",
4038 region: "test",
4039 stream: "released",
4040@@ -328,7 +243,7 @@
4041 {
4042 desc: "no image exists in metadata",
4043 region: "invalid-region",
4044- err: `no "precise" images in invalid-region with arches \[amd64 armhf\]`,
4045+ err: `no "precise" images in invalid-region with arches \[amd64 arm\]`,
4046 },
4047 {
4048 desc: "no valid instance types",
4049@@ -392,6 +307,44 @@
4050 }
4051 }
4052
4053+func (s *imageSuite) TestPreferredSpec(c *gc.C) {
4054+ type prefTest struct {
4055+ desc string
4056+ specs []*InstanceSpec
4057+ expected *InstanceSpec
4058+ }
4059+
4060+ s.PatchValue(&arch.HostArch, func() string { return arch.ARM64 })
4061+
4062+ amd64 := &InstanceSpec{Image: Image{Arch: arch.AMD64}}
4063+ i386 := &InstanceSpec{Image: Image{Arch: arch.I386}}
4064+ arm64 := &InstanceSpec{Image: Image{Arch: arch.ARM64}}
4065+
4066+ prefTests := []prefTest{
4067+ {
4068+ "choose hostarch (arm64) over other arches",
4069+ []*InstanceSpec{i386, arm64, amd64},
4070+ arm64,
4071+ },
4072+ {
4073+ "choose first image if no arm64",
4074+ []*InstanceSpec{i386, amd64},
4075+ i386,
4076+ },
4077+ {
4078+ "choose only image only one there",
4079+ []*InstanceSpec{amd64},
4080+ amd64,
4081+ },
4082+ }
4083+
4084+ for n, test := range prefTests {
4085+ c.Logf("PreferredSpec test %d: %s", n, test.desc)
4086+ actual := preferredSpec(test.specs)
4087+ c.Assert(actual, gc.Equals, test.expected)
4088+ }
4089+}
4090+
4091 var imageMatchtests = []struct {
4092 image Image
4093 itype InstanceType
4094@@ -403,14 +356,14 @@
4095 match: true,
4096 }, {
4097 image: Image{Arch: "amd64"},
4098- itype: InstanceType{Arches: []string{"amd64", "armhf"}},
4099+ itype: InstanceType{Arches: []string{"amd64", "arm"}},
4100 match: true,
4101 }, {
4102 image: Image{Arch: "amd64", VirtType: hvm},
4103 itype: InstanceType{Arches: []string{"amd64"}, VirtType: &hvm},
4104 match: true,
4105 }, {
4106- image: Image{Arch: "armhf"},
4107+ image: Image{Arch: "arm"},
4108 itype: InstanceType{Arches: []string{"amd64"}},
4109 }, {
4110 image: Image{Arch: "amd64", VirtType: hvm},
4111
4112=== modified file 'environs/instances/instancetype_test.go'
4113--- environs/instances/instancetype_test.go 2014-05-20 04:27:02 +0000
4114+++ environs/instances/instancetype_test.go 2014-05-22 14:33:28 +0000
4115@@ -9,11 +9,11 @@
4116 gc "launchpad.net/gocheck"
4117
4118 "launchpad.net/juju-core/constraints"
4119- "launchpad.net/juju-core/testing"
4120+ "launchpad.net/juju-core/testing/testbase"
4121 )
4122
4123 type instanceTypeSuite struct {
4124- testing.BaseSuite
4125+ testbase.LoggingSuite
4126 }
4127
4128 var _ = gc.Suite(&instanceTypeSuite{})
4129
4130=== modified file 'environs/jujutest/livetests.go'
4131--- environs/jujutest/livetests.go 2014-05-20 00:11:22 +0000
4132+++ environs/jujutest/livetests.go 2014-05-22 14:33:28 +0000
4133@@ -33,6 +33,7 @@
4134 "launchpad.net/juju-core/state/api"
4135 statetesting "launchpad.net/juju-core/state/testing"
4136 coretesting "launchpad.net/juju-core/testing"
4137+ "launchpad.net/juju-core/testing/testbase"
4138 coretools "launchpad.net/juju-core/tools"
4139 "launchpad.net/juju-core/utils"
4140 "launchpad.net/juju-core/version"
4141@@ -42,6 +43,7 @@
4142 // (e.g. Amazon EC2). The Environ is opened once only for all the tests
4143 // in the suite, stored in Env, and Destroyed after the suite has completed.
4144 type LiveTests struct {
4145+ testbase.LoggingSuite
4146 envtesting.ToolsFixture
4147
4148 // TestConfig contains the configuration attributes for opening an environment.
4149@@ -73,9 +75,15 @@
4150 }
4151
4152 func (t *LiveTests) SetUpSuite(c *gc.C) {
4153+ t.LoggingSuite.SetUpSuite(c)
4154 t.ConfigStore = configstore.NewMem()
4155 }
4156
4157+func (t *LiveTests) SetUpTest(c *gc.C) {
4158+ t.LoggingSuite.SetUpTest(c)
4159+ t.ToolsFixture.SetUpTest(c)
4160+}
4161+
4162 func publicAttrs(e environs.Environ) map[string]interface{} {
4163 cfg := e.Config()
4164 secrets, err := e.Provider().SecretAttrs(cfg)
4165@@ -93,6 +101,12 @@
4166 if t.Env != nil {
4167 t.Destroy(c)
4168 }
4169+ t.LoggingSuite.TearDownSuite(c)
4170+}
4171+
4172+func (t *LiveTests) TearDownTest(c *gc.C) {
4173+ t.ToolsFixture.TearDownTest(c)
4174+ t.LoggingSuite.TearDownTest(c)
4175 }
4176
4177 // PrepareOnce ensures that the environment is
4178@@ -122,7 +136,7 @@
4179 _, err := sync.Upload(t.Env.Storage(), nil, coretesting.FakeDefaultSeries)
4180 c.Assert(err, gc.IsNil)
4181 }
4182- t.UploadFakeTools(c, t.Env.Storage())
4183+ envtesting.UploadFakeTools(c, t.Env.Storage())
4184 err := bootstrap.EnsureNotBootstrapped(t.Env)
4185 c.Assert(err, gc.IsNil)
4186 err = bootstrap.Bootstrap(coretesting.Context(c), t.Env, environs.BootstrapParams{Constraints: cons})
4187@@ -157,7 +171,7 @@
4188 // that it does not assume a pristine environment.
4189 func (t *LiveTests) TestStartStop(c *gc.C) {
4190 t.PrepareOnce(c)
4191- t.UploadFakeTools(c, t.Env.Storage())
4192+ envtesting.UploadFakeTools(c, t.Env.Storage())
4193
4194 inst, _ := testing.AssertStartInstance(c, t.Env, "0")
4195 c.Assert(inst, gc.NotNil)
4196@@ -211,7 +225,7 @@
4197
4198 func (t *LiveTests) TestPorts(c *gc.C) {
4199 t.PrepareOnce(c)
4200- t.UploadFakeTools(c, t.Env.Storage())
4201+ envtesting.UploadFakeTools(c, t.Env.Storage())
4202
4203 inst1, _ := testing.AssertStartInstance(c, t.Env, "1")
4204 c.Assert(inst1, gc.NotNil)
4205@@ -300,7 +314,7 @@
4206
4207 func (t *LiveTests) TestGlobalPorts(c *gc.C) {
4208 t.PrepareOnce(c)
4209- t.UploadFakeTools(c, t.Env.Storage())
4210+ envtesting.UploadFakeTools(c, t.Env.Storage())
4211
4212 // Change configuration.
4213 oldConfig := t.Env.Config()
4214
4215=== modified file 'environs/jujutest/tests.go'
4216--- environs/jujutest/tests.go 2014-05-19 09:06:00 +0000
4217+++ environs/jujutest/tests.go 2014-05-22 14:33:28 +0000
4218@@ -22,6 +22,7 @@
4219 "launchpad.net/juju-core/instance"
4220 "launchpad.net/juju-core/juju/testing"
4221 coretesting "launchpad.net/juju-core/testing"
4222+ "launchpad.net/juju-core/testing/testbase"
4223 "launchpad.net/juju-core/utils"
4224 "launchpad.net/juju-core/version"
4225 )
4226@@ -32,6 +33,7 @@
4227 // is opened once for each test, and some potentially expensive operations
4228 // may be executed.
4229 type Tests struct {
4230+ testbase.LoggingSuite
4231 TestConfig coretesting.Attrs
4232 envtesting.ToolsFixture
4233
4234@@ -64,17 +66,19 @@
4235 }
4236
4237 func (t *Tests) SetUpTest(c *gc.C) {
4238+ t.LoggingSuite.SetUpTest(c)
4239 t.ToolsFixture.SetUpTest(c)
4240 t.ConfigStore = configstore.NewMem()
4241 }
4242
4243 func (t *Tests) TearDownTest(c *gc.C) {
4244 t.ToolsFixture.TearDownTest(c)
4245+ t.LoggingSuite.TearDownTest(c)
4246 }
4247
4248 func (t *Tests) TestStartStop(c *gc.C) {
4249 e := t.Prepare(c)
4250- t.UploadFakeTools(c, e.Storage())
4251+ envtesting.UploadFakeTools(c, e.Storage())
4252 cfg, err := e.Config().Apply(map[string]interface{}{
4253 "agent-version": version.Current.Number.String(),
4254 })
4255@@ -125,7 +129,7 @@
4256
4257 func (t *Tests) TestBootstrap(c *gc.C) {
4258 e := t.Prepare(c)
4259- t.UploadFakeTools(c, e.Storage())
4260+ envtesting.UploadFakeTools(c, e.Storage())
4261 err := bootstrap.EnsureNotBootstrapped(e)
4262 c.Assert(err, gc.IsNil)
4263 err = bootstrap.Bootstrap(coretesting.Context(c), e, environs.BootstrapParams{})
4264@@ -139,7 +143,7 @@
4265 c.Assert(err, gc.ErrorMatches, "environment is already bootstrapped")
4266
4267 e2 := t.Open(c)
4268- t.UploadFakeTools(c, e2.Storage())
4269+ envtesting.UploadFakeTools(c, e2.Storage())
4270 err = bootstrap.EnsureNotBootstrapped(e2)
4271 c.Assert(err, gc.ErrorMatches, "environment is already bootstrapped")
4272
4273@@ -152,7 +156,7 @@
4274
4275 // Prepare again because Destroy invalidates old environments.
4276 e3 := t.Prepare(c)
4277- t.UploadFakeTools(c, e3.Storage())
4278+ envtesting.UploadFakeTools(c, e3.Storage())
4279
4280 err = bootstrap.EnsureNotBootstrapped(e3)
4281 c.Assert(err, gc.IsNil)
4282
4283=== modified file 'environs/manual/addresses_test.go'
4284--- environs/manual/addresses_test.go 2014-05-20 04:27:02 +0000
4285+++ environs/manual/addresses_test.go 2014-05-22 14:33:28 +0000
4286@@ -10,7 +10,7 @@
4287
4288 "launchpad.net/juju-core/environs/manual"
4289 "launchpad.net/juju-core/instance"
4290- "launchpad.net/juju-core/testing"
4291+ "launchpad.net/juju-core/testing/testbase"
4292 )
4293
4294 const (
4295@@ -19,7 +19,7 @@
4296 )
4297
4298 type addressesSuite struct {
4299- testing.BaseSuite
4300+ testbase.LoggingSuite
4301 netLookupHostCalled int
4302 }
4303
4304
4305=== modified file 'environs/manual/init_test.go'
4306--- environs/manual/init_test.go 2014-05-20 04:27:02 +0000
4307+++ environs/manual/init_test.go 2014-05-22 14:33:28 +0000
4308@@ -10,11 +10,11 @@
4309 gc "launchpad.net/gocheck"
4310
4311 "launchpad.net/juju-core/environs/manual"
4312- "launchpad.net/juju-core/testing"
4313+ "launchpad.net/juju-core/testing/testbase"
4314 )
4315
4316 type initialisationSuite struct {
4317- testing.BaseSuite
4318+ testbase.LoggingSuite
4319 }
4320
4321 var _ = gc.Suite(&initialisationSuite{})
4322
4323=== modified file 'environs/open_test.go'
4324--- environs/open_test.go 2014-05-16 01:33:13 +0000
4325+++ environs/open_test.go 2014-05-22 14:33:28 +0000
4326@@ -18,23 +18,18 @@
4327 envtesting "launchpad.net/juju-core/environs/testing"
4328 "launchpad.net/juju-core/provider/dummy"
4329 "launchpad.net/juju-core/testing"
4330+ "launchpad.net/juju-core/testing/testbase"
4331 )
4332
4333 type OpenSuite struct {
4334- testing.FakeJujuHomeSuite
4335+ testbase.LoggingSuite
4336 envtesting.ToolsFixture
4337 }
4338
4339 var _ = gc.Suite(&OpenSuite{})
4340
4341-func (s *OpenSuite) SetUpTest(c *gc.C) {
4342- s.FakeJujuHomeSuite.SetUpTest(c)
4343- testing.WriteEnvironments(c, testing.MultipleEnvConfigNoDefault)
4344-}
4345-
4346-func (s *OpenSuite) TearDownTest(c *gc.C) {
4347+func (*OpenSuite) TearDownTest(c *gc.C) {
4348 dummy.Reset()
4349- s.FakeJujuHomeSuite.TearDownTest(c)
4350 }
4351
4352 func (*OpenSuite) TestNewDummyEnviron(c *gc.C) {
4353@@ -59,6 +54,7 @@
4354 }
4355
4356 func (*OpenSuite) TestNewFromName(c *gc.C) {
4357+ defer testing.MakeFakeHome(c, testing.MultipleEnvConfigNoDefault, testing.SampleCertName).Restore()
4358 store := configstore.NewMem()
4359 ctx := testing.Context(c)
4360 e, err := environs.PrepareFromName("erewhemos", ctx, store)
4361@@ -70,6 +66,7 @@
4362 }
4363
4364 func (*OpenSuite) TestNewFromNameWithInvalidInfo(c *gc.C) {
4365+ defer testing.MakeFakeHome(c, testing.MultipleEnvConfigNoDefault, testing.SampleCertName).Restore()
4366 store := configstore.NewMem()
4367 cfg, _, err := environs.ConfigForName("erewhemos", store)
4368 c.Assert(err, gc.IsNil)
4369@@ -89,6 +86,7 @@
4370 }
4371
4372 func (*OpenSuite) TestNewFromNameWithInvalidEnvironConfig(c *gc.C) {
4373+ defer testing.MakeFakeHome(c, testing.MultipleEnvConfigNoDefault, testing.SampleCertName).Restore()
4374 store := configstore.NewMem()
4375
4376 e, err := environs.NewFromName("erewhemos", store)
4377@@ -97,6 +95,7 @@
4378 }
4379
4380 func (*OpenSuite) TestPrepareFromName(c *gc.C) {
4381+ defer testing.MakeFakeHome(c, testing.MultipleEnvConfigNoDefault, testing.SampleCertName).Restore()
4382 ctx := testing.Context(c)
4383 e, err := environs.PrepareFromName("erewhemos", ctx, configstore.NewMem())
4384 c.Assert(err, gc.IsNil)
4385@@ -106,6 +105,7 @@
4386 }
4387
4388 func (*OpenSuite) TestConfigForName(c *gc.C) {
4389+ defer testing.MakeFakeHome(c, testing.MultipleEnvConfigNoDefault, testing.SampleCertName).Restore()
4390 cfg, source, err := environs.ConfigForName("erewhemos", configstore.NewMem())
4391 c.Assert(err, gc.IsNil)
4392 c.Assert(source, gc.Equals, environs.ConfigFromEnvirons)
4393@@ -113,6 +113,7 @@
4394 }
4395
4396 func (*OpenSuite) TestConfigForNameNoDefault(c *gc.C) {
4397+ defer testing.MakeFakeHome(c, testing.MultipleEnvConfigNoDefault, testing.SampleCertName).Restore()
4398 cfg, source, err := environs.ConfigForName("", configstore.NewMem())
4399 c.Assert(err, gc.ErrorMatches, "no default environment found")
4400 c.Assert(cfg, gc.IsNil)
4401@@ -120,7 +121,7 @@
4402 }
4403
4404 func (*OpenSuite) TestConfigForNameDefault(c *gc.C) {
4405- testing.WriteEnvironments(c, testing.SingleEnvConfig)
4406+ defer testing.MakeFakeHome(c, testing.SingleEnvConfig, testing.SampleCertName).Restore()
4407 cfg, source, err := environs.ConfigForName("", configstore.NewMem())
4408 c.Assert(err, gc.IsNil)
4409 c.Assert(cfg.Name(), gc.Equals, "erewhemos")
4410@@ -128,7 +129,7 @@
4411 }
4412
4413 func (*OpenSuite) TestConfigForNameFromInfo(c *gc.C) {
4414- testing.WriteEnvironments(c, testing.SingleEnvConfig)
4415+ defer testing.MakeFakeHome(c, testing.SingleEnvConfig, testing.SampleCertName).Restore()
4416 store := configstore.NewMem()
4417 cfg, source, err := environs.ConfigForName("", store)
4418 c.Assert(err, gc.IsNil)
4419@@ -325,23 +326,17 @@
4420 authorized-keys: i-am-a-key
4421 `
4422
4423-type checkEnvironmentSuite struct {
4424- testing.FakeJujuHomeSuite
4425-}
4426+type checkEnvironmentSuite struct{}
4427
4428 var _ = gc.Suite(&checkEnvironmentSuite{})
4429
4430-func (s *checkEnvironmentSuite) SetUpTest(c *gc.C) {
4431- s.FakeJujuHomeSuite.SetUpTest(c)
4432- testing.WriteEnvironments(c, checkEnv)
4433-}
4434-
4435 func (s *checkEnvironmentSuite) TearDownTest(c *gc.C) {
4436 dummy.Reset()
4437- s.FakeJujuHomeSuite.TearDownTest(c)
4438 }
4439
4440 func (s *checkEnvironmentSuite) TestCheckEnvironment(c *gc.C) {
4441+ defer testing.MakeFakeHome(c, checkEnv, "existing").Restore()
4442+
4443 ctx := testing.Context(c)
4444 environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem())
4445 c.Assert(err, gc.IsNil)
4446@@ -356,6 +351,8 @@
4447 }
4448
4449 func (s *checkEnvironmentSuite) TestCheckEnvironmentFileNotFound(c *gc.C) {
4450+ defer testing.MakeFakeHome(c, checkEnv, "existing").Restore()
4451+
4452 ctx := testing.Context(c)
4453 environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem())
4454 c.Assert(err, gc.IsNil)
4455@@ -376,6 +373,8 @@
4456 }
4457
4458 func (s *checkEnvironmentSuite) TestCheckEnvironmentGetFails(c *gc.C) {
4459+ defer testing.MakeFakeHome(c, checkEnv, "existing").Restore()
4460+
4461 ctx := testing.Context(c)
4462 environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem())
4463 c.Assert(err, gc.IsNil)
4464@@ -395,6 +394,8 @@
4465 }
4466
4467 func (s *checkEnvironmentSuite) TestCheckEnvironmentBadContent(c *gc.C) {
4468+ defer testing.MakeFakeHome(c, checkEnv, "existing").Restore()
4469+
4470 ctx := testing.Context(c)
4471 environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem())
4472 c.Assert(err, gc.IsNil)
4473
4474=== modified file 'environs/simplestreams/testing/testing.go'
4475--- environs/simplestreams/testing/testing.go 2014-05-20 04:27:02 +0000
4476+++ environs/simplestreams/testing/testing.go 2014-05-22 14:33:28 +0000
4477@@ -13,7 +13,7 @@
4478
4479 "launchpad.net/juju-core/environs/jujutest"
4480 "launchpad.net/juju-core/environs/simplestreams"
4481- "launchpad.net/juju-core/testing"
4482+ "launchpad.net/juju-core/testing/testbase"
4483 "launchpad.net/juju-core/version/ubuntu"
4484 )
4485
4486@@ -506,7 +506,7 @@
4487 }
4488
4489 type LocalLiveSimplestreamsSuite struct {
4490- testing.BaseSuite
4491+ testbase.LoggingSuite
4492 Source simplestreams.DataSource
4493 RequireSigned bool
4494 DataType string
4495@@ -514,11 +514,11 @@
4496 }
4497
4498 func (s *LocalLiveSimplestreamsSuite) SetUpSuite(c *gc.C) {
4499- s.BaseSuite.SetUpSuite(c)
4500+ s.LoggingSuite.SetUpSuite(c)
4501 }
4502
4503 func (s *LocalLiveSimplestreamsSuite) TearDownSuite(c *gc.C) {
4504- s.BaseSuite.TearDownSuite(c)
4505+ s.LoggingSuite.TearDownSuite(c)
4506 }
4507
4508 const (
4509
4510=== modified file 'environs/sshstorage/storage_test.go'
4511--- environs/sshstorage/storage_test.go 2014-05-20 04:27:02 +0000
4512+++ environs/sshstorage/storage_test.go 2014-05-22 14:33:28 +0000
4513@@ -22,13 +22,13 @@
4514 gc "launchpad.net/gocheck"
4515
4516 "launchpad.net/juju-core/environs/storage"
4517- coretesting "launchpad.net/juju-core/testing"
4518+ "launchpad.net/juju-core/testing/testbase"
4519 "launchpad.net/juju-core/utils"
4520 "launchpad.net/juju-core/utils/ssh"
4521 )
4522
4523 type storageSuite struct {
4524- coretesting.BaseSuite
4525+ testbase.LoggingSuite
4526 bin string
4527 }
4528
4529@@ -56,7 +56,7 @@
4530 var flockBin string
4531
4532 func (s *storageSuite) SetUpSuite(c *gc.C) {
4533- s.BaseSuite.SetUpSuite(c)
4534+ s.LoggingSuite.SetUpSuite(c)
4535
4536 var err error
4537 flockBin, err = exec.LookPath("flock")
4538
4539=== modified file 'environs/storage/storage_test.go'
4540--- environs/storage/storage_test.go 2014-05-16 01:33:13 +0000
4541+++ environs/storage/storage_test.go 2014-05-22 14:33:28 +0000
4542@@ -27,7 +27,7 @@
4543 var _ = gc.Suite(&datasourceSuite{})
4544
4545 type datasourceSuite struct {
4546- testing.FakeJujuHomeSuite
4547+ home *testing.FakeHome
4548 stor storage.Storage
4549 baseURL string
4550 }
4551@@ -41,8 +41,7 @@
4552 `
4553
4554 func (s *datasourceSuite) SetUpTest(c *gc.C) {
4555- s.FakeJujuHomeSuite.SetUpTest(c)
4556- testing.WriteEnvironments(c, existingEnv)
4557+ s.home = testing.MakeFakeHome(c, existingEnv, "existing")
4558 environ, err := environs.PrepareFromName("test", testing.Context(c), configstore.NewMem())
4559 c.Assert(err, gc.IsNil)
4560 s.stor = environ.Storage()
4561@@ -52,7 +51,7 @@
4562
4563 func (s *datasourceSuite) TearDownTest(c *gc.C) {
4564 dummy.Reset()
4565- s.FakeJujuHomeSuite.TearDownTest(c)
4566+ s.home.Restore()
4567 }
4568
4569 func (s *datasourceSuite) TestFetch(c *gc.C) {
4570
4571=== modified file 'environs/sync/sync_test.go'
4572--- environs/sync/sync_test.go 2014-05-20 00:01:25 +0000
4573+++ environs/sync/sync_test.go 2014-05-22 14:33:28 +0000
4574@@ -40,7 +40,7 @@
4575 }
4576
4577 type syncSuite struct {
4578- coretesting.FakeJujuHomeSuite
4579+ testbase.LoggingSuite
4580 envtesting.ToolsFixture
4581 targetEnv environs.Environ
4582 origVersion version.Binary
4583@@ -53,21 +53,21 @@
4584 var _ = gc.Suite(&badBuildSuite{})
4585
4586 func (s *syncSuite) setUpTest(c *gc.C) {
4587- s.FakeJujuHomeSuite.SetUpTest(c)
4588+ s.LoggingSuite.SetUpTest(c)
4589 s.ToolsFixture.SetUpTest(c)
4590 s.origVersion = version.Current
4591 // It's important that this be v1.8.x to match the test data.
4592 version.Current.Number = version.MustParse("1.8.3")
4593
4594 // Create a target environments.yaml.
4595- envConfig := `
4596+ fakeHome := coretesting.MakeFakeHome(c, `
4597 environments:
4598 test-target:
4599 type: dummy
4600 state-server: false
4601 authorized-keys: "not-really-one"
4602-`
4603- coretesting.WriteEnvironments(c, envConfig)
4604+`)
4605+ s.AddCleanup(func(*gc.C) { fakeHome.Restore() })
4606 var err error
4607 s.targetEnv, err = environs.PrepareFromName("test-target", coretesting.Context(c), configstore.NewMem())
4608 c.Assert(err, gc.IsNil)
4609@@ -100,7 +100,7 @@
4610 dummy.Reset()
4611 version.Current = s.origVersion
4612 s.ToolsFixture.TearDownTest(c)
4613- s.FakeJujuHomeSuite.TearDownTest(c)
4614+ s.LoggingSuite.TearDownTest(c)
4615 }
4616
4617 var tests = []struct {
4618@@ -255,12 +255,12 @@
4619
4620 type uploadSuite struct {
4621 env environs.Environ
4622- coretesting.FakeJujuHomeSuite
4623+ testbase.LoggingSuite
4624 envtesting.ToolsFixture
4625 }
4626
4627 func (s *uploadSuite) SetUpTest(c *gc.C) {
4628- s.FakeJujuHomeSuite.SetUpTest(c)
4629+ s.LoggingSuite.SetUpTest(c)
4630 s.ToolsFixture.SetUpTest(c)
4631 // We only want to use simplestreams to find any synced tools.
4632 cfg, err := config.New(config.NoDefaults, dummy.SampleConfig())
4633@@ -272,7 +272,7 @@
4634 func (s *uploadSuite) TearDownTest(c *gc.C) {
4635 dummy.Reset()
4636 s.ToolsFixture.TearDownTest(c)
4637- s.FakeJujuHomeSuite.TearDownTest(c)
4638+ s.LoggingSuite.TearDownTest(c)
4639 }
4640
4641 func (s *uploadSuite) TestUpload(c *gc.C) {
4642
4643=== modified file 'environs/testing/tools.go'
4644--- environs/testing/tools.go 2014-05-19 06:06:35 +0000
4645+++ environs/testing/tools.go 2014-05-22 14:33:28 +0000
4646@@ -30,11 +30,6 @@
4647 type ToolsFixture struct {
4648 origDefaultURL string
4649 DefaultBaseURL string
4650-
4651- // UploadArches holds the architectures of tools to
4652- // upload in UploadFakeTools. If empty, it will default
4653- // to just version.Current.Arch.
4654- UploadArches []string
4655 }
4656
4657 func (s *ToolsFixture) SetUpTest(c *gc.C) {
4658@@ -46,26 +41,6 @@
4659 envtools.DefaultBaseURL = s.origDefaultURL
4660 }
4661
4662-// UploadFakeTools uploads fake tools of the architectures in
4663-// s.UploadArches for each LTS release to the specified storage.
4664-func (s *ToolsFixture) UploadFakeTools(c *gc.C, stor storage.Storage) {
4665- arches := s.UploadArches
4666- if len(arches) == 0 {
4667- arches = []string{version.Current.Arch}
4668- }
4669- var versions []version.Binary
4670- for _, arch := range arches {
4671- v := version.Current
4672- v.Arch = arch
4673- for _, series := range bootstrap.ToolsLtsSeries {
4674- v.Series = series
4675- versions = append(versions, v)
4676- }
4677- }
4678- _, err := UploadFakeToolsVersions(stor, versions...)
4679- c.Assert(err, gc.IsNil)
4680-}
4681-
4682 // RemoveFakeToolsMetadata deletes the fake simplestreams tools metadata from the supplied storage.
4683 func RemoveFakeToolsMetadata(c *gc.C, stor storage.Storage) {
4684 files := []string{simplestreams.UnsignedIndex, envtools.ProductMetadataPath}
4685
4686=== modified file 'environs/tools/build_test.go'
4687--- environs/tools/build_test.go 2014-05-20 04:27:02 +0000
4688+++ environs/tools/build_test.go 2014-05-22 14:33:28 +0000
4689@@ -12,11 +12,11 @@
4690 gc "launchpad.net/gocheck"
4691
4692 "launchpad.net/juju-core/environs/tools"
4693- "launchpad.net/juju-core/testing"
4694+ "launchpad.net/juju-core/testing/testbase"
4695 )
4696
4697 type buildSuite struct {
4698- testing.BaseSuite
4699+ testbase.LoggingSuite
4700 restore func()
4701 cwd string
4702 filePath string
4703@@ -25,7 +25,7 @@
4704 var _ = gc.Suite(&buildSuite{})
4705
4706 func (b *buildSuite) SetUpTest(c *gc.C) {
4707- b.BaseSuite.SetUpTest(c)
4708+ b.LoggingSuite.SetUpTest(c)
4709
4710 dir1 := c.MkDir()
4711 dir2 := c.MkDir()
4712@@ -59,7 +59,7 @@
4713
4714 func (b *buildSuite) TearDownTest(c *gc.C) {
4715 b.restore()
4716- b.BaseSuite.TearDownTest(c)
4717+ b.LoggingSuite.TearDownTest(c)
4718 }
4719
4720 func (b *buildSuite) TestFindExecutable(c *gc.C) {
4721
4722=== modified file 'environs/tools/storage_test.go'
4723--- environs/tools/storage_test.go 2014-05-20 04:27:02 +0000
4724+++ environs/tools/storage_test.go 2014-05-22 14:33:28 +0000
4725@@ -13,21 +13,21 @@
4726 envtools "launchpad.net/juju-core/environs/tools"
4727 "launchpad.net/juju-core/provider/dummy"
4728 "launchpad.net/juju-core/testing"
4729- coretesting "launchpad.net/juju-core/testing"
4730+ "launchpad.net/juju-core/testing/testbase"
4731 coretools "launchpad.net/juju-core/tools"
4732 "launchpad.net/juju-core/version"
4733 )
4734
4735 type StorageSuite struct {
4736 env environs.Environ
4737- coretesting.BaseSuite
4738+ testbase.LoggingSuite
4739 dataDir string
4740 }
4741
4742 var _ = gc.Suite(&StorageSuite{})
4743
4744 func (s *StorageSuite) SetUpTest(c *gc.C) {
4745- s.BaseSuite.SetUpTest(c)
4746+ s.LoggingSuite.SetUpTest(c)
4747 cfg, err := config.New(config.NoDefaults, dummy.SampleConfig())
4748 c.Assert(err, gc.IsNil)
4749 s.env, err = environs.Prepare(cfg, testing.Context(c), configstore.NewMem())
4750@@ -37,7 +37,7 @@
4751
4752 func (s *StorageSuite) TearDownTest(c *gc.C) {
4753 dummy.Reset()
4754- s.BaseSuite.TearDownTest(c)
4755+ s.LoggingSuite.TearDownTest(c)
4756 }
4757
4758 func (s *StorageSuite) TestStorageName(c *gc.C) {
4759
4760=== modified file 'environs/tools/tools_test.go'
4761--- environs/tools/tools_test.go 2014-05-21 22:15:10 +0000
4762+++ environs/tools/tools_test.go 2014-05-22 14:33:28 +0000
4763@@ -21,14 +21,14 @@
4764 toolstesting "launchpad.net/juju-core/environs/tools/testing"
4765 "launchpad.net/juju-core/provider/dummy"
4766 "launchpad.net/juju-core/testing"
4767- coretesting "launchpad.net/juju-core/testing"
4768+ "launchpad.net/juju-core/testing/testbase"
4769 coretools "launchpad.net/juju-core/tools"
4770 "launchpad.net/juju-core/version"
4771 )
4772
4773 type SimpleStreamsToolsSuite struct {
4774 env environs.Environ
4775- coretesting.BaseSuite
4776+ testbase.LoggingSuite
4777 envtesting.ToolsFixture
4778 origCurrentVersion version.Binary
4779 customToolsDir string
4780@@ -40,14 +40,14 @@
4781 }
4782
4783 func (s *SimpleStreamsToolsSuite) SetUpSuite(c *gc.C) {
4784- s.BaseSuite.SetUpSuite(c)
4785+ s.LoggingSuite.SetUpSuite(c)
4786 s.customToolsDir = c.MkDir()
4787 s.publicToolsDir = c.MkDir()
4788 }
4789
4790 func (s *SimpleStreamsToolsSuite) SetUpTest(c *gc.C) {
4791 s.ToolsFixture.DefaultBaseURL = "file://" + s.publicToolsDir
4792- s.BaseSuite.SetUpTest(c)
4793+ s.LoggingSuite.SetUpTest(c)
4794 s.ToolsFixture.SetUpTest(c)
4795 s.origCurrentVersion = version.Current
4796 s.reset(c, nil)
4797@@ -57,7 +57,7 @@
4798 dummy.Reset()
4799 version.Current = s.origCurrentVersion
4800 s.ToolsFixture.TearDownTest(c)
4801- s.BaseSuite.TearDownTest(c)
4802+ s.LoggingSuite.TearDownTest(c)
4803 }
4804
4805 func (s *SimpleStreamsToolsSuite) reset(c *gc.C, attrs map[string]interface{}) {
4806
4807=== modified file 'environs/tools/urls_test.go'
4808--- environs/tools/urls_test.go 2014-05-15 05:14:01 +0000
4809+++ environs/tools/urls_test.go 2014-05-22 14:33:28 +0000
4810@@ -17,18 +17,21 @@
4811 "launchpad.net/juju-core/environs/tools"
4812 "launchpad.net/juju-core/provider/dummy"
4813 "launchpad.net/juju-core/testing"
4814- coretesting "launchpad.net/juju-core/testing"
4815 )
4816
4817 type URLsSuite struct {
4818- coretesting.BaseSuite
4819+ home *testing.FakeHome
4820 }
4821
4822 var _ = gc.Suite(&URLsSuite{})
4823
4824+func (s *URLsSuite) SetUpTest(c *gc.C) {
4825+ s.home = testing.MakeEmptyFakeHome(c)
4826+}
4827+
4828 func (s *URLsSuite) TearDownTest(c *gc.C) {
4829+ s.home.Restore()
4830 dummy.Reset()
4831- s.BaseSuite.TearDownTest(c)
4832 }
4833
4834 func (s *URLsSuite) env(c *gc.C, toolsMetadataURL string) environs.Environ {
4835
4836=== modified file 'environs/tools/validation_test.go'
4837--- environs/tools/validation_test.go 2014-05-20 04:27:02 +0000
4838+++ environs/tools/validation_test.go 2014-05-22 14:33:28 +0000
4839@@ -10,12 +10,12 @@
4840
4841 "launchpad.net/juju-core/environs/filestorage"
4842 "launchpad.net/juju-core/environs/simplestreams"
4843- "launchpad.net/juju-core/testing"
4844+ "launchpad.net/juju-core/testing/testbase"
4845 "launchpad.net/juju-core/utils"
4846 )
4847
4848 type ValidateSuite struct {
4849- testing.BaseSuite
4850+ testbase.LoggingSuite
4851 metadataDir string
4852 }
4853
4854@@ -40,7 +40,7 @@
4855 }
4856
4857 func (s *ValidateSuite) SetUpTest(c *gc.C) {
4858- s.BaseSuite.SetUpTest(c)
4859+ s.LoggingSuite.SetUpTest(c)
4860 s.metadataDir = c.MkDir()
4861 }
4862
4863
4864=== modified file 'instance/address_test.go'
4865--- instance/address_test.go 2014-05-20 04:27:02 +0000
4866+++ instance/address_test.go 2014-05-22 14:33:28 +0000
4867@@ -7,11 +7,11 @@
4868 jc "github.com/juju/testing/checkers"
4869 gc "launchpad.net/gocheck"
4870
4871- "launchpad.net/juju-core/testing"
4872+ "launchpad.net/juju-core/testing/testbase"
4873 )
4874
4875 type AddressSuite struct {
4876- testing.BaseSuite
4877+ testbase.LoggingSuite
4878 }
4879
4880 var _ = gc.Suite(&AddressSuite{})
4881
4882=== modified file 'juju/apiconn_test.go'
4883--- juju/apiconn_test.go 2014-05-16 01:33:13 +0000
4884+++ juju/apiconn_test.go 2014-05-22 14:33:28 +0000
4885@@ -23,24 +23,25 @@
4886 "launchpad.net/juju-core/provider/dummy"
4887 "launchpad.net/juju-core/state/api"
4888 coretesting "launchpad.net/juju-core/testing"
4889+ "launchpad.net/juju-core/testing/testbase"
4890 )
4891
4892 type NewAPIConnSuite struct {
4893- coretesting.FakeJujuHomeSuite
4894+ testbase.LoggingSuite
4895 envtesting.ToolsFixture
4896 }
4897
4898 var _ = gc.Suite(&NewAPIConnSuite{})
4899
4900 func (cs *NewAPIConnSuite) SetUpTest(c *gc.C) {
4901- cs.FakeJujuHomeSuite.SetUpTest(c)
4902+ cs.LoggingSuite.SetUpTest(c)
4903 cs.ToolsFixture.SetUpTest(c)
4904 }
4905
4906 func (cs *NewAPIConnSuite) TearDownTest(c *gc.C) {
4907 dummy.Reset()
4908 cs.ToolsFixture.TearDownTest(c)
4909- cs.FakeJujuHomeSuite.TearDownTest(c)
4910+ cs.LoggingSuite.TearDownTest(c)
4911 }
4912
4913 func (*NewAPIConnSuite) TestNewConn(c *gc.C) {
4914@@ -75,18 +76,18 @@
4915 }
4916
4917 type NewAPIClientSuite struct {
4918- coretesting.FakeJujuHomeSuite
4919+ testbase.LoggingSuite
4920 }
4921
4922 var _ = gc.Suite(&NewAPIClientSuite{})
4923
4924 func (cs *NewAPIClientSuite) TearDownTest(c *gc.C) {
4925 dummy.Reset()
4926- cs.FakeJujuHomeSuite.TearDownTest(c)
4927+ cs.LoggingSuite.TearDownTest(c)
4928 }
4929
4930 func (s *NewAPIClientSuite) TestNameDefault(c *gc.C) {
4931- coretesting.WriteEnvironments(c, coretesting.MultipleEnvConfig)
4932+ defer coretesting.MakeMultipleEnvHome(c).Restore()
4933 // The connection logic should not delay the config connection
4934 // at all when there is no environment info available.
4935 // Make sure of that by providing a suitably long delay
4936@@ -106,7 +107,7 @@
4937 }
4938
4939 func (*NewAPIClientSuite) TestNameNotDefault(c *gc.C) {
4940- coretesting.WriteEnvironments(c, coretesting.MultipleEnvConfig)
4941+ defer coretesting.MakeMultipleEnvHome(c).Restore()
4942 envName := coretesting.SampleCertName + "-2"
4943 bootstrapEnv(c, envName, defaultConfigStore(c))
4944 apiclient, err := juju.NewAPIClientFromName(envName)
4945@@ -116,6 +117,7 @@
4946 }
4947
4948 func (s *NewAPIClientSuite) TestWithInfoOnly(c *gc.C) {
4949+ defer coretesting.MakeEmptyFakeHome(c).Restore()
4950 store := newConfigStore("noconfig", dummyStoreInfo)
4951
4952 called := 0
4953@@ -155,7 +157,7 @@
4954 }
4955
4956 func (s *NewAPIClientSuite) TestWithConfigAndNoInfo(c *gc.C) {
4957- coretesting.MakeSampleJujuHome(c)
4958+ defer coretesting.MakeSampleHome(c).Restore()
4959
4960 store := newConfigStore(coretesting.SampleEnvName, &environInfo{
4961 bootstrapConfig: map[string]interface{}{
4962@@ -208,6 +210,7 @@
4963 }
4964
4965 func (s *NewAPIClientSuite) TestWithInfoError(c *gc.C) {
4966+ defer coretesting.MakeEmptyFakeHome(c).Restore()
4967 expectErr := fmt.Errorf("an error")
4968 store := newConfigStoreWithError(expectErr)
4969 client, err := juju.NewAPIFromStore("noconfig", store, panicAPIOpen)
4970@@ -216,6 +219,7 @@
4971 }
4972
4973 func (s *NewAPIClientSuite) TestWithInfoNoAddresses(c *gc.C) {
4974+ defer coretesting.MakeEmptyFakeHome(c).Restore()
4975 store := newConfigStore("noconfig", &environInfo{
4976 endpoint: configstore.APIEndpoint{
4977 Addresses: []string{},
4978@@ -228,6 +232,7 @@
4979 }
4980
4981 func (s *NewAPIClientSuite) TestWithInfoAPIOpenError(c *gc.C) {
4982+ defer coretesting.MakeEmptyFakeHome(c).Restore()
4983 store := newConfigStore("noconfig", &environInfo{
4984 endpoint: configstore.APIEndpoint{
4985 Addresses: []string{"foo.invalid"},
4986@@ -244,7 +249,7 @@
4987 }
4988
4989 func (s *NewAPIClientSuite) TestWithSlowInfoConnect(c *gc.C) {
4990- coretesting.MakeSampleJujuHome(c)
4991+ defer coretesting.MakeSampleHome(c).Restore()
4992 store := configstore.NewMem()
4993 bootstrapEnv(c, coretesting.SampleEnvName, store)
4994 setEndpointAddress(c, store, coretesting.SampleEnvName, "infoapi.invalid")
4995@@ -328,7 +333,7 @@
4996 }
4997
4998 func (s *NewAPIClientSuite) TestWithSlowConfigConnect(c *gc.C) {
4999- coretesting.MakeSampleJujuHome(c)
5000+ defer coretesting.MakeSampleHome(c).Restore()
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to status/vote changes: