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

added fetcher test cases #2893

Merged
merged 3 commits into from Dec 21, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/fetcher/app/server.go
Expand Up @@ -39,7 +39,7 @@ var (
readyToServe uint32
)

func Run(ctx context.Context, clientGen crd.ClientGeneratorInterface, logger *zap.Logger, mgr manager.Interface) {
func Run(ctx context.Context, clientGen crd.ClientGeneratorInterface, logger *zap.Logger, mgr manager.Interface, port string, podInfoMountDir string) {
flag.Usage = fetcherUsage
specializeOnStart := flag.Bool("specialize-on-startup", false, "Flag to activate specialize process at pod startup")
specializePayload := flag.String("specialize-request", "", "JSON payload for specialize request")
Expand Down Expand Up @@ -74,7 +74,7 @@ func Run(ctx context.Context, clientGen crd.ClientGeneratorInterface, logger *za
ctx, span := tracer.Start(ctx, "fetcher/Run")
defer span.End()

f, err := fetcher.MakeFetcher(logger, clientGen, dir, *secretDir, *configDir)
f, err := fetcher.MakeFetcher(logger, clientGen, dir, *secretDir, *configDir, podInfoMountDir)
if err != nil {
logger.Fatal("error making fetcher", zap.Error(err))
}
Expand Down Expand Up @@ -121,7 +121,7 @@ func Run(ctx context.Context, clientGen crd.ClientGeneratorInterface, logger *za
logger.Info("fetcher ready to receive requests")

handler := otelUtils.GetHandlerWithOTEL(mux, "fission-fetcher", otelUtils.UrlsToIgnore("/healthz", "/readiness-healthz"))
httpserver.StartServer(ctx, logger, mgr, "fetcher", "8000", handler)
httpserver.StartServer(ctx, logger, mgr, "fetcher", port, handler)
}

func fetcherUsage() {
Expand Down
5 changes: 4 additions & 1 deletion cmd/fetcher/main.go
Expand Up @@ -20,12 +20,15 @@ import (
"sigs.k8s.io/controller-runtime/pkg/manager/signals"

"github.com/fission/fission/cmd/fetcher/app"
fv1 "github.com/fission/fission/pkg/apis/core/v1"
"github.com/fission/fission/pkg/crd"
"github.com/fission/fission/pkg/utils/loggerfactory"
"github.com/fission/fission/pkg/utils/manager"
"github.com/fission/fission/pkg/utils/profile"
)

const fetcherPort = "8000"

// Usage: fetcher <shared volume path>
func main() {

Expand All @@ -38,5 +41,5 @@ func main() {
ctx := signals.SetupSignalHandler()
profile.ProfileIfEnabled(ctx, logger, mgr)

app.Run(ctx, crd.NewClientGenerator(), logger, mgr)
app.Run(ctx, crd.NewClientGenerator(), logger, mgr, fetcherPort, fv1.PodInfoMount)
}
7 changes: 4 additions & 3 deletions pkg/fetcher/fetcher.go
Expand Up @@ -75,7 +75,8 @@ func makeVolumeDir(dirPath string) error {
return os.MkdirAll(dirPath, os.ModeDir|0750)
}

func MakeFetcher(logger *zap.Logger, clientGen crd.ClientGeneratorInterface, sharedVolumePath string, sharedSecretPath string, sharedConfigPath string) (*Fetcher, error) {
func MakeFetcher(logger *zap.Logger, clientGen crd.ClientGeneratorInterface, sharedVolumePath string, sharedSecretPath string,
sharedConfigPath string, podInfoMountDir string) (*Fetcher, error) {
fLogger := logger.Named("fetcher")
err := makeVolumeDir(sharedVolumePath)
if err != nil {
Expand All @@ -99,12 +100,12 @@ func MakeFetcher(logger *zap.Logger, clientGen crd.ClientGeneratorInterface, sha
return nil, errors.Wrap(err, "error making the kube client")
}

name, err := os.ReadFile(fv1.PodInfoMount + "/name")
name, err := os.ReadFile(podInfoMountDir + "/name")
if err != nil {
return nil, errors.Wrap(err, "error reading pod name from downward volume")
}

namespace, err := os.ReadFile(fv1.PodInfoMount + "/namespace")
namespace, err := os.ReadFile(podInfoMountDir + "/namespace")
if err != nil {
return nil, errors.Wrap(err, "error reading pod namespace from downward volume")
}
Expand Down
Binary file added test/e2e/fetcher/data/test-deploy-pkg.zip
Binary file not shown.
Binary file added test/e2e/fetcher/data/test-specialize-deploy-pkg.zip
Binary file not shown.
Binary file added test/e2e/fetcher/data/test-url-arch.zip
Binary file not shown.