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

feat: Add multi-namespace test for scaling #75

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 2 additions & 3 deletions tests/function_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,13 @@ func deleteFunction(t *testing.T, function *sdk.DeployFunctionSpec) {
}
}

func scaleFunction(t *testing.T, name string, count int) {
func scaleFunction(t *testing.T, name, namespace string, count int) {
t.Helper()

// the CLI sdk does not currently support manually scaling
gwURL := resourceURL(t, path.Join("system", "scale-function", name), "")
gwURL := resourceURL(t, path.Join("system", "scale-function", name), fmt.Sprintf("namespace=%s", namespace))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if you have checked latest version of CLI SDK, it already has API for scaling functions https://github.com/openfaas/faas-cli/blob/master/proxy/scale.go

Probably we can use that or make an separate MR to update that.

payload := makeReader(map[string]interface{}{"service": name, "replicas": count})

// TODO : enable auth
_, res := request(t, gwURL, http.MethodPost, config.Auth, payload)
if res.StatusCode != http.StatusAccepted && res.StatusCode != http.StatusOK {
t.Fatalf("scale got %d, wanted %d (or %d)", res.StatusCode, http.StatusAccepted, http.StatusOK)
Expand Down
13 changes: 13 additions & 0 deletions tests/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/url"
"os"
"path/filepath"
"strconv"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -108,6 +109,8 @@ type Config struct {
// AuthEnabled
AuthEnabled bool

IdlerEnabled bool

// SecretUpdate enables/disables the secret update test
SecretUpdate bool
// ScaleToZero enables/disables the scale from zero test
Expand Down Expand Up @@ -148,4 +151,14 @@ func FromEnv(config *Config) {
} else {
config.DefaultNamespace = "openfaas-fn"
}

idlerEnabled, ok := os.LookupEnv("idler_enabled")
if ok && idlerEnabled == "true" {
enableTest, err := strconv.ParseBool(idlerEnabled)
if err != nil {
LucasRoesler marked this conversation as resolved.
Show resolved Hide resolved
log.Fatalf("can parse idler_enabled env flag: %s", err.Error())
}

config.IdlerEnabled = enableTest
}
}
Loading