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:
Sanket Sudake
2023-11-17 14:08:38 +05:30
committed by GitHub
parent e7d6381876
commit d23ed572f9
18 changed files with 186 additions and 77 deletions
+6 -6
View File
@@ -124,7 +124,7 @@ func (client *PreUpgradeTaskClient) LatestSchemaApplied(ctx context.Context) err
// VerifyFunctionSpecReferences verifies that a function references secrets, configmaps, pkgs in its own namespace and
// outputs a list of functions that don't adhere to this requirement.
func (client *PreUpgradeTaskClient) VerifyFunctionSpecReferences(ctx context.Context) {
func (client *PreUpgradeTaskClient) VerifyFunctionSpecReferences(ctx context.Context) error {
client.logger.Info("verifying function spec references for all functions in the cluster")
var err error
@@ -140,9 +140,11 @@ func (client *PreUpgradeTaskClient) VerifyFunctionSpecReferences(ctx context.Con
}
if err != nil {
client.logger.Fatal("error listing functions after max retries",
client.logger.Error("error listing functions after max retries",
zap.Error(err),
zap.Int("max_retries", maxRetries))
errs = errors.Join(errs, fmt.Errorf("error listing functions in namespace : %s", namespace))
continue
}
// check that all secrets, configmaps, packages are in the same namespace
@@ -169,10 +171,8 @@ func (client *PreUpgradeTaskClient) VerifyFunctionSpecReferences(ctx context.Con
}
if errs != nil {
client.logger.Fatal("installation failed",
zap.Error(errs),
zap.String("summary", "a function cannot reference secrets, configmaps and packages outside it's own namespace"))
return errs
}
client.logger.Info("function spec references verified")
return nil
}