-
Notifications
You must be signed in to change notification settings - Fork 742
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add metrics, dashboard, and test suite
- Loading branch information
Showing
15 changed files
with
3,864 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,26 @@ | ||
package warm_pool | ||
|
||
import ( | ||
k8sUtils "github.com/aws/amazon-vpc-cni-k8s/test/framework/resources/k8s/utils" | ||
. "github.com/onsi/ginkgo/v2" | ||
) | ||
|
||
// Environment variables are not reset before and after each test so that way multiple tests can be run to | ||
// evaluate behavior. You can run this test which will unset all warm pool environment variables. Or, if you | ||
// want to test the behavior with some of those environment variables set, alter them in that file and run it once before | ||
// you run the desired tests. | ||
var _ = Describe("clear warm env", func() { | ||
Context("Clear out environment variables for warm pool for testing", func() { | ||
|
||
It("Unsetting env variables", func() { | ||
k8sUtils.UpdateEnvVarOnDaemonSetAndWaitUntilReady(f, "aws-node", "kube-system", | ||
"aws-node", map[string]string{}, | ||
map[string]struct{}{ | ||
"WARM_ENI_TARGET": {}, | ||
"WARM_IP_TARGET": {}, | ||
"MINIMUM_IP_TARGET": {}, | ||
"WARM_PREFIX_TARGET": {}, | ||
}) | ||
}) | ||
}) | ||
}) |
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,26 @@ | ||
package warm_pool | ||
|
||
import ( | ||
k8sUtils "github.com/aws/amazon-vpc-cni-k8s/test/framework/resources/k8s/utils" | ||
"github.com/aws/amazon-vpc-cni-k8s/test/framework/utils" | ||
. "github.com/onsi/ginkgo/v2" | ||
"strconv" | ||
) | ||
|
||
// Environment variables are not reset before and after each test so that way multiple tests can be run to | ||
// evaluate behavior. You can run this test which will unset all warm pool environment variables. Or, if you | ||
// want to test the behavior with some of those environment variables set, alter them in that file and run it once before | ||
// you run the desired tests. | ||
var _ = Describe("set warm env", func() { | ||
Context("Sets env variables", func() { | ||
|
||
It("Sets env variables", func() { | ||
k8sUtils.AddEnvVarToDaemonSetAndWaitTillUpdated(f, | ||
utils.AwsNodeName, utils.AwsNodeNamespace, utils.AwsNodeName, | ||
map[string]string{ | ||
"WARM_IP_TARGET": strconv.Itoa(0), | ||
"ENABLE_DYNAMIC_WARM_POOL": strconv.FormatBool(true), | ||
}) | ||
}) | ||
}) | ||
}) |
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,98 @@ | ||
package warm_pool | ||
|
||
import ( | ||
"fmt" | ||
"github.com/aws/amazon-vpc-cni-k8s/test/framework/resources/k8s/manifest" | ||
"github.com/aws/amazon-vpc-cni-k8s/test/framework/utils" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
v1 "k8s.io/api/core/v1" | ||
"time" | ||
) | ||
|
||
var primaryNode v1.Node | ||
|
||
// This test scales up the cluster to maxPods, then scales it back down to minPods. | ||
var _ = Describe("use case 1", func() { | ||
Context("Quick Scale Up and Down", func() { | ||
|
||
BeforeEach(func() { | ||
By("Getting Warm Pool Environment Variables Before Test") | ||
getWarmPoolEnvVars() | ||
}) | ||
|
||
It("Scales the cluster and checks warm pool before and after", func() { | ||
fmt.Fprintf(GinkgoWriter, "Deploying %v minimum pods\n", minPods) | ||
|
||
start := time.Now().Unix() | ||
|
||
fmt.Fprintf(GinkgoWriter, "Scaling cluster up to %v pods\n", minPods) | ||
deploymentSpec := manifest.NewBusyBoxDeploymentBuilder(f.Options.TestImageRegistry). | ||
Namespace("default"). | ||
Name("busybox"). | ||
NodeName(primaryNode.Name). | ||
Namespace(utils.DefaultTestNamespace). | ||
Replicas(minPods). | ||
Build() | ||
|
||
_, err := f.K8sResourceManagers. | ||
DeploymentManager(). | ||
CreateAndWaitTillDeploymentIsReady(deploymentSpec, utils.DefaultDeploymentReadyTimeout*5) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
if minPods != 0 { | ||
time.Sleep(sleep) | ||
} | ||
|
||
fmt.Fprintf(GinkgoWriter, "Scaling cluster up to %v pods\n", maxPods) | ||
quickScale(maxPods) | ||
|
||
Expect(maxPods).To(Equal(busyboxPodCnt())) | ||
|
||
fmt.Fprintf(GinkgoWriter, "Scaling cluster down to %v pods\n", minPods) | ||
quickScale(minPods) | ||
|
||
end := time.Now().Unix() | ||
|
||
fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Start Time: %v\n", start)) | ||
fmt.Fprintf(GinkgoWriter, fmt.Sprintf("End Time: %v\n", end)) | ||
|
||
By("Starting Curl Container") | ||
curlContainer := manifest.NewCurlContainer(). | ||
Command([]string{"sleep", "1000"}).Build() | ||
|
||
getCurlPod := manifest.NewDefaultPodBuilder(). | ||
Name("curl-pod"). | ||
Namespace(utils.DefaultTestNamespace). | ||
NodeName(primaryNode.Name). | ||
HostNetwork(true). | ||
Container(curlContainer). | ||
Build() | ||
|
||
testPod, err := f.K8sResourceManagers.PodManager(). | ||
CreateAndWaitTillPodCompleted(getCurlPod) | ||
|
||
logs, errLogs := f.K8sResourceManagers.PodManager(). | ||
PodLogs(testPod.Namespace, testPod.Name) | ||
Expect(errLogs).ToNot(HaveOccurred()) | ||
fmt.Fprintln(GinkgoWriter, logs) | ||
|
||
By("Fetching metrics via Curl Container") | ||
getMetrics(start, end) | ||
|
||
By("Deleting the deployment") | ||
err = f.K8sResourceManagers.DeploymentManager().DeleteAndWaitTillDeploymentIsDeleted(deploymentSpec) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
By("Deleting Curl Container") | ||
err = f.K8sResourceManagers.PodManager().DeleteAndWaitTillPodDeleted(getCurlPod) | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
|
||
AfterEach(func() { | ||
By("Getting Warm Pool Environment Variables After Test") | ||
getWarmPoolEnvVars() | ||
|
||
}) | ||
}) | ||
}) |
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,104 @@ | ||
package warm_pool | ||
|
||
import ( | ||
"fmt" | ||
"github.com/aws/amazon-vpc-cni-k8s/test/framework/resources/k8s/manifest" | ||
"github.com/aws/amazon-vpc-cni-k8s/test/framework/utils" | ||
"strconv" | ||
"time" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
// This test replicates sawtooth behavior by adding a fixed amount of pods and removing the same fixed amount of pods | ||
// over a preset number of iterations. | ||
var _ = Describe("use case 2", func() { | ||
Context("Sawtooth Fixed Add and Subtract", func() { | ||
|
||
BeforeEach(func() { | ||
By("Getting Warm Pool Environment Variables Before Test") | ||
getWarmPoolEnvVars() | ||
}) | ||
|
||
It("Scales the cluster and checks warm pool before and after", func() { | ||
replicas := minPods | ||
|
||
start := time.Now().Unix() | ||
|
||
fmt.Fprintf(GinkgoWriter, "Deploying %v minimum pods\n", minPods) | ||
deploymentSpec := manifest.NewBusyBoxDeploymentBuilder(f.Options.TestImageRegistry). | ||
Namespace("default"). | ||
Name("busybox"). | ||
NodeName(primaryNode.Name). | ||
Namespace(utils.DefaultTestNamespace). | ||
Replicas(replicas). | ||
Build() | ||
|
||
_, err := f.K8sResourceManagers. | ||
DeploymentManager(). | ||
CreateAndWaitTillDeploymentIsReady(deploymentSpec, utils.DefaultDeploymentReadyTimeout*5) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
if minPods != 0 { | ||
time.Sleep(sleep) | ||
} | ||
|
||
for i := 0; i < iterations; i++ { | ||
By("Loop " + strconv.Itoa(i)) | ||
replicas = checkInRange(replicas + iterPods) | ||
fmt.Fprintf(GinkgoWriter, "Scaling cluster up to %v pods\n", replicas) | ||
quickScale(replicas) | ||
Expect(replicas).To(Equal(busyboxPodCnt())) | ||
|
||
replicas = checkInRange(replicas - iterPods) | ||
fmt.Fprintf(GinkgoWriter, "Scaling cluster down to %v pods\n", replicas) | ||
quickScale(replicas) | ||
Expect(replicas).To(Equal(busyboxPodCnt())) | ||
} | ||
|
||
Expect(minPods).To(Equal(busyboxPodCnt())) | ||
|
||
end := time.Now().Unix() | ||
|
||
fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Start Time: %v\n", start)) | ||
fmt.Fprintf(GinkgoWriter, fmt.Sprintf("End Time: %v\n", end)) | ||
|
||
By("Starting Curl Container") | ||
curlContainer := manifest.NewCurlContainer(). | ||
Command([]string{"sleep", "3600"}).Build() | ||
|
||
getCurlPod := manifest.NewDefaultPodBuilder(). | ||
Name("curl-pod"). | ||
Namespace(utils.DefaultTestNamespace). | ||
NodeName(primaryNode.Name). | ||
HostNetwork(true). | ||
Container(curlContainer). | ||
Build() | ||
|
||
testPod, err := f.K8sResourceManagers.PodManager(). | ||
CreateAndWaitTillPodCompleted(getCurlPod) | ||
|
||
logs, errLogs := f.K8sResourceManagers.PodManager(). | ||
PodLogs(testPod.Namespace, testPod.Name) | ||
Expect(errLogs).ToNot(HaveOccurred()) | ||
fmt.Fprintln(GinkgoWriter, logs) | ||
|
||
By("Fetching metrics via Curl Container") | ||
getMetrics(start, end) | ||
|
||
By("Deleting the deployment") | ||
err = f.K8sResourceManagers.DeploymentManager().DeleteAndWaitTillDeploymentIsDeleted(deploymentSpec) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
By("Deleting Curl Container") | ||
err = f.K8sResourceManagers.PodManager().DeleteAndWaitTillPodDeleted(getCurlPod) | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
|
||
AfterEach(func() { | ||
By("Getting Warm Pool Environment Variables After Test") | ||
getWarmPoolEnvVars() | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.