forked from eraser-dev/eraser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: ashnamehrotra <ashnamehrotra@gmail.com>
- Loading branch information
1 parent
4e62d5e
commit a155ab0
Showing
7 changed files
with
136 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ARG NODE_VERSION | ||
FROM kindest/node:v${NODE_VERSION} | ||
|
||
RUN echo '[grpc]' >> /etc/containerd/config.toml \ | ||
&& echo ' address = "/fake/socket/address.sock"' >> /etc/containerd/config.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//go:build e2e | ||
// +build e2e | ||
|
||
package e2e | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/eraser-dev/eraser/test/e2e/util" | ||
|
||
"sigs.k8s.io/e2e-framework/pkg/envconf" | ||
"sigs.k8s.io/e2e-framework/pkg/features" | ||
) | ||
|
||
func TestCustomRuntimeAddress(t *testing.T) { | ||
collectRuntimeFeat := features.New("Collector pods should run automatically, trigger the scanner, then the eraser pods. Helm test with custom runtime socket address."). | ||
Assess("Vulnerable and EOL images are successfully deleted from all nodes", func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context { | ||
ctxT, cancel := context.WithTimeout(ctx, util.Timeout) | ||
defer cancel() | ||
util.CheckImageRemoved(ctxT, t, util.GetClusterNodes(t), util.Alpine) | ||
|
||
return ctx | ||
}). | ||
Assess("Get logs", func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context { | ||
if err := util.GetPodLogs(t); err != nil { | ||
t.Error("error getting eraser pod logs", err) | ||
} | ||
|
||
return ctx | ||
}). | ||
Feature() | ||
|
||
util.Testenv.Test(t, collectRuntimeFeat) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
//go:build e2e | ||
// +build e2e | ||
|
||
package e2e | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
eraserv1alpha1 "github.com/eraser-dev/eraser/api/v1alpha1" | ||
"github.com/eraser-dev/eraser/test/e2e/util" | ||
utilruntime "k8s.io/apimachinery/pkg/util/runtime" | ||
"k8s.io/client-go/kubernetes/scheme" | ||
"sigs.k8s.io/e2e-framework/pkg/env" | ||
"sigs.k8s.io/e2e-framework/pkg/envconf" | ||
"sigs.k8s.io/e2e-framework/pkg/envfuncs" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
utilruntime.Must(eraserv1alpha1.AddToScheme(scheme.Scheme)) | ||
|
||
removerImage := util.ParsedImages.RemoverImage | ||
managerImage := util.ParsedImages.ManagerImage | ||
collectorImage := util.ParsedImages.CollectorImage | ||
scannerImage := util.ParsedImages.ScannerImage | ||
|
||
util.Testenv = env.NewWithConfig(envconf.New()) | ||
// Create KinD Cluster | ||
util.Testenv.Setup( | ||
envfuncs.CreateKindClusterWithConfig(util.KindClusterName, util.NodeVersion, util.KindConfigPath), | ||
envfuncs.CreateNamespace(util.TestNamespace), | ||
util.LoadImageToCluster(util.KindClusterName, util.ManagerImage, util.ManagerTarballPath), | ||
util.LoadImageToCluster(util.KindClusterName, util.RemoverImage, util.RemoverTarballPath), | ||
util.LoadImageToCluster(util.KindClusterName, util.CollectorImage, util.CollectorTarballPath), | ||
util.LoadImageToCluster(util.KindClusterName, util.VulnerableImage, ""), | ||
util.LoadImageToCluster(util.KindClusterName, util.NonVulnerableImage, ""), | ||
util.LoadImageToCluster(util.KindClusterName, util.EOLImage, ""), | ||
util.LoadImageToCluster(util.KindClusterName, util.ScannerImage, util.ScannerTarballPath), | ||
util.LoadImageToCluster(util.KindClusterName, util.RemoverImage, util.RemoverTarballPath), | ||
util.HelmDeployLatestEraserRelease(util.TestNamespace, | ||
"--set", util.ScannerEnable.Set("false"), | ||
"--set", util.CollectorEnable.Set("false"), | ||
"--set", util.RemoverImageRepo.Set(removerImage.Repo), | ||
"--set", util.RemoverImageTag.Set(removerImage.Tag), | ||
"--set", util.ManagerImageRepo.Set(managerImage.Repo), | ||
"--set", util.ManagerImageTag.Set(managerImage.Tag), | ||
), | ||
util.UpgradeEraserHelm(util.TestNamespace, | ||
"--set", util.ScannerEnable.Set("true"), | ||
"--set", util.ScannerImageRepo.Set(scannerImage.Repo), | ||
"--set", util.ScannerImageTag.Set(scannerImage.Tag), | ||
"--set", util.RemoverImageRepo.Set(removerImage.Repo), | ||
"--set", util.RemoverImageTag.Set(removerImage.Tag), | ||
"--set", util.CollectorEnable.Set("true"), | ||
"--set", util.CollectorImageRepo.Set(collectorImage.Repo), | ||
"--set", util.CollectorImageTag.Set(collectorImage.Tag), | ||
"--set", util.ManagerImageRepo.Set(managerImage.Repo), | ||
"--set", util.ManagerImageTag.Set(managerImage.Tag), | ||
"--set", util.CleanupOnSuccessDelay.Set("1m"), | ||
// set deleteFailedImages to FALSE to catch a broken scanner | ||
"--set-json", util.ScannerConfig.Set(util.ScannerConfigNoDeleteFailedJSON), | ||
// set custom runtime socket as runtime address | ||
"--set", util.CustomRuntimeAddress.Set("unix:///fake/socket/address.sock"), | ||
"--set", util.CustomRuntimeName.Set("containerd"), | ||
), | ||
).Finish( | ||
// envfuncs.DestroyKindCluster(util.KindClusterName), | ||
) | ||
os.Exit(util.Testenv.Run(m)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters