@@ -86,14 +86,17 @@ func TestServerCreateAdminUser(t *testing.T) {
86
86
connectionURL , closeFunc , err := postgres .Open ()
87
87
require .NoError (t , err )
88
88
defer closeFunc ()
89
- ctx , cancelFunc := context .WithCancel (context .Background ())
90
- defer cancelFunc ()
91
89
92
90
sqlDB , err := sql .Open ("postgres" , connectionURL )
93
91
require .NoError (t , err )
94
92
defer sqlDB .Close ()
95
93
db := database .New (sqlDB )
96
94
95
+ // Sometimes generating SSH keys takes a really long time if there isn't
96
+ // enough entropy. We don't want the tests to fail in these cases.
97
+ ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitSuperLong )
98
+ defer cancel ()
99
+
97
100
pingCtx , pingCancel := context .WithTimeout (ctx , testutil .WaitShort )
98
101
defer pingCancel ()
99
102
_ , err = db .Ping (pingCtx )
@@ -135,14 +138,14 @@ func TestServerCreateAdminUser(t *testing.T) {
135
138
errC <- err
136
139
}()
137
140
138
- pty .ExpectMatch ( "Creating user..." )
139
- pty .ExpectMatch ( "Generating user SSH key..." )
140
- pty .ExpectMatch ( fmt .Sprintf ("Adding user to organization %q (%s) as admin..." , org1Name , org1ID .String ()))
141
- pty .ExpectMatch ( fmt .Sprintf ("Adding user to organization %q (%s) as admin..." , org2Name , org2ID .String ()))
142
- pty .ExpectMatch ( "User created successfully." )
143
- pty .ExpectMatch ( username )
144
- pty .ExpectMatch ( email )
145
- pty .ExpectMatch ( "****" )
141
+ pty .ExpectMatchContext ( ctx , "Creating user..." )
142
+ pty .ExpectMatchContext ( ctx , "Generating user SSH key..." )
143
+ pty .ExpectMatchContext ( ctx , fmt .Sprintf ("Adding user to organization %q (%s) as admin..." , org1Name , org1ID .String ()))
144
+ pty .ExpectMatchContext ( ctx , fmt .Sprintf ("Adding user to organization %q (%s) as admin..." , org2Name , org2ID .String ()))
145
+ pty .ExpectMatchContext ( ctx , "User created successfully." )
146
+ pty .ExpectMatchContext ( ctx , username )
147
+ pty .ExpectMatchContext ( ctx , email )
148
+ pty .ExpectMatchContext ( ctx , "****" )
146
149
147
150
require .NoError (t , <- errC )
148
151
@@ -158,11 +161,14 @@ func TestServerCreateAdminUser(t *testing.T) {
158
161
connectionURL , closeFunc , err := postgres .Open ()
159
162
require .NoError (t , err )
160
163
defer closeFunc ()
161
- ctx , cancelFunc := context .WithCancel (context .Background ())
162
- defer cancelFunc ()
164
+
165
+ // Sometimes generating SSH keys takes a really long time if there isn't
166
+ // enough entropy. We don't want the tests to fail in these cases.
167
+ ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitSuperLong )
168
+ defer cancel ()
163
169
164
170
t .Setenv ("CODER_POSTGRES_URL" , connectionURL )
165
- t .Setenv ("CODER_SSH_KEYGEN_ALGORITHM" , "ecdsa " )
171
+ t .Setenv ("CODER_SSH_KEYGEN_ALGORITHM" , "ed25519 " )
166
172
t .Setenv ("CODER_USERNAME" , username )
167
173
t .Setenv ("CODER_EMAIL" , email )
168
174
t .Setenv ("CODER_PASSWORD" , password )
@@ -178,10 +184,10 @@ func TestServerCreateAdminUser(t *testing.T) {
178
184
errC <- err
179
185
}()
180
186
181
- pty .ExpectMatch ( "User created successfully." )
182
- pty .ExpectMatch ( username )
183
- pty .ExpectMatch ( email )
184
- pty .ExpectMatch ( "****" )
187
+ pty .ExpectMatchContext ( ctx , "User created successfully." )
188
+ pty .ExpectMatchContext ( ctx , username )
189
+ pty .ExpectMatchContext ( ctx , email )
190
+ pty .ExpectMatchContext ( ctx , "****" )
185
191
186
192
require .NoError (t , <- errC )
187
193
@@ -198,13 +204,16 @@ func TestServerCreateAdminUser(t *testing.T) {
198
204
connectionURL , closeFunc , err := postgres .Open ()
199
205
require .NoError (t , err )
200
206
defer closeFunc ()
201
- ctx , cancelFunc := context .WithCancel (context .Background ())
202
- defer cancelFunc ()
207
+
208
+ // Sometimes generating SSH keys takes a really long time if there isn't
209
+ // enough entropy. We don't want the tests to fail in these cases.
210
+ ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitSuperLong )
211
+ defer cancel ()
203
212
204
213
root , _ := clitest .New (t ,
205
214
"server" , "create-admin-user" ,
206
215
"--postgres-url" , connectionURL ,
207
- "--ssh-keygen-algorithm" , "rsa4096 " ,
216
+ "--ssh-keygen-algorithm" , "ed25519 " ,
208
217
)
209
218
pty := ptytest .New (t )
210
219
root .SetIn (pty .Input ())
@@ -217,19 +226,19 @@ func TestServerCreateAdminUser(t *testing.T) {
217
226
errC <- err
218
227
}()
219
228
220
- pty .ExpectMatch ( "> Username" )
229
+ pty .ExpectMatchContext ( ctx , "> Username" )
221
230
pty .WriteLine (username )
222
- pty .ExpectMatch ( "> Email" )
231
+ pty .ExpectMatchContext ( ctx , "> Email" )
223
232
pty .WriteLine (email )
224
- pty .ExpectMatch ( "> Password" )
233
+ pty .ExpectMatchContext ( ctx , "> Password" )
225
234
pty .WriteLine (password )
226
- pty .ExpectMatch ( "> Confirm password" )
235
+ pty .ExpectMatchContext ( ctx , "> Confirm password" )
227
236
pty .WriteLine (password )
228
237
229
- pty .ExpectMatch ( "User created successfully." )
230
- pty .ExpectMatch ( username )
231
- pty .ExpectMatch ( email )
232
- pty .ExpectMatch ( "****" )
238
+ pty .ExpectMatchContext ( ctx , "User created successfully." )
239
+ pty .ExpectMatchContext ( ctx , username )
240
+ pty .ExpectMatchContext ( ctx , email )
241
+ pty .ExpectMatchContext ( ctx , "****" )
233
242
234
243
require .NoError (t , <- errC )
235
244
0 commit comments