|
| 1 | +package containerstatus_test |
| 2 | + |
| 3 | +import ( |
| 4 | + . "github.com/onsi/ginkgo/v2" |
| 5 | + . "github.com/onsi/gomega" |
| 6 | + |
| 7 | + "docker-provider/test/utils" |
| 8 | +) |
| 9 | + |
| 10 | +/* |
| 11 | + * For each of the pods that we deploy, ensure each container within that pod has status 'Running'. |
| 12 | + * The replicaset, and daemonset are always deployed. |
| 13 | + * The label and values are provided to get a list of pods only with that label. |
| 14 | + */ |
| 15 | +var _ = DescribeTable("The containers should be running", |
| 16 | + func(namespace string, controllerLabelName string, controllerLabelValue string) { |
| 17 | + err := utils.CheckIfAllContainersAreRunning(K8sClient, namespace, controllerLabelName, controllerLabelValue) |
| 18 | + Expect(err).NotTo(HaveOccurred()) |
| 19 | + }, |
| 20 | + Entry("when checking the ama-logs", "kube-system", "component", "ama-logs-agent"), |
| 21 | + Entry("when checking the ama-logs-rs replica pod(s)", "kube-system", "rsName", "ama-logs-rs"), |
| 22 | +) |
| 23 | + |
| 24 | +/* |
| 25 | + * For each of the DS pods that we deploy, ensure that all nodes have been used to schedule these pods. |
| 26 | + * The label and values are provided to get a list of pods only with that label. |
| 27 | + * The osLabel is provided to check on all DS pods based on the OS. |
| 28 | + */ |
| 29 | +var _ = DescribeTable("The pods should be scheduled in all nodes", |
| 30 | + func(namespace string, controllerLabelName string, controllerLabelValue string, osLabel string) { |
| 31 | + err := utils.CheckIfAllPodsScheduleOnNodes(K8sClient, namespace, controllerLabelName, controllerLabelValue, osLabel) |
| 32 | + Expect(err).NotTo(HaveOccurred()) |
| 33 | + }, |
| 34 | + Entry("when checking the ama-logs", "kube-system", "component", "ama-logs-agent", "linux"), |
| 35 | + Entry("when checking the ama-logs-win pod", "kube-system", "component", "ama-logs-agent-windows", "windows", Label(utils.WindowsLabel)), |
| 36 | +) |
| 37 | + |
| 38 | +/* |
| 39 | +* For each of the DS pods that we deploy, ensure that all specific nodes like ARM64, FIPS have been used to schedule these pods. |
| 40 | +* The label and values are provided to get a list of pods only with that label. |
| 41 | + */ |
| 42 | +var _ = DescribeTable("The pods should be scheduled in all Fips and ARM64 nodes", |
| 43 | + func(namespace string, controllerLabelName string, controllerLabelValue string, nodeLabelKey string, nodeLabelValue string) { |
| 44 | + err := utils.CheckIfAllPodsScheduleOnSpecificNodesLabels(K8sClient, namespace, controllerLabelName, controllerLabelValue, nodeLabelKey, nodeLabelValue) |
| 45 | + Expect(err).NotTo(HaveOccurred()) |
| 46 | + }, |
| 47 | + Entry("when checking the ama-logs", "kube-system", "component", "ama-logs-agent", "kubernetes.azure.com/fips_enabled", "true", Label(utils.FIPSLabel)), |
| 48 | + Entry("when checking the ama-logs-win pod", "kube-system", "component", "ama-logs-agent-windows", "kubernetes.azure.com/fips_enabled", "true", Label(utils.WindowsLabel), Label(utils.FIPSLabel)), |
| 49 | + Entry("when checking the ama-logs", "kube-system", "component", "ama-logs-agent", "kubernetes.io/arch", "arm64", Label(utils.ARM64Label)), |
| 50 | +) |
| 51 | + |
| 52 | +/* |
| 53 | +* For each of the pods that have the ama-logs container, check all expected processes are running. |
| 54 | +* The linux replicaset and daemonset should have the same processes running. |
| 55 | + */ |
| 56 | +var _ = DescribeTable("All processes are running", |
| 57 | + func(namespace, labelName, labelValue, containerName string, processes []string) { |
| 58 | + err := utils.CheckAllProcessesRunning(K8sClient, Cfg, labelName, labelValue, namespace, containerName, processes) |
| 59 | + Expect(err).NotTo(HaveOccurred()) |
| 60 | + }, |
| 61 | + Entry("when checking the ama-logs-rs replica pod", "kube-system", "rsName", "ama-logs-rs", "ama-logs", |
| 62 | + []string{ |
| 63 | + "fluent-bit", |
| 64 | + "fluentd", |
| 65 | + "mdsd -a -A -r", |
| 66 | + "inotifywait /etc/config/settings", |
| 67 | + "crond", |
| 68 | + }, |
| 69 | + ), |
| 70 | + Entry("when checking the ama-logs daemonset pods", "kube-system", "component", "ama-logs-agent", "ama-logs", |
| 71 | + []string{ |
| 72 | + "fluent-bit", |
| 73 | + "fluentd", |
| 74 | + "mdsd -a -A -r", |
| 75 | + "inotifywait /etc/config/settings", |
| 76 | + "crond", |
| 77 | + "telegraf", |
| 78 | + }, |
| 79 | + ), |
| 80 | +) |
| 81 | + |
| 82 | +/* |
| 83 | +* For windows daemonset pods that have the ama-logs-windows container, check all expected processes are running. |
| 84 | + */ |
| 85 | +var _ = DescribeTable("All processes are running", |
| 86 | + func(namespace, labelName, labelValue, containerName string, processes []string) { |
| 87 | + err := utils.CheckAllWindowsProcessesRunning(K8sClient, Cfg, labelName, labelValue, namespace, containerName, processes) |
| 88 | + Expect(err).NotTo(HaveOccurred()) |
| 89 | + }, |
| 90 | + Entry("when checking the ama-logs-windows daemonset pods", "kube-system", "component", "ama-logs-agent-windows", "ama-logs-windows", |
| 91 | + []string{ |
| 92 | + "fluent-bit", |
| 93 | + "MonAgentLauncher", |
| 94 | + "MonAgentHost", |
| 95 | + "MonAgentManager", |
| 96 | + "MonAgentCore", |
| 97 | + "telegraf", |
| 98 | + }, |
| 99 | + Label(utils.WindowsLabel), |
| 100 | + FlakeAttempts(3), |
| 101 | + ), |
| 102 | +) |
| 103 | + |
| 104 | +/* |
| 105 | +- For each of the pods that we deploy, ensure each container within that pod doesn't have errors in the logs. |
| 106 | +- The replicaset and daemonset are always deployed. |
| 107 | +- The label and values are provided to get a list of pods only with that label. |
| 108 | +*/ |
| 109 | +var _ = DescribeTable("The container logs should not contain errors", |
| 110 | + func(namespace string, controllerLabelName string, controllerLabelValue string) { |
| 111 | + err := utils.CheckContainerLogsForErrors(K8sClient, namespace, controllerLabelName, controllerLabelValue) |
| 112 | + Expect(err).NotTo(HaveOccurred()) |
| 113 | + }, |
| 114 | + Entry("when checking the ama-logs-rs pods", "kube-system", "rsName", "ama-logs-rs"), |
| 115 | + Entry("when checking the ama-logs daemonset pods", "kube-system", "component", "ama-logs-agent"), |
| 116 | + Entry("when checking the ama-logs-rs pods", "kube-system", "rsName", "ama-logs-rs", Label(utils.ARM64Label)), |
| 117 | + Entry("when checking the ama-logs daemonset pods", "kube-system", "component", "ama-logs-agent", Label(utils.ARM64Label)), |
| 118 | + Entry("when checking the ama-logs-windows daemonset pods", "kube-system", "component", "ama-logs-agent-windows", Label(utils.WindowsLabel)), |
| 119 | +) |
0 commit comments