@@ -62,15 +62,15 @@ func TestWaitForBackoffFallback(t *testing.T) {
6262 // Retry #0 and #1. At retry #2, we switch protocol, so the fallback loop has one more retry than this
6363 for i := 0 ; i < int (maxRetries - 1 ); i ++ {
6464 protocolFallback .BackoffTimer () // simulate retry
65- ok := selectNextProtocol (& log , protocolFallback , protocolSelector )
65+ ok := selectNextProtocol (& log , protocolFallback , protocolSelector , false )
6666 assert .True (t , ok )
6767 assert .Equal (t , initProtocol , protocolFallback .protocol )
6868 }
6969
7070 // Retry fallback protocol
7171 for i := 0 ; i < int (maxRetries ); i ++ {
7272 protocolFallback .BackoffTimer () // simulate retry
73- ok := selectNextProtocol (& log , protocolFallback , protocolSelector )
73+ ok := selectNextProtocol (& log , protocolFallback , protocolSelector , false )
7474 assert .True (t , ok )
7575 fallback , ok := protocolSelector .Fallback ()
7676 assert .True (t , ok )
@@ -82,12 +82,19 @@ func TestWaitForBackoffFallback(t *testing.T) {
8282
8383 // No protocol to fallback, return error
8484 protocolFallback .BackoffTimer () // simulate retry
85- ok := selectNextProtocol (& log , protocolFallback , protocolSelector )
85+ ok := selectNextProtocol (& log , protocolFallback , protocolSelector , false )
8686 assert .False (t , ok )
8787
8888 protocolFallback .reset ()
8989 protocolFallback .BackoffTimer () // simulate retry
90- ok = selectNextProtocol (& log , protocolFallback , protocolSelector )
90+ ok = selectNextProtocol (& log , protocolFallback , protocolSelector , false )
9191 assert .True (t , ok )
9292 assert .Equal (t , initProtocol , protocolFallback .protocol )
93+
94+ protocolFallback .reset ()
95+ protocolFallback .BackoffTimer () // simulate retry
96+ ok = selectNextProtocol (& log , protocolFallback , protocolSelector , true )
97+ // Check that we get a true after the first try itself when this flag is true. This allows us to immediately
98+ // switch protocols.
99+ assert .True (t , ok )
93100}
0 commit comments