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
=== modified file '2.0.0/fake-juju.go'
--- 2.0.0/fake-juju.go 2016-11-01 01:47:57 +0000
+++ 2.0.0/fake-juju.go 2016-11-07 14:47:08 +0000
@@ -562,6 +562,26 @@
562func (s *FakeJujuSuite) SetUpTest(c *gc.C) {562func (s *FakeJujuSuite) SetUpTest(c *gc.C) {
563 s.JujuConnSuite.SetUpTest(c)563 s.JujuConnSuite.SetUpTest(c)
564564
565 // Juju needs internet access to reach the charm store. This is
566 // necessary to download charmstore charms (e.g. when adding a
567 // service. In the case of downloading charms, the controller
568 // does not try to download if the charm is already in the database.
569 // So internet access could go back to disabled if we were to add
570 // the charm directly before using any API methods that try to
571 // download it. Here are some ideas on how to do that:
572 // * use the API's "upload charm" HTTP endpoint (POST on /charms);
573 // this requires disabling the prohibition against uploading
574 // charmstore charms (which we've done already in fake-juju);
575 // this could be accomplished using txjuju, python-jujuclient,
576 // or manually with httplib (all have auth complexity)
577 // * add an "upload-charm" command to fake-juju that forces a
578 // charmstore charm into the DB
579 // * add the service with a "local" charm schema and then forcibly
580 // change the charm's schema to "cs" in the DB
581 // In the meantime, we allow fake-juju to have internet access.
582 // XXX (lp:1639276): Remove this special case.
583 utils.OutgoingAccessAllowed = true
584
565 c.Assert(os.Getenv(envDataDir), gc.Not(gc.Equals), "")585 c.Assert(os.Getenv(envDataDir), gc.Not(gc.Equals), "")
566 s.filenames = newFakeJujuFilenames("", "", "")586 s.filenames = newFakeJujuFilenames("", "", "")
567 // Note that LoggingSuite.SetUpTest (github.com/juju/testing/log.go),587 // Note that LoggingSuite.SetUpTest (github.com/juju/testing/log.go),
@@ -634,7 +654,7 @@
634 // Send the info back to the bootstrap command.654 // Send the info back to the bootstrap command.
635 reportInfo(apiInfo.ModelTag.Id(), jujuHome)655 reportInfo(apiInfo.ModelTag.Id(), jujuHome)
636656
637 log.Println("Started fake-juju at ", jujuHome)657 log.Println("Started fake-juju at", jujuHome)
638}658}
639659
640func setUpLogging(c *gc.C, filenames fakejujuFilenames) (*os.File, *os.File) {660func setUpLogging(c *gc.C, filenames fakejujuFilenames) (*os.File, *os.File) {
@@ -686,15 +706,15 @@
686 c.Assert(err, gc.IsNil)706 c.Assert(err, gc.IsNil)
687 defer func() {707 defer func() {
688 if err := fd.Close(); err != nil {708 if err := fd.Close(); err != nil {
689 c.Logf("failed closing FIFO file: %s", err)709 log.Printf("failed closing FIFO file: %s\n", err)
690 }710 }
691 // Mark the controller as destroyed by renaming some files.711 // Mark the controller as destroyed by renaming some files.
692 if err := os.Rename(fifoPath, fifoPath+".destroyed"); err != nil {712 if err := os.Rename(fifoPath, fifoPath+".destroyed"); err != nil {
693 c.Logf("failed renaming FIFO file: %s", err)713 log.Printf("failed renaming FIFO file: %s\n", err)
694 }714 }
695 infofile := s.filenames.infoFile()715 infofile := s.filenames.infoFile()
696 if err := os.Rename(infofile, infofile+".destroyed"); err != nil {716 if err := os.Rename(infofile, infofile+".destroyed"); err != nil {
697 c.Logf("failed renaming info file: %s", err)717 log.Printf("failed renaming info file: %s\n", err)
698 }718 }
699 }()719 }()
700 scanner := bufio.NewScanner(fd)720 scanner := bufio.NewScanner(fd)

Subscribers

People subscribed via source and target branches

to all changes: