Envtest based integration tests for Fission (#2858)

* skeleton for envtest fission
* Refactor code and add CLI test
* hack
* Update server test
* remove skip-ci for lint tests
* Pass client go storagesvc
* Add clientGen interface across code
* Fix storagesvc test
* Fix cmd client
* add retry in server test
* Fix concurrenct access to pool deployment
* Remove old executor test
* get rid of ginkgo/gomega
* disable flaky test
* flaky test
* revert ci change
* handle err from ParseBool

---------

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
Co-authored-by: Pranoy Kundu <pranoy1998k@gmail.com>
This commit is contained in:
Sanket Sudake
2023-10-26 12:09:11 +05:30
committed by GitHub
co-authored by Pranoy Kundu
parent 15e16fcc82
commit 8a17d391c5
44 changed files with 534 additions and 524 deletions
+15 -15
View File
@@ -7,6 +7,8 @@ import (
"testing"
"github.com/gorilla/mux"
"github.com/hashicorp/go-retryablehttp"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
"github.com/fission/fission/pkg/utils/loggerfactory"
@@ -27,36 +29,34 @@ func TestStartServer(t *testing.T) {
go StartServer(ctx, logger, "test", "8999", m)
tests := []struct {
Name string
URL string
StatusCode int
Body string
}{
{
Name: "test handler",
URL: "http://localhost:8999",
StatusCode: http.StatusOK,
Body: "test handler",
},
{
Name: "not found",
URL: "http://localhost:8999/notfound",
StatusCode: http.StatusNotFound,
Body: "404 page not found\n",
},
}
client := retryablehttp.NewClient()
for _, test := range tests {
resp, err := http.Get(test.URL)
if err != nil {
t.Errorf("failed to make get request %v: %v", test.URL, err)
}
defer resp.Body.Close()
if resp.StatusCode != test.StatusCode {
t.Errorf("expected status code %v, got %v", test.StatusCode, resp.StatusCode)
}
body, err := io.ReadAll(resp.Body)
if err != nil {
t.Errorf("failed to read response body: %v", err)
}
if string(body) != test.Body {
t.Errorf("expected body \"%v\", got \"%v\"", test.Body, string(body))
}
t.Run(test.Name, func(t *testing.T) {
resp, err := client.Get(test.URL)
require.NoError(t, err, "failed to make get request %s", test.URL)
defer resp.Body.Close()
require.Equal(t, test.StatusCode, resp.StatusCode)
body, err := io.ReadAll(resp.Body)
require.NoError(t, err)
require.Equal(t, string(body), test.Body)
})
}
}