Add tests for preupgradchecks and spec/archive CLI (#2874)
* Add tests for preupgradchecks * Add spec tests * Add package archive tests * Wait for cleanup * Fix test and coverage --------- Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
|
||||
"go.uber.org/zap"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/cmd/fission-cli/app"
|
||||
@@ -12,6 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func ExecCommand(f *framework.Framework, ctx context.Context, args ...string) (string, error) {
|
||||
f.Logger().Info("Executing command", zap.Strings("args", args))
|
||||
cmd := app.App(cmd.ClientOptions{
|
||||
RestConfig: f.RestConfig(),
|
||||
Namespace: metav1.NamespaceDefault,
|
||||
|
||||
@@ -20,11 +20,6 @@ import (
|
||||
"github.com/fission/fission/pkg/utils/loggerfactory"
|
||||
)
|
||||
|
||||
const (
|
||||
EXECUTOR_URL = "http://executor.fission"
|
||||
STORAGESVC_URL = "http://storagesvc.fission"
|
||||
)
|
||||
|
||||
type ServiceInfo struct {
|
||||
Port int
|
||||
}
|
||||
@@ -61,10 +56,14 @@ func NewFramework() *Framework {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_, filename, _, _ := runtime.Caller(0) //nolint
|
||||
root := filepath.Dir(filename)
|
||||
crdPath := filepath.Join(root, "..", "..", "..", "crds", "v1")
|
||||
|
||||
return &Framework{
|
||||
logger: loggerfactory.GetLogger(),
|
||||
env: &envtest.Environment{
|
||||
CRDDirectoryPaths: []string{filepath.Join("../../..", "crds", "v1")},
|
||||
CRDDirectoryPaths: []string{crdPath},
|
||||
ErrorIfCRDPathMissing: true,
|
||||
CRDInstallOptions: envtest.CRDInstallOptions{
|
||||
MaxTime: 60 * time.Second,
|
||||
@@ -111,9 +110,11 @@ func (f *Framework) ClientGen() *crd.ClientGenerator {
|
||||
}
|
||||
|
||||
func (f *Framework) Stop() error {
|
||||
f.logger.Info("Stopping test env")
|
||||
_ = f.logger.Sync()
|
||||
err := f.env.Stop()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error stopping test env: %v", err)
|
||||
return fmt.Errorf("error stopping test env: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -87,6 +87,11 @@ func StartServices(ctx context.Context, f *framework.Framework, mgr manager.Inte
|
||||
return fmt.Errorf("error starting storage service: %v", err)
|
||||
}
|
||||
f.AddServiceInfo("storagesvc", framework.ServiceInfo{Port: storageSvcPort})
|
||||
storagesvcURL, err := f.GetServiceURL("storagesvc")
|
||||
if err != nil {
|
||||
return fmt.Errorf("error getting storage service URL: %v", err)
|
||||
}
|
||||
os.Setenv("FISSION_STORAGESVC_URL", storagesvcURL)
|
||||
err = f.ToggleMetricAddr()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error toggling metric address: %v", err)
|
||||
@@ -122,8 +127,10 @@ func StartServices(ctx context.Context, f *framework.Framework, mgr manager.Inte
|
||||
return fmt.Errorf("error starting router: %v", err)
|
||||
}
|
||||
f.AddServiceInfo("router", framework.ServiceInfo{Port: routerPort})
|
||||
|
||||
routerURL := fmt.Sprintf("http://localhost:%d", routerPort)
|
||||
routerURL, err := f.GetServiceURL("router")
|
||||
if err != nil {
|
||||
return fmt.Errorf("error getting router URL: %v", err)
|
||||
}
|
||||
os.Setenv("FISSION_ROUTER_URL", routerURL)
|
||||
|
||||
err = timer.Start(ctx, f.ClientGen(), f.Logger(), mgr, routerURL)
|
||||
|
||||
Reference in New Issue
Block a user