Skip to content

Commit

Permalink
benchmark: use plain text proxy.
Browse files Browse the repository at this point in the history
In order to not have misleading benchmark outcomes as detailed in #21 (comment) we will benchmark with a plaintext proxy from now on. This will make the process slower but the results will be more intuitive.
  • Loading branch information
Peter Van Bouwel authored and pvbouwel committed Jan 29, 2025
1 parent 87f10dc commit 1e19ed7
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
18 changes: 17 additions & 1 deletion cmd/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,26 @@ func getTestBucketObjectContentReadLength(t testing.TB, client s3.Client, object
return written, nil
}

//This is a testing fixture but where sts and s3 proxy are running in plaintext mode
//This is not really a common deployment setup but if we use TLS for our proxy but not for our testing backend
//Then we get misleading performance metrics as mentioned in https://github.com/VITObelgium/fakes3pp/pull/21#issuecomment-2620902233
//Using plain text will be a fairer comparison.
func testingFixturePlainTextProxy(t testing.TB) (tearDown func ()(), getToken func(subject string, d time.Duration, tags AWSSessionTags) string){
resetEnv := fixture_with_environment_values(t, map[string]string{
FAKES3PP_SECURE: "false",
})
tearDown1, getToken := testingFixture(t)
tearDown = func() {
tearDown1()
resetEnv()
}
return tearDown, getToken
}


func BenchmarkFakeS3Proxy(b *testing.B) {
initializeTestLogging()
tearDown, getSignedToken := testingFixture(b)
tearDown, getSignedToken := testingFixturePlainTextProxy(b)
defer tearDown()
token := getSignedToken("mySubject", time.Minute * 20, AWSSessionTags{PrincipalTags: map[string][]string{"org": {"a"}}})
//Given the policy Manager that has our test policies
Expand Down
37 changes: 37 additions & 0 deletions cmd/test-utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,41 @@ func assertHttpRequestOK(tb testing.TB, resp *http.Response) {
if resp.StatusCode != http.StatusOK {
tb.Errorf("Should have gotten succesful request")
}
}

func fixture_with_environment_values(tb testing.TB, new_env map[string]string) (tearDown func ()()){
old_env_variables := map[string]string{}

for new_env_key, new_env_value := range new_env {
old_value, old_value_exists := os.LookupEnv(new_env_key)
if old_value_exists {
old_env_variables[new_env_key] = old_value
}
err := os.Setenv(new_env_key, new_env_value)
if err != nil {
tb.Errorf("Issue environment fixture when setting %s=%s got %s", new_env_key, new_env_value, err)
tb.FailNow()
}
}

tearDown = func() () {
for new_env_key, new_env_value := range new_env {
old_value, old_value_exists := os.LookupEnv(new_env_key)
if old_value_exists {
err := os.Setenv(new_env_key, old_value)
if err != nil {
tb.Errorf("Issue environment fixture when setting %s=%s got %s", new_env_key, new_env_value, err)
tb.FailNow()
}
} else {
err := os.Unsetenv(new_env_key)
if err != nil {
tb.Errorf("Issue environment fixture when unsetting %s=%s got %s", new_env_key, new_env_value, err)
tb.FailNow()
}
}

}
}
return tearDown
}

0 comments on commit 1e19ed7

Please sign in to comment.