-
Notifications
You must be signed in to change notification settings - Fork 729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Increase Analysers' test coverage #889
Comments
Hey @arbreezy I was recently testing the # command-line-arguments [command-line-arguments.test]
./statefulset_test.go:38:25: undefined: StatefulSetAnalyzer
./statefulset_test.go:65:25: undefined: StatefulSetAnalyzer
./statefulset_test.go:130:25: undefined: StatefulSetAnalyzer
./statefulset_test.go:176:25: undefined: StatefulSetAnalyzer
FAIL command-line-arguments [build failed]
FAIL Could you please specify a procedure to run tests correctly (I mean to run the existing tests, if any) |
Heu @Ishani217 you can use the Makefile to run the tests, |
Hello everyone 👋, I have a basic understanding of Linux, Docker, Helm, Kubernetes, Go, version control, and GitHub Actions. I participated in GSoC 2023 with CCExtractor, working on the open-source flood-mobile project. Now, I plan to join the k8sgpt project through the LFX Mentorship Program. Issue #889 caught my attention as it aligns with my skills and offers a great opportunity to gain hands-on experience with real-world open-source codebases. I've started exploring the provided resources and reviewing the issue. I'm excited about the chance to make meaningful contributions. Looking forward to learning from the k8sgpt community and contributing to this valuable project. |
This commit introduces comprehensive tests for the mutating webhook analyzer defined in the `pkg/analyzer` package. Addition of these tests increases the code coverage of the `mutating_webhook.go` file to almost 95%. Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
This commit introduces comprehensive tests for the mutating webhook analyzer defined in the `pkg/analyzer` package. Adding these tests increases the code coverage of the `mutating_webhook.go` file to almost 95%. Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
This commit introduces comprehensive tests for the validating webhook analyzer defined in the `pkg/analyzer` package. Adding these tests increases the code coverage of the `validating_webhook.go` file to almost 95%. Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
This commit introduces comprehensive tests for the validating webhook analyzer defined in the `pkg/analyzer` package. Adding these tests increases the code coverage of the `validating_webhook.go` file to almost 95%. Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
This commit introduces comprehensive tests for the ReplicaSet analyzer defined in the `pkg/analyzer` package. Adding these tests increases the code coverage of the `validating_webhook.go` file to >95%. Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
This commit introduces comprehensive tests for the ReplicaSet analyzer defined in the `pkg/analyzer` package. Adding these tests increases the code coverage of the `rs.go` file to >95%. Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
This commit introduces comprehensive tests for the validating webhook analyzer defined in the `pkg/analyzer` package. Adding these tests increases the code coverage of the `validating_webhook.go` file to almost 95%. Partially addresses: #889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
This commit introduces comprehensive tests for the mutating webhook analyzer defined in the `pkg/analyzer` package. Adding these tests increases the code coverage of the `mutating_webhook.go` file to almost 95%. Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
This commit introduces comprehensive tests for the ReplicaSet analyzer defined in the `pkg/analyzer` package. Adding these tests increases the code coverage of the `rs.go` file to >95%. Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
This commit introduces comprehensive tests for the ReplicaSet analyzer defined in the `pkg/analyzer` package. Adding these tests increases the code coverage of the `rs.go` file to >95%. Partially addresses: #889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
This commit introduces comprehensive tests for the mutating webhook analyzer defined in the `pkg/analyzer` package. Adding these tests increases the code coverage of the `mutating_webhook.go` file to almost 95%. Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
This commit introduces comprehensive tests fro the PersistentVolumeClaim analyzer defined in the `pkg/analyzer` package. Adding these tests increases the code coverage of the `pvc.go` file to >95%. Also made minor modifications in the ReplicaSet test to make sure that sure that all the expectations are met. Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
This commit introduces comprehensive tests for the `PersistentVolumeClaim` analyzer defined in the `pkg/analyzer` package. Adding these tests increases the code coverage of the `pvc.go` file to >95%. I also made minor modifications to the ReplicaSet test to ensure all expectations were met. Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
This commit introduces comprehensive tests for the `PersistentVolumeClaim` analyzer defined in the `pkg/analyzer` package. Adding these tests increases the code coverage of the `pvc.go` file to >95%. I also made minor modifications to the ReplicaSet test to ensure all expectations were met. Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
This commit introduces comprehensive tests for the `PersistentVolumeClaim` analyzer defined in the `pkg/analyzer` package. Adding these tests increases the code coverage of the `pvc.go` file to >95%. I also made minor modifications to the ReplicaSet test to ensure all expectations were met. Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
This commit introduces comprehensive tests for the `PodDisruptionBudget` analyzer defined in the `pkg/analyzer` package. Adding these tests increases the code coverage of the `pdb.go` file to >96%. Additionally, a potential crash in case of empty or nil PDB status conditions has been addressed. Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
This commit introduces comprehensive tests for the `PodDisruptionBudget` analyzer defined in the `pkg/analyzer` package. Adding these tests increases the code coverage of the `pdb.go` file to >96%. Additionally, a potential crash in case of empty or nil PDB status conditions has been addressed. Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
This commit introduces comprehensive tests for the mutating webhook analyzer defined in the `pkg/analyzer` package. Adding these tests increases the code coverage of the `mutating_webhook.go` file to almost 95%. Partially addresses: #889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
* Added new tests for the `Service` analyzer defined in the `pkg/analyzer` package. * The addition of these new tests has increased the code coverage of the service.go file to over 97%. * Additionally addressed some flaky tests related to the `ReplicaSet`and `PersisentVolumeClaim` analyzers. Partially addresses: #889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com> Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
* Added new tests for the `Node` analyzer defined in the `pkg/analyzer` package. * The addition of these new tests has increased the code coverage of the node.go file to over 96%. Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
- Added a network policy allowing traffic to all pods. Resulting in additional failures in the results. Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
With the addition of the latest changes, the missing test case when an event happened after the currently set latest event has been covered. Partially Addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
With the addition of the latest changes, the missing test case when an event happens after the currently set latest event has been covered. Partially Addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
- Added a network policy allowing traffic to all pods. Resulting in additional failures in the results. Partially addresses: #889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com> Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
- Fixed a small bug where pre-analysis was incorrectly appended to the results every time at the end of the for loop. This caused the result for a single cronjob failure to be appended multiple times in the final results. - Added missing test cases to ensure proper testing of the CronJob analyzer. The addition of these missing test cases has increased the code coverage of this analyzer to over 96%. Partially Addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
With the addition of the latest changes, the missing test case when an event happens after the currently set latest event has been covered. Partially Addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
* Added new tests for `LogAnalyzer` defined in the `pkg/analyzer` package. Increased the code coverage of the `log.go` file to >90% * Added `fake logs` string to the `errorPattern` to enable the discovery of error logs during the tests. TODO: Find a method to edit logs of the containers defined in the Kubernetes client config. Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
- Added missing test cases to ensure proper testing of the Ingress analyzer. The addition of these missing test cases has increased the code coverage of this analyzer to over 97%. Partially Addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
- Fixed a small bug where failures were being appended multiple times for CrashLoopBackOff and ContainerCreating container status reasons. - Added missing test cases to ensure proper testing of the Pod analyzer. The addition of these missing test cases has increased the code coverage of this analyzer to 92%. Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
* Added new tests for the `Node` analyzer defined in the `pkg/analyzer` package. * The addition of these new tests has increased the code coverage of the node.go file to over 96%. Partially addresses: #889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com> Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
- Added missing test cases to ensure proper testing of the Ingress analyzer. The addition of these missing test cases has increased the code coverage of this analyzer to over 97%. Partially Addresses: #889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com> Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
With the addition of the latest changes, the missing test case when an event happens after the currently set latest event has been covered. Partially Addresses: #889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com> Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
- Fixed a small bug where pre-analysis was incorrectly appended to the results every time at the end of the for loop. This caused the result for a single cronjob failure to be appended multiple times in the final results. - Added missing test cases to ensure proper testing of the CronJob analyzer. The addition of these missing test cases has increased the code coverage of this analyzer to over 96%. Partially Addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
* test: added missing tests for the CronJob analyzer - Fixed a small bug where pre-analysis was incorrectly appended to the results every time at the end of the for loop. This caused the result for a single cronjob failure to be appended multiple times in the final results. - Added missing test cases to ensure proper testing of the CronJob analyzer. The addition of these missing test cases has increased the code coverage of this analyzer to over 96%. Partially Addresses: #889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com> * test: removed failure strings matching from tests It is possible that the error or failure strings might change in the future, causing the tests to fail. This commit addresses that issue by removing the matching of failure text from various analyzer tests. Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com> --------- Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
* Added new tests for `LogAnalyzer` defined in the `pkg/analyzer` package. Increased the code coverage of the `log.go` file to >90% Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
- Fixed a small bug where failures were being appended multiple times for CrashLoopBackOff and ContainerCreating container status reasons. - Added missing test cases to ensure proper testing of the Pod analyzer. The addition of these missing test cases has increased the code coverage of this analyzer to 92%. Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
- Fixed a small bug where failures were being appended multiple times for CrashLoopBackOff and ContainerCreating container status reasons. - Added missing test cases to ensure proper testing of the Pod analyzer. The addition of these missing test cases has increased the code coverage of this analyzer to 98%. - Added checks for init containers in a pod. Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
* Added new tests for `LogAnalyzer` defined in the `pkg/analyzer` package. Increased the code coverage of the `log.go` file to >90% Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
- Fixed a small bug where failures were being appended multiple times for CrashLoopBackOff and ContainerCreating container status reasons. - Added missing test cases to ensure proper testing of the Pod analyzer. The addition of these missing test cases has increased the code coverage of this analyzer to 98%. - Added checks for init containers in a pod. Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
- Fixed a small bug where failures were being appended multiple times for CrashLoopBackOff and ContainerCreating container status reasons. - Added missing test cases to ensure proper testing of the Pod analyzer. The addition of these missing test cases has increased the code coverage of this analyzer to 98%. - Added checks for init containers in a pod. Partially addresses: #889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
* Added new tests for `LogAnalyzer` defined in the `pkg/analyzer` package. Increased the code coverage of the `log.go` file to >90% Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
* Added new tests for `LogAnalyzer` defined in the `pkg/analyzer` package. Increased the code coverage of the `log.go` file to >90% Partially addresses: k8sgpt-ai#889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
* Added new tests for `LogAnalyzer` defined in the `pkg/analyzer` package. Increased the code coverage of the `log.go` file to >90% Partially addresses: #889 Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
K8sGPT analysers are the first step of K8sGPT analysis whereby we scan K8s clusters and identify issues with K8s resources.
To gain more confidence every analyser should come with its own unit testing of various use cases we aim to identify.
There are a few analysers that have either limited or absent unit tests. The goal of this work is to increase code coverage of K8sGPT analysers by mocking a K8s environment. e.g Statefulset analyser
Here is a non-exhaustive list but a rather good start of enhancing or adding unit testing.
The text was updated successfully, but these errors were encountered: