@@ -142,8 +142,6 @@ func TestPushInvalidArgsLength(t *testing.T) {
142142
143143// TestConcurrentPushSameRepo tests many concurrent pushes, each to the same repo
144144func TestConcurrentPushSameRepo (t * testing.T ) {
145- t .Skip ("skipping because the global lock prevents testing the repository lock, for multiple concurrent pushes to the same repo" )
146- t .SkipNow ()
147145 const testingServerAddr = "127.0.0.1:2245"
148146 key , err := sshTestingHostKey ()
149147 assert .NoErr (t , err )
@@ -153,7 +151,7 @@ func TestConcurrentPushSameRepo(t *testing.T) {
153151 cfg .AddHostKey (key )
154152
155153 c := NewCircuit ()
156- pushLock := NewInMemoryRepositoryLock (0 )
154+ pushLock := NewInMemoryRepositoryLock (500 * time . Millisecond )
157155 runServer (cfg , c , pushLock , testingServerAddr , 2 * time .Second , t )
158156
159157 // Give server time to initialize.
@@ -165,45 +163,32 @@ func TestConcurrentPushSameRepo(t *testing.T) {
165163 client , err := ssh .Dial ("tcp" , testingServerAddr , clientConfig ())
166164 assert .NoErr (t , err )
167165
168- const numPushers = 10
166+ const numPushers = 4
169167 outCh := make (chan * sshSessionOutput , numPushers )
170168 for i := 0 ; i < numPushers ; i ++ {
171169 go func () {
172- sess , err := client .NewSession ()
173- assert .NoErr (t , err )
170+ sess , newSessErr := client .NewSession ()
171+ assert .NoErr (t , newSessErr )
174172 defer sess .Close ()
175- out , err := sess .Output ("git-upload-pack /demo.git" )
176- outCh <- & sshSessionOutput {outStr : string (out ), err : err }
173+ out , outErr := sess .Output ("git-upload-pack /demo.git" )
174+ outCh <- & sshSessionOutput {outStr : string (out ), err : outErr }
177175 }()
178176 }
179177
178+ // ensure at least 1 output was successful
180179 foundOK := false
181180 to := 1 * time .Second
182- multiPushLine , err := gitPktLineStr (multiplePush )
183- assert .NoErr (t , err )
184181 for i := 0 ; i < numPushers ; i ++ {
185182 select {
186183 case sessOut := <- outCh :
187- output := sessOut .outStr
188- err := sessOut .err
189- if output != multiPushLine && output != "OK" {
190- t .Fatalf ("expected 'OK' or '%s', but got '%s' (error '%s')" , multiPushLine , output , err )
191- }
192-
193- if sessOut .err != nil {
194- t .Fatalf ("found '%s' output with an error '%s'" , output , err )
195- }
196-
197- if ! foundOK && output == "OK" {
184+ if sessOut .outStr == "OK" {
198185 foundOK = true
199- } else if output == "OK" {
200- t .Fatalf ("found second 'OK' when shouldn't have" )
201186 }
202-
203187 case <- time .After (to ):
204188 t .Fatalf ("didn't receive an output within %s" , to )
205189 }
206190 }
191+ assert .True (t , foundOK , "no SSH requests were successful" )
207192}
208193
209194// TestConcurrentPushDifferentRepo tests many concurrent pushes, each to a different repo
0 commit comments