// 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),
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): server. go
A [revision details]
M ec2/ec2test/
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 server. go' server. go 2013-10-03 12:10:33 +0000 server. go 2013-12-18 14:22:35 +0000
=== modified file 'ec2/ec2test/
--- ec2/ec2test/
+++ ec2/ec2test/
@@ -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 { "%s.testing. invalid" , id) "%s.testing. invalid" , id), "%s.internal. invalid" , id), "8.0.0. %d", inst.seq%256), dress: fmt.Sprintf( "127.0. 0.%d", inst.seq%256),
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(
+ } else {
+ inst.dnsNameSet = true
+ }
return ec2.Instance{
InstanceId: id,
InstanceType: inst.instType,
ImageId: inst.imageId,
- DNSName: fmt.Sprintf(
+ DNSName: dnsName,
PrivateDNSName: fmt.Sprintf(
IPAddress: fmt.Sprintf(
PrivateIPAd