Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up code and add simple test cases for force h1 feature #2

Merged
merged 2 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions js/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ func (r *Runner) newVU(idLocal, idGlobal uint64, samplesOut chan<- stats.SampleC
MaxIdleConnsPerHost: int(r.Bundle.Options.BatchPerHost.Int64),
}

if ForceHTTP1() {
transport.TLSNextProto = map[string]func(string, *tls.Conn) http.RoundTripper{} //send over h1 protocol
if forceHTTP1() {
transport.TLSNextProto = make(map[string]func(string, *tls.Conn) http.RoundTripper) //send over h1 protocol
} else {
_ = http2.ConfigureTransport(transport) //send over h2 protocol
}
Expand Down Expand Up @@ -268,9 +268,9 @@ func (r *Runner) newVU(idLocal, idGlobal uint64, samplesOut chan<- stats.SampleC
return vu, nil
}

// Will check if force http1 env variable has been set in order to force requests to be sent over h1
// This feature is temporary until #936 is resolved
func ForceHTTP1() bool {
// forceHTTP1 checks if force http1 env variable has been set in order to force requests to be sent over h1
// TODO: This feature is temporary until #936 is resolved
func forceHTTP1() bool {
godebug := os.Getenv("GODEBUG")
if godebug == "" {
return false
Expand Down
14 changes: 14 additions & 0 deletions js/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2074,6 +2074,20 @@ func TestMinIterationDurationIsCancellable(t *testing.T) {
}
}

func TestCheckingForceHTTP1EnvironmentVariable(t *testing.T) {
os.Setenv("GODEBUG", "http2client=0,gctrace=1")
defer os.Unsetenv("GODEBUG")

assert.True(t, forceHTTP1())
}

func TestCheckingForceHTTP1EnvironmentVariableWhenNotSet(t *testing.T) {
os.Setenv("GODEBUG", "test=0")
defer os.Unsetenv("GODEBUG")

assert.False(t, forceHTTP1())
}

func TestExecutionInfo(t *testing.T) {
t.Parallel()

Expand Down