Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(9)

Unified Diff: environs/jujutest/livetests.go

Issue 10733044: Fail when run against Python juju environment
Patch Set: Fail when run against Python juju environment Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « [revision details] ('k') | environs/open.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: environs/jujutest/livetests.go
=== modified file 'environs/jujutest/livetests.go'
--- environs/jujutest/livetests.go 2013-06-26 13:19:16 +0000
+++ environs/jujutest/livetests.go 2013-06-29 02:49:49 +0000
@@ -23,6 +23,7 @@
coretesting "launchpad.net/juju-core/testing"
"launchpad.net/juju-core/utils"
"launchpad.net/juju-core/version"
+ "strings"
"time"
)
@@ -471,6 +472,67 @@
"juju-core storage writing verified: ok\n")
}
+func restoreBootstrapVerificationFile(c *C, storage environs.Storage) {
+ content := "juju-core storage writing verified: ok\n"
+ contentReader := strings.NewReader(content)
+ err := storage.Put("bootstrap-verify", contentReader,
+ int64(len(content)))
+ c.Assert(err, IsNil)
+}
+
+func (t *LiveTests) TestCheckEnvironmentOnConnect(c *C) {
+ // When new connection is established to a bootstraped environment,
+ // it is checked that we are running against a juju-core environment.
+ t.BootstrapOnce(c)
+
+ conn, err := juju.NewConn(t.Env)
+ c.Assert(err, IsNil)
+ conn.Close()
+}
+
+func (t *LiveTests) TestCheckEnvironmentOnConnectNoVerificationFile(c *C) {
+ // When new connection is established to a bootstraped environment,
+ // it is checked that we are running against a juju-core environment.
+ //
+ // Absence of a verification file means it is a juju-core environment
+ // with an older version, which is fine.
+ t.BootstrapOnce(c)
+ environ := t.Env
+ storage := environ.Storage()
+ err := storage.Remove("bootstrap-verify")
+ c.Assert(err, IsNil)
+ defer restoreBootstrapVerificationFile(c, storage)
+
+ conn, err := juju.NewConn(t.Env)
+ c.Assert(err, IsNil)
+ conn.Close()
+}
+
+func (t *LiveTests) TestCheckEnvironmentOnConnectBadVerificationFile(c *C) {
+ // When new connection is established to a bootstraped environment,
+ // it is checked that we are running against a juju-core environment.
+ //
+ // If the verification file has unexpected content, it is not
+ // a juju-core environment (likely to a Python juju environment).
+ t.BootstrapOnce(c)
+ environ := t.Env
+ storage := environ.Storage()
+
+ // Finally, replace the content with an arbitrary string.
+ badVerificationContent := "bootstrap storage verification"
+ reader := strings.NewReader(badVerificationContent)
+ err := storage.Put(
+ "bootstrap-verify",
+ reader,
+ int64(len(badVerificationContent)))
+ c.Assert(err, IsNil)
+ defer restoreBootstrapVerificationFile(c, storage)
+
+ // Running NewConn() should fail.
+ _, err = juju.NewConn(t.Env)
+ c.Assert(err, Equals, environs.InvalidEnvironmentError)
+}
+
type tooler interface {
Life() state.Life
AgentTools() (*state.Tools, error)
« no previous file with comments | « [revision details] ('k') | environs/open.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b