Merge lp:~ericsnowcurrently/fake-juju/allow-external-connections into lp:~landscape/fake-juju/trunk-old

Proposed by Eric Snow
Status: Merged
Approved by: Eric Snow
Approved revision: 51
Merged at revision: 50
Proposed branch: lp:~ericsnowcurrently/fake-juju/allow-external-connections
Merge into: lp:~landscape/fake-juju/trunk-old
Diff against target: 58 lines (+24/-4)
1 file modified
2.0.0/fake-juju.go (+24/-4)
To merge this branch: bzr merge lp:~ericsnowcurrently/fake-juju/allow-external-connections
Reviewer Review Type Date Requested Status
Chad Smith Approve
🤖 Landscape Builder test results Approve
Landscape Pending
Review via email: mp+310190@code.launchpad.net

Commit message

Allow access to external networks.

This is a temporary fix to allow downloading charms from the charm store.

Description of the change

Allow access to external networks.

This is a temporary fix to allow downloading charms from the charm store.

Testing instructions:

make test

To post a comment you must log in.
Revision history for this message
🤖 Landscape Builder (landscape-builder) :
review: Abstain (executing tests)
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :
review: Approve (test results)
Revision history for this message
Chad Smith (chad.smith) wrote :

+1 on this eric. nice1!

Tested before and after your patch

JUJU_VERSION=2.0.0 make
./2.0.0/2.0.0 bootstrap myctrl
juju-2.0 deploy ubuntu

# fails without your fix on access to external websites, succeeds with your patch

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '2.0.0/fake-juju.go'
2--- 2.0.0/fake-juju.go 2016-11-01 01:47:57 +0000
3+++ 2.0.0/fake-juju.go 2016-11-07 14:47:08 +0000
4@@ -562,6 +562,26 @@
5 func (s *FakeJujuSuite) SetUpTest(c *gc.C) {
6 s.JujuConnSuite.SetUpTest(c)
7
8+ // Juju needs internet access to reach the charm store. This is
9+ // necessary to download charmstore charms (e.g. when adding a
10+ // service. In the case of downloading charms, the controller
11+ // does not try to download if the charm is already in the database.
12+ // So internet access could go back to disabled if we were to add
13+ // the charm directly before using any API methods that try to
14+ // download it. Here are some ideas on how to do that:
15+ // * use the API's "upload charm" HTTP endpoint (POST on /charms);
16+ // this requires disabling the prohibition against uploading
17+ // charmstore charms (which we've done already in fake-juju);
18+ // this could be accomplished using txjuju, python-jujuclient,
19+ // or manually with httplib (all have auth complexity)
20+ // * add an "upload-charm" command to fake-juju that forces a
21+ // charmstore charm into the DB
22+ // * add the service with a "local" charm schema and then forcibly
23+ // change the charm's schema to "cs" in the DB
24+ // In the meantime, we allow fake-juju to have internet access.
25+ // XXX (lp:1639276): Remove this special case.
26+ utils.OutgoingAccessAllowed = true
27+
28 c.Assert(os.Getenv(envDataDir), gc.Not(gc.Equals), "")
29 s.filenames = newFakeJujuFilenames("", "", "")
30 // Note that LoggingSuite.SetUpTest (github.com/juju/testing/log.go),
31@@ -634,7 +654,7 @@
32 // Send the info back to the bootstrap command.
33 reportInfo(apiInfo.ModelTag.Id(), jujuHome)
34
35- log.Println("Started fake-juju at ", jujuHome)
36+ log.Println("Started fake-juju at", jujuHome)
37 }
38
39 func setUpLogging(c *gc.C, filenames fakejujuFilenames) (*os.File, *os.File) {
40@@ -686,15 +706,15 @@
41 c.Assert(err, gc.IsNil)
42 defer func() {
43 if err := fd.Close(); err != nil {
44- c.Logf("failed closing FIFO file: %s", err)
45+ log.Printf("failed closing FIFO file: %s\n", err)
46 }
47 // Mark the controller as destroyed by renaming some files.
48 if err := os.Rename(fifoPath, fifoPath+".destroyed"); err != nil {
49- c.Logf("failed renaming FIFO file: %s", err)
50+ log.Printf("failed renaming FIFO file: %s\n", err)
51 }
52 infofile := s.filenames.infoFile()
53 if err := os.Rename(infofile, infofile+".destroyed"); err != nil {
54- c.Logf("failed renaming info file: %s", err)
55+ log.Printf("failed renaming info file: %s\n", err)
56 }
57 }()
58 scanner := bufio.NewScanner(fd)

Subscribers

People subscribed via source and target branches

to all changes: