-
Notifications
You must be signed in to change notification settings - Fork 367
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
Improve unit test coverage #4142
Comments
@tnqn do you have the link with code coverage info per package? Edit: found it. For reference of others: https://app.codecov.io/gh/antrea-io/antrea/branch/main |
For SecondaryNetwork support, we switch to using the standard value type for the k8s.v1.cni.cncf.io/networks annotation: https://pkg.go.dev/github.com/k8snetworkplumbingwg/network-attachment-definition-client@v1.3.0/pkg/apis/k8s.cni.cncf.io/v1#NetworkSelectionElement By switching to the standard type: * we avoid user confusion * we ensure compatibility with other solutions such as Multus * we support "edge" cases that were not supported before: 1) using a NetworkAttachmentDefinition CR defined in a different Namespace than the Pod, 2) providing the NetworkAttachmentDefinition CR name as `[namespace/]name[@interface]` * we can use the standard ParseNetworkAnnotation function and avoid potential bugs or inconsistencies. This means that it is no longer possible to provide an "interface type" as part of the annotation value. However, this is not really a standard concept, as this information is typically provided in the NetworkAttachmentDefinition CR. For example, "bridge" mode for "macvlan". And in our case we use "sriov" mode (for the "antrea" network type). In addition to this change, we add a good amount of unit tests, in the context of #4142. Signed-off-by: Antonin Bas <abas@vmware.com>
For SecondaryNetwork support, we switch to using the standard value type for the k8s.v1.cni.cncf.io/networks annotation: https://pkg.go.dev/github.com/k8snetworkplumbingwg/network-attachment-definition-client@v1.3.0/pkg/apis/k8s.cni.cncf.io/v1#NetworkSelectionElement By switching to the standard type: * we avoid user confusion * we ensure compatibility with other solutions such as Multus * we support "edge" cases that were not supported before: 1) using a NetworkAttachmentDefinition CR defined in a different Namespace than the Pod, 2) providing the NetworkAttachmentDefinition CR name as `[namespace/]name[@interface]` * we can use the standard ParseNetworkAnnotation function and avoid potential bugs or inconsistencies. This means that it is no longer possible to provide an "interface type" as part of the annotation value. However, this is not really a standard concept, as this information is typically provided in the NetworkAttachmentDefinition CR. For example, "bridge" mode for "macvlan". And in our case we use "sriov" mode (for the "antrea" network type). In addition to this change, we add a good amount of unit tests, in the context of antrea-io#4142. Signed-off-by: Antonin Bas <abas@vmware.com>
For SecondaryNetwork support, we switch to using the standard value type for the k8s.v1.cni.cncf.io/networks annotation: https://pkg.go.dev/github.com/k8snetworkplumbingwg/network-attachment-definition-client@v1.3.0/pkg/apis/k8s.cni.cncf.io/v1#NetworkSelectionElement By switching to the standard type: * we avoid user confusion * we ensure compatibility with other solutions such as Multus * we support "edge" cases that were not supported before: 1) using a NetworkAttachmentDefinition CR defined in a different Namespace than the Pod, 2) providing the NetworkAttachmentDefinition CR name as `[namespace/]name[@interface]` * we can use the standard ParseNetworkAnnotation function and avoid potential bugs or inconsistencies. This means that it is no longer possible to provide an "interface type" as part of the annotation value. However, this is not really a standard concept, as this information is typically provided in the NetworkAttachmentDefinition CR. For example, "bridge" mode for "macvlan". And in our case we use "sriov" mode (for the "antrea" network type). In addition to this change, we add a good amount of unit tests, in the context of antrea-io#4142. Signed-off-by: Antonin Bas <abas@vmware.com>
For SecondaryNetwork support, we switch to using the standard value type for the k8s.v1.cni.cncf.io/networks annotation: https://pkg.go.dev/github.com/k8snetworkplumbingwg/network-attachment-definition-client@v1.3.0/pkg/apis/k8s.cni.cncf.io/v1#NetworkSelectionElement By switching to the standard type: * we avoid user confusion * we ensure compatibility with other solutions such as Multus * we support "edge" cases that were not supported before: 1) using a NetworkAttachmentDefinition CR defined in a different Namespace than the Pod, 2) providing the NetworkAttachmentDefinition CR name as `[namespace/]name[@interface]` * we can use the standard ParseNetworkAnnotation function and avoid potential bugs or inconsistencies. This means that it is no longer possible to provide an "interface type" as part of the annotation value. However, this is not really a standard concept, as this information is typically provided in the NetworkAttachmentDefinition CR. For example, "bridge" mode for "macvlan". And in our case we use "sriov" mode (for the "antrea" network type). In addition to this change, we add a good amount of unit tests, in the context of antrea-io#4142. Signed-off-by: Antonin Bas <abas@vmware.com>
For SecondaryNetwork support, we switch to using the standard value type for the k8s.v1.cni.cncf.io/networks annotation: https://pkg.go.dev/github.com/k8snetworkplumbingwg/network-attachment-definition-client@v1.3.0/pkg/apis/k8s.cni.cncf.io/v1#NetworkSelectionElement By switching to the standard type: * we avoid user confusion * we ensure compatibility with other solutions such as Multus * we support "edge" cases that were not supported before: 1) using a NetworkAttachmentDefinition CR defined in a different Namespace than the Pod, 2) providing the NetworkAttachmentDefinition CR name as `[namespace/]name[@interface]` * we can use the standard ParseNetworkAnnotation function and avoid potential bugs or inconsistencies. This means that it is no longer possible to provide an "interface type" as part of the annotation value. However, this is not really a standard concept, as this information is typically provided in the NetworkAttachmentDefinition CR. For example, "bridge" mode for "macvlan". And in our case we use "sriov" mode (for the "antrea" network type). In addition to this change, we add a good amount of unit tests, in the context of antrea-io#4142. Signed-off-by: Antonin Bas <abas@vmware.com>
For SecondaryNetwork support, we switch to using the standard value type for the k8s.v1.cni.cncf.io/networks annotation: https://pkg.go.dev/github.com/k8snetworkplumbingwg/network-attachment-definition-client@v1.3.0/pkg/apis/k8s.cni.cncf.io/v1#NetworkSelectionElement By switching to the standard type: * we avoid user confusion * we ensure compatibility with other solutions such as Multus * we support "edge" cases that were not supported before: 1) using a NetworkAttachmentDefinition CR defined in a different Namespace than the Pod, 2) providing the NetworkAttachmentDefinition CR name as `[namespace/]name[@interface]` * we can use the standard ParseNetworkAnnotation function and avoid potential bugs or inconsistencies. This means that it is no longer possible to provide an "interface type" as part of the annotation value. However, this is not really a standard concept, as this information is typically provided in the NetworkAttachmentDefinition CR. For example, "bridge" mode for "macvlan". And in our case we use "sriov" mode (for the "antrea" network type). In addition to this change, we add a good amount of unit tests, in the context of antrea-io#4142. Signed-off-by: Antonin Bas <abas@vmware.com>
Hi @tnqn I was trying to take the |
For SecondaryNetwork support, we switch to using the standard value type for the k8s.v1.cni.cncf.io/networks annotation: https://pkg.go.dev/github.com/k8snetworkplumbingwg/network-attachment-definition-client@v1.3.0/pkg/apis/k8s.cni.cncf.io/v1#NetworkSelectionElement By switching to the standard type: * we avoid user confusion * we ensure compatibility with other solutions such as Multus * we support "edge" cases that were not supported before: 1) using a NetworkAttachmentDefinition CR defined in a different Namespace than the Pod, 2) providing the NetworkAttachmentDefinition CR name as `[namespace/]name[@interface]` * we can use the standard ParseNetworkAnnotation function and avoid potential bugs or inconsistencies. This means that it is no longer possible to provide an "interface type" as part of the annotation value. However, this is not really a standard concept, as this information is typically provided in the NetworkAttachmentDefinition CR. For example, "bridge" mode for "macvlan". And in our case we use "sriov" mode (for the "antrea" network type). In addition to this change, we add a good amount of unit tests, in the context of antrea-io#4142. Signed-off-by: Antonin Bas <abas@vmware.com>
…4146) For SecondaryNetwork support, we switch to using the standard value type for the k8s.v1.cni.cncf.io/networks annotation: https://pkg.go.dev/github.com/k8snetworkplumbingwg/network-attachment-definition-client@v1.3.0/pkg/apis/k8s.cni.cncf.io/v1#NetworkSelectionElement By switching to the standard type: * we avoid user confusion * we ensure compatibility with other solutions such as Multus * we support "edge" cases that were not supported before: 1) using a NetworkAttachmentDefinition CR defined in a different Namespace than the Pod, 2) providing the NetworkAttachmentDefinition CR name as `[namespace/]name[@interface]` * we can use the standard ParseNetworkAnnotation function and avoid potential bugs or inconsistencies. This means that it is no longer possible to provide an "interface type" as part of the annotation value. However, this is not really a standard concept, as this information is typically provided in the NetworkAttachmentDefinition CR. For example, "bridge" mode for "macvlan". And in our case we use "sriov" networkType. In addition to this change, we add a good amount of unit tests, in the context of #4142. Signed-off-by: Antonin Bas <abas@vmware.com>
Fix one of the tests (`TestPodControllerAddPod/missing_Status.PodIPs`) and add a few more unit tests. For antrea-io#4142 Signed-off-by: Antonin Bas <abas@vmware.com>
Fix one of the unit test TestFlowExporter_sendFlowRecords, and adds a testcase to TestFlowExporter_initFlowExporter. For antrea-io#4142 Signed-off-by: heanlan <hanlan@vmware.com>
@luolanzone I made the list based on the unit test coverage report. It was 30% for this package as there is no unit test for cacert_controller.go. And I understand why its overall coverage looks fine: as long as the program runs end to end, many code in cacert_controller.go will run at least once regardless of whether the e2e test is intended to test it. But running the code once doesn't mean it's well tested, for example, if
I think the purpose of improving test coverage is not to make the code to be executed once by any kind of test, but to ensure the code is executed as expected in various situation. |
Fix one of the tests (`TestPodControllerAddPod/missing_Status.PodIPs`) and add a few more unit tests. For antrea-io#4142 Signed-off-by: Antonin Bas <abas@vmware.com>
Fix one of the tests (`TestPodControllerAddPod/missing_Status.PodIPs`) and add a few more unit tests. For #4142 Signed-off-by: Antonin Bas <abas@vmware.com>
Add more test cases for pkg/agent/flowexporter package and its subpackages: connections, exporter, priorityqueue. For antrea-io#4142 Signed-off-by: heanlan <hanlan@vmware.com>
Add more test cases for pkg/agent/flowexporter package and its subpackages: connections, exporter, priorityqueue. For antrea-io#4142 Signed-off-by: heanlan <hanlan@vmware.com>
Add more test cases for pkg/agent/flowexporter package and its subpackages: connections, exporter, priorityqueue. For antrea-io#4142 Signed-off-by: heanlan <hanlan@vmware.com>
Add more test cases for pkg/agent/flowexporter package and its subpackages: connections, exporter, priorityqueue. For antrea-io#4142 Signed-off-by: heanlan <hanlan@vmware.com>
…ntrea-io#4146) For SecondaryNetwork support, we switch to using the standard value type for the k8s.v1.cni.cncf.io/networks annotation: https://pkg.go.dev/github.com/k8snetworkplumbingwg/network-attachment-definition-client@v1.3.0/pkg/apis/k8s.cni.cncf.io/v1#NetworkSelectionElement By switching to the standard type: * we avoid user confusion * we ensure compatibility with other solutions such as Multus * we support "edge" cases that were not supported before: 1) using a NetworkAttachmentDefinition CR defined in a different Namespace than the Pod, 2) providing the NetworkAttachmentDefinition CR name as `[namespace/]name[@interface]` * we can use the standard ParseNetworkAnnotation function and avoid potential bugs or inconsistencies. This means that it is no longer possible to provide an "interface type" as part of the annotation value. However, this is not really a standard concept, as this information is typically provided in the NetworkAttachmentDefinition CR. For example, "bridge" mode for "macvlan". And in our case we use "sriov" networkType. In addition to this change, we add a good amount of unit tests, in the context of antrea-io#4142. Signed-off-by: Antonin Bas <abas@vmware.com>
Fix one of the tests (`TestPodControllerAddPod/missing_Status.PodIPs`) and add a few more unit tests. For antrea-io#4142 Signed-off-by: Antonin Bas <abas@vmware.com>
Add more test cases for pkg/agent/flowexporter package and its subpackages: connections, exporter, priorityqueue. For antrea-io#4142 Signed-off-by: heanlan <hanlan@vmware.com>
For antrea-io#4142 Signed-off-by: Yun-Tang Hsu <hsuy@vmware.com>
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment, or this will be closed in 90 days |
@luolanzone Can I work on improving the code coverage of the cmd package? |
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment, or this will be closed in 90 days |
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment, or this will be closed in 90 days |
Hi @VaibhavMalik4187 , sorry for a quite late response, you can work on coverage improvement if you are still interested in contribution. You can check this link https://app.codecov.io/gh/antrea-io/antrea/tree/codecov-ut-only to check overall Antrea coverage and take any package which coverage is low. Thanks a lot! |
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment, or this will be closed in 90 days |
Describe the bug
To ensure quality code and features being delivered, code coverage is one of the most important metrics we rely on. With good coverage for regression testing, there is also much less risk of breaking existing functionality when adding or changing features.
Currently Antrea’s entire coverage is 66.02%, with 49.12% e2e test coverage, 44.70% unit test coverage, 35.00% integration test coverage. Even though unit test is the easiest and the most cost efficient one, its coverage is only 44.70%, less than e2e test, which means there is a lot of room for improvement.
This issue tracks packages that should be well unit tested but were not. If you are familiar with or interested in understanding a package's implementation, feel free to pick up the package by adding your name after the package name to indicate you will work on it or comment the issue if you cannot edit it, write unit tests for it and submit your code.
Expected
Unit test coverage greater than 70%
Actual behavior
Unit test coverage less than 70%
The text was updated successfully, but these errors were encountered: