@@ -127,6 +127,110 @@ func TestScheduler_Submit_NewStack(t *testing.T) {
127127 x .AssertExpectations (t )
128128}
129129
130+ func TestScheduler_Submit_NoDNS (t * testing.T ) {
131+ db := newDB (t )
132+ defer db .Close ()
133+
134+ x := new (mockS3Client )
135+ c := new (mockCloudFormationClient )
136+ e := new (mockECSClient )
137+ s := & Scheduler {
138+ Template : template .Must (template .New ("t" ).Parse ("{}" )),
139+ Bucket : "bucket" ,
140+ Cluster : "cluster" ,
141+ cloudformation : c ,
142+ ecs : e ,
143+ s3 : x ,
144+ db : db ,
145+ after : fakeAfter ,
146+ }
147+
148+ x .On ("PutObject" , & s3.PutObjectInput {
149+ Bucket : aws .String ("bucket" ),
150+ Body : bytes .NewReader ([]byte ("{}" )),
151+ Key : aws .String ("/acme-inc/c9366591-ab68-4d49-a333-95ce5a23df68/bf21a9e8fbc5a3846fb05b4fa0859e0917b2202f" ),
152+ ContentType : aws .String ("application/json" ),
153+ }).Return (& s3.PutObjectOutput {}, nil )
154+
155+ c .On ("ValidateTemplate" , & cloudformation.ValidateTemplateInput {
156+ TemplateURL : aws .String ("https://bucket.s3.amazonaws.com/acme-inc/c9366591-ab68-4d49-a333-95ce5a23df68/bf21a9e8fbc5a3846fb05b4fa0859e0917b2202f" ),
157+ }).Return (& cloudformation.ValidateTemplateOutput {}, nil )
158+
159+ c .On ("DescribeStacks" , & cloudformation.DescribeStacksInput {
160+ StackName : aws .String ("acme-inc" ),
161+ }).Return (& cloudformation.DescribeStacksOutput {}, awserr .New ("400" , "Stack with id acme-inc does not exist" , errors .New ("" ))).Once ()
162+
163+ c .On ("CreateStack" , & cloudformation.CreateStackInput {
164+ StackName : aws .String ("acme-inc" ),
165+ TemplateURL : aws .String ("https://bucket.s3.amazonaws.com/acme-inc/c9366591-ab68-4d49-a333-95ce5a23df68/bf21a9e8fbc5a3846fb05b4fa0859e0917b2202f" ),
166+ Parameters : []* cloudformation.Parameter {
167+ {ParameterKey : aws .String ("DNS" ), ParameterValue : aws .String ("false" )},
168+ {ParameterKey : aws .String ("webScale" ), ParameterValue : aws .String ("1" )},
169+ },
170+ Tags : []* cloudformation.Tag {
171+ {Key : aws .String ("empire.app.id" ), Value : aws .String ("c9366591-ab68-4d49-a333-95ce5a23df68" )},
172+ {Key : aws .String ("empire.app.name" ), Value : aws .String ("acme-inc" )},
173+ },
174+ }).Return (& cloudformation.CreateStackOutput {}, nil )
175+
176+ c .On ("WaitUntilStackCreateComplete" , & cloudformation.DescribeStacksInput {
177+ StackName : aws .String ("acme-inc" ),
178+ }).Return (nil )
179+
180+ c .On ("DescribeStacks" , & cloudformation.DescribeStacksInput {
181+ StackName : aws .String ("acme-inc" ),
182+ }).Return (& cloudformation.DescribeStacksOutput {
183+ Stacks : []* cloudformation.Stack {
184+ {
185+ StackStatus : aws .String ("CREATE_COMPLETE" ),
186+ Outputs : []* cloudformation.Output {
187+ {
188+ OutputKey : aws .String ("Services" ),
189+ OutputValue : aws .String ("web=arn:aws:ecs:us-east-1:012345678910:service/acme-inc-web" ),
190+ },
191+ {
192+ OutputKey : aws .String ("Deployments" ),
193+ OutputValue : aws .String ("web=1" ),
194+ },
195+ },
196+ },
197+ },
198+ }, nil )
199+
200+ e .On ("DescribeServices" , & ecs.DescribeServicesInput {
201+ Cluster : aws .String ("cluster" ),
202+ Services : []* string {aws .String ("arn:aws:ecs:us-east-1:012345678910:service/acme-inc-web" )},
203+ }).Return (& ecs.DescribeServicesOutput {
204+ Services : []* ecs.Service {
205+ {
206+ ServiceArn : aws .String ("arn:aws:ecs:us-east-1:012345678910:service/acme-inc-web" ),
207+ Deployments : []* ecs.Deployment {& ecs.Deployment {Id : aws .String ("1" ), Status : aws .String ("PRIMARY" )}},
208+ },
209+ },
210+ }, nil )
211+
212+ err := s .SubmitWithOptions (context .Background (), & scheduler.App {
213+ ID : "c9366591-ab68-4d49-a333-95ce5a23df68" ,
214+ Name : "acme-inc" ,
215+ Labels : map [string ]string {
216+ "empire.app.id" : "c9366591-ab68-4d49-a333-95ce5a23df68" ,
217+ "empire.app.name" : "acme-inc" ,
218+ },
219+ Processes : []* scheduler.Process {
220+ {
221+ Type : "web" ,
222+ Instances : 1 ,
223+ },
224+ },
225+ }, scheduler .NullStatusStream , SubmitOptions {
226+ NoDNS : aws .Bool (true ),
227+ })
228+ assert .NoError (t , err )
229+
230+ c .AssertExpectations (t )
231+ x .AssertExpectations (t )
232+ }
233+
130234func TestScheduler_Submit_ExistingStack (t * testing.T ) {
131235 db := newDB (t )
132236 defer db .Close ()
0 commit comments