Merge lp:~axwalk/goamz/ec2test-empty-dnsname into lp:goamz

Proposed by Andrew Wilkins
Status: Merged
Merged at revision: 44
Proposed branch: lp:~axwalk/goamz/ec2test-empty-dnsname
Merge into: lp:goamz
Diff against target: 34 lines (+11/-2)
1 file modified
ec2/ec2test/server.go (+11/-2)
To merge this branch: bzr merge lp:~axwalk/goamz/ec2test-empty-dnsname
Reviewer Review Type Date Requested Status
goamz maintainers Pending
Review via email: mp+199466@code.launchpad.net

Commit message

ec2/ec2test: set empty DNSName initially

Initially set empty DNSName, causing the
client to re-request the DNSName. This
exercises the address refreshing logic
in juju's ec2 provider.

https://codereview.appspot.com/43650045/

Description of the change

ec2/ec2test: set empty DNSName initially

Initially set empty DNSName, causing the
client to re-request the DNSName. This
exercises the address refreshing logic
in juju's ec2 provider.

https://codereview.appspot.com/43650045/

To post a comment you must log in.
Revision history for this message
Andrew Wilkins (axwalk) wrote :

Reviewers: mp+199466_code.launchpad.net,

Message:
Please take a look.

Description:
ec2/ec2test: set empty DNSName initially

Initially set empty DNSName, causing the
client to re-request the DNSName. This
exercises the address refreshing logic
in juju's ec2 provider.

https://code.launchpad.net/~axwalk/goamz/ec2test-empty-dnsname/+merge/199466

(do not edit description out of merge proposal)

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

Affected files (+13, -2 lines):
   A [revision details]
   M ec2/ec2test/server.go

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>

Index: ec2/ec2test/server.go
=== modified file 'ec2/ec2test/server.go'
--- ec2/ec2test/server.go 2013-10-03 12:10:33 +0000
+++ ec2/ec2test/server.go 2013-12-18 14:22:35 +0000
@@ -66,7 +66,8 @@

  // instance holds a simulated ec2 instance
  type Instance struct {
- seq int
+ seq int
+ dnsNameSet bool
   // UserData holds the data that was passed to the RunInstances request
   // when the instance was started.
   UserData []byte
@@ -550,11 +551,19 @@

  func (inst *Instance) ec2instance() ec2.Instance {
   id := inst.id()
+ // The first time the instance is returned, its DNSName
+ // will be empty. The client should then refresh the instance.
+ var dnsName string
+ if inst.dnsNameSet {
+ dnsName = fmt.Sprintf("%s.testing.invalid", id)
+ } else {
+ inst.dnsNameSet = true
+ }
   return ec2.Instance{
    InstanceId: id,
    InstanceType: inst.instType,
    ImageId: inst.imageId,
- DNSName: fmt.Sprintf("%s.testing.invalid", id),
+ DNSName: dnsName,
    PrivateDNSName: fmt.Sprintf("%s.internal.invalid", id),
    IPAddress: fmt.Sprintf("8.0.0.%d", inst.seq%256),
    PrivateIPAddress: fmt.Sprintf("127.0.0.%d", inst.seq%256),

Revision history for this message
Roger Peppe (rogpeppe) wrote :

LGTM with one thought below.

https://codereview.appspot.com/43650045/diff/1/ec2/ec2test/server.go
File ec2/ec2test/server.go (right):

https://codereview.appspot.com/43650045/diff/1/ec2/ec2test/server.go#newcode567
ec2/ec2test/server.go:567: PrivateDNSName:
fmt.Sprintf("%s.internal.invalid", id),
I wonder if we should do it for these addresses too.

https://codereview.appspot.com/43650045/

Revision history for this message
Andrew Wilkins (axwalk) wrote :

On 2013/12/18 14:39:38, rog wrote:
> LGTM with one thought below.

> https://codereview.appspot.com/43650045/diff/1/ec2/ec2test/server.go
> File ec2/ec2test/server.go (right):

https://codereview.appspot.com/43650045/diff/1/ec2/ec2test/server.go#newcode567
> ec2/ec2test/server.go:567: PrivateDNSName:
fmt.Sprintf("%s.internal.invalid",
> id),
> I wonder if we should do it for these addresses too.

I can see it could be useful, but I think only if you could control
which ones are empty, or if they're initially all empty and each one is
updated on successive calls.
That's a much bigger change, though, that I'd like to leave to when we
need it.

https://codereview.appspot.com/43650045/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ec2/ec2test/server.go'
--- ec2/ec2test/server.go 2013-10-03 12:10:33 +0000
+++ ec2/ec2test/server.go 2013-12-18 14:30:43 +0000
@@ -66,7 +66,8 @@
6666
67// instance holds a simulated ec2 instance67// instance holds a simulated ec2 instance
68type Instance struct {68type Instance struct {
69 seq int69 seq int
70 dnsNameSet bool
70 // UserData holds the data that was passed to the RunInstances request71 // UserData holds the data that was passed to the RunInstances request
71 // when the instance was started.72 // when the instance was started.
72 UserData []byte73 UserData []byte
@@ -550,11 +551,19 @@
550551
551func (inst *Instance) ec2instance() ec2.Instance {552func (inst *Instance) ec2instance() ec2.Instance {
552 id := inst.id()553 id := inst.id()
554 // The first time the instance is returned, its DNSName
555 // will be empty. The client should then refresh the instance.
556 var dnsName string
557 if inst.dnsNameSet {
558 dnsName = fmt.Sprintf("%s.testing.invalid", id)
559 } else {
560 inst.dnsNameSet = true
561 }
553 return ec2.Instance{562 return ec2.Instance{
554 InstanceId: id,563 InstanceId: id,
555 InstanceType: inst.instType,564 InstanceType: inst.instType,
556 ImageId: inst.imageId,565 ImageId: inst.imageId,
557 DNSName: fmt.Sprintf("%s.testing.invalid", id),566 DNSName: dnsName,
558 PrivateDNSName: fmt.Sprintf("%s.internal.invalid", id),567 PrivateDNSName: fmt.Sprintf("%s.internal.invalid", id),
559 IPAddress: fmt.Sprintf("8.0.0.%d", inst.seq%256),568 IPAddress: fmt.Sprintf("8.0.0.%d", inst.seq%256),
560 PrivateIPAddress: fmt.Sprintf("127.0.0.%d", inst.seq%256),569 PrivateIPAddress: fmt.Sprintf("127.0.0.%d", inst.seq%256),

Subscribers

People subscribed via source and target branches