diff --git a/test/doc/egressclusterinfo.md b/test/doc/egressclusterinfo.md index 564ec43c7..848c2a50d 100644 --- a/test/doc/egressclusterinfo.md +++ b/test/doc/egressclusterinfo.md @@ -2,10 +2,10 @@ | Case ID | Title | Priority | Smoke | Status | Other | |---------|--------------------------------------------------------------------------------------------------------------------------------------|----------|-------|--------|-------| -| I00001 | Get egressClusterInfo `default`, the data in the status should be consistent with the data in the cluster | p2 | false | | | -| I00002 | Edit `spec.autoDetect.clusterIP` in egressClusterInfo `default`, `status.clusterIP` data update is correct | p2 | false | | | -| I00003 | Edit `spec.autoDetect.nodeIP` in egressClusterInfo `default`, `status.nodeIP` data update is correct | p2 | false | | | -| I00004 | Edit `spec.autoDetect.podCidrMode` in egressClusterInfo `default`, `status.podCIDR` data update is correct | p2 | false | | | -| I00005 | Edit `spec.extraCidr` in egressClusterInfo `default`, `status.extraCidr` data is updated correctly | p2 | false | | | -| I00006 | When `spec.autoDetect.clusterIP` is `calico`, `ippool` is added or deleted in the cluster, and `status.podCIDR` is updated correctly | p2 | false | | | -| I00007 | Remove egressClusterInfo `default`, will fail | p2 | false | | | \ No newline at end of file +| I00001 | Get egressClusterInfo `default`, the data in the status should be consistent with the data in the cluster | p2 | false | done | | +| I00002 | Edit `spec.autoDetect.clusterIP` in egressClusterInfo `default`, `status.clusterIP` data update is correct | p2 | false | done | | +| I00003 | Edit `spec.autoDetect.nodeIP` in egressClusterInfo `default`, `status.nodeIP` data update is correct | p2 | false | done | | +| I00004 | Edit `spec.autoDetect.podCidrMode` in egressClusterInfo `default`, `status.podCIDR` data update is correct | p2 | false | done | | +| I00005 | Edit `spec.extraCidr` in egressClusterInfo `default`, `status.extraCidr` data is updated correctly | p2 | false | done | | +| I00006 | When `spec.autoDetect.clusterIP` is `calico`, `ippool` is added or deleted in the cluster, and `status.podCIDR` is updated correctly | p2 | false | done | | +| I00007 | Remove egressClusterInfo `default`, will fail | p2 | false | done | | \ No newline at end of file diff --git a/test/doc/egressclusterinfo_zh.md b/test/doc/egressclusterinfo_zh.md index f315f7bda..d4bd218b1 100644 --- a/test/doc/egressclusterinfo_zh.md +++ b/test/doc/egressclusterinfo_zh.md @@ -17,10 +17,10 @@ | Case ID | Title | Priority | Smoke | Status | Other | |---------|----------------------------------------------------------------------------------------|----------|-------|--------|-------| -| I00001 | 获取 egressClusterInfo `default`,status 中数据应该与集群中数据一直 | p2 | false | | | -| I00002 | 编辑 egressClusterInfo `default` 中 `spec.autoDetect.clusterIP`,`status.clusterIP` 数据更新正确 | p2 | false | | | -| I00003 | 编辑 egressClusterInfo `default` 中 `spec.autoDetect.nodeIP`,`status.nodeIP` 数据更新正确 | p2 | false | | | -| I00004 | 编辑 egressClusterInfo `default` 中 `spec.autoDetect.podCidrMode`,`status.podCIDR` 数据更新正确 | p2 | false | | | -| I00005 | 编辑 egressClusterInfo `default` 中 `spec.extraCidr`,`status.extraCidr` 数据更新正确 | p2 | false | | | -| I00006 | 当 `spec.autoDetect.clusterIP` 为 `calico` 时,集群中添加或删除 `ippool`,`status.podCIDR` 更新正确 | p2 | false | | | -| I00007 | 删除 egressClusterInfo `default`,会失败 | p2 | false | | | \ No newline at end of file +| I00001 | 获取 egressClusterInfo `default`,status 中数据应该与集群中数据一直 | p2 | false | done | | +| I00002 | 编辑 egressClusterInfo `default` 中 `spec.autoDetect.clusterIP`,`status.clusterIP` 数据更新正确 | p2 | false | done | | +| I00003 | 编辑 egressClusterInfo `default` 中 `spec.autoDetect.nodeIP`,`status.nodeIP` 数据更新正确 | p2 | false | done | | +| I00004 | 编辑 egressClusterInfo `default` 中 `spec.autoDetect.podCidrMode`,`status.podCIDR` 数据更新正确 | p2 | false | done | | +| I00005 | 编辑 egressClusterInfo `default` 中 `spec.extraCidr`,`status.extraCidr` 数据更新正确 | p2 | false | done | | +| I00006 | 当 `spec.autoDetect.clusterIP` 为 `calico` 时,集群中添加或删除 `ippool`,`status.podCIDR` 更新正确 | p2 | false | done | | +| I00007 | 删除 egressClusterInfo `default`,会失败 | p2 | false | done | | \ No newline at end of file diff --git a/test/doc/egressendpointslice.md b/test/doc/egressendpointslice.md index 2ce43b8b3..6b6d2b795 100644 --- a/test/doc/egressendpointslice.md +++ b/test/doc/egressendpointslice.md @@ -2,4 +2,4 @@ | Case ID | Title | Priority | Smoke | Status | Other | |---------|--------------------------------------------------------------------------------------------------------------------------------------|----------|-------|--------|-------| -| S00001 | After repeatedly creating and deleting `pods` matched by a specific `policy`, check the egress IP addresses of all `pods` | p2 | false | | | \ No newline at end of file +| S00001 | After repeatedly creating and deleting `pods` matched by a specific `policy`, check the egress IP addresses of all `pods` | p2 | false | done | | \ No newline at end of file diff --git a/test/doc/egressendpointslice_zh.md b/test/doc/egressendpointslice_zh.md index 9a07cbcf7..c16c781a5 100644 --- a/test/doc/egressendpointslice_zh.md +++ b/test/doc/egressendpointslice_zh.md @@ -11,4 +11,4 @@ | Case ID | Title | Priority | Smoke | Status | Other | |---------|----------------------------------------------------------------------------------------|----------|-------|--------|-------| -| S00001 | 不断增删 `policy` 所匹配到的 `pods`,几轮增删后,判断所有 `pods` 的出口 `IP` | p2 | false | | | \ No newline at end of file +| S00001 | 不断增删 `policy` 所匹配到的 `pods`,几轮增删后,判断所有 `pods` 的出口 `IP` | p2 | false | done | | \ No newline at end of file diff --git a/test/doc/egressgateway.md b/test/doc/egressgateway.md index 315515036..6fd65ce66 100644 --- a/test/doc/egressgateway.md +++ b/test/doc/egressgateway.md @@ -8,17 +8,17 @@ | G00002 | Creation of EgressGateway fails when `NodeSelector` is empty | p2 | false | done | | | G00003 | Creation of EgressGateway fails when `DefaultEIP` is not in scope of `Ippools` | p2 | false | done | | | G00004 | Creation of EgressGateway fails when the number of `Ippools.IPv4` and `Ippools.IPv6` does not match | p2 | false | done | | -| G00005 | When `DefaultEIP` is empty, when creating EgressGateway, this field will randomly assign an IP from `Ippools` | p2 | false | | | +| G00005 | When `DefaultEIP` is empty, when creating EgressGateway, this field will randomly assign an IP from `Ippools` | p2 | false | done | | | G00006 | When `Ippools` is a single IP, the EgressGateway is successfully created and the `EgressGatewayStatus` check is passed | p2 | false | done | | | G00007 | When `Ippools` is an IP range in `a-b` format, the EgressGateway is successfully created and the `EgressGatewayStatus` check passes | p2 | false | done | | | G00008 | When `Ippools` is in IP cidr format, EgressGateway is successfully created and `EgressGatewayStatus` check is passed | p2 | false | done | | | G00009 | Updating EgressGateway fails when adding invalid IP addresses to `Ippools` | p2 | false | done | | -| G00010 | Updating EgressGateway fails when removing IP addresses in use from `Ippools` | p2 | false | done | | +| G00010 | Updating EgressGateway fails when removing IP addresses in use from `Ippools` | p2 | false | done | | | G00011 | Updating EgressGateway fails when adding different number of IPs to `Ippools.IPv4` and `Ippools.IPv6` | p2 | false | done | | | G00012 | Updating EgressGateway succeed when adding same number of IPs to `Ippools.IPv4` and `Ippools.IPv6` | p2 | false | done | | | G00013 | Add legal IP address to `Ippools`, update EgressGateway successfully | p2 | false | done | | -| G00014 | Edit the `NodeSelector` to match another `node`, `Status.NodeList` is updated to the newly matched node, using the `policy` of this `EgressGateway`, `Status.Node` is updated to the newly matched `node`, the `pod`'s egress ip is eip
Edit the `NodeSelector` to not match any `node`, `Status.NodeList` is empty, using the `policy` of this `EgressGateway`, `Status.Node` is empty, accessing external IP from the pod will error
Edit the `NodeSelector` to match one `node`, `Status.NodeList` is the matched `node`, using the `policy` of this `EgressGateway`, `Status.Node` is updated to the newly matched `node`, the `pod`'s egress ip is eip | p2 | false | | | +| G00014 | Edit the `NodeSelector` to match another `node`, `Status.NodeList` is updated to the newly matched node, using the `policy` of this `EgressGateway`, `Status.Node` is updated to the newly matched `node`, the `pod`'s egress ip is eip
Edit the `NodeSelector` to not match any `node`, `Status.NodeList` is empty, using the `policy` of this `EgressGateway`, `Status.Node` is empty, accessing external IP from the pod will error
Edit the `NodeSelector` to match one `node`, `Status.NodeList` is the matched `node`, using the `policy` of this `EgressGateway`, `Status.Node` is updated to the newly matched `node`, the `pod`'s egress ip is eip | p2 | false | done | | | G00017 | When creating an `EgressCluster` or `EgressClusterPolicy` without specifying `spec.egressGatewayName`, the tenant or cluster default gateway can be automatically configured and created successfully | p2 | false | done | | | G00018 | When `Ippools.IPv4` and `Ippools.IPv6` are empty, creating `EgressGateway` succeeds | p2 | false | done | | | G00019 | When `Ippools.IPv4` and `Ippools.IPv6` are empty, creating `EgressCluster` or `EgressClusterPolicy` without specifying `spec.egressIP.useNodeIP` will fail to create the policy. When `spec.egressIP.useNodeIP` is set to true, the policy will be created successfully | p2 | false | done | | -| G00020 | When a `policy` references a `gateway`, deleting the `gateway` will be in a "deleting" state until all the `policies` that reference the `gateway` are deleted. The `gateway` will be successfully deleted once all the referencing `policies` are removed | p2 | false | | | \ No newline at end of file +| G00020 | When a `policy` references a `gateway`, deleting the `gateway` will be in a "deleting" state until all the `policies` that reference the `gateway` are deleted. The `gateway` will be successfully deleted once all the referencing `policies` are removed | p2 | false | done | | \ No newline at end of file diff --git a/test/doc/egressgateway_zh.md b/test/doc/egressgateway_zh.md index 903929c72..b392783c7 100644 --- a/test/doc/egressgateway_zh.md +++ b/test/doc/egressgateway_zh.md @@ -33,21 +33,21 @@ | 用例编号 | 标题 | 优先级 | 冒烟 | 状态 | 其他 | |--------|--------------------------------------------------------------------------------------------------------|-----|-------|----|----| -| G00001 | 使用不合法的 `Ippools` 时,创建 EgressGateway 会失败 | p2 | false | | | -| G00002 | 当 `NodeSelector` 为空时,创建 EgressGateway 会失败 | p2 | false | | | -| G00003 | 当 `DefaultEIP` 不在 `Ippools` 范围内,创建 EgressGateway 会失败 | p2 | false | | | -| G00004 | 当 `Ippools.IPv4` 和 `Ippools.IPv6` 的数量不一致时,创建 EgressGateway 会失败 | p2 | false | | | -| G00005 | 当 `DefaultEIP` 为空,创建 EgressGateway 时,此字段会从 `Ippools` 中随机分配一个 IP | p2 | false | | | -| G00006 | 当 `Ippools` 为单个 IP 时,创建 EgressGateway 成功,`EgressGatewayStatus` 检查通过 | p2 | false | | | -| G00007 | 当 `Ippools` 是 `a-b` 格式的 IP 范围时,创建 EgressGateway 成功,`EgressGatewayStatus` 检查通过 | p2 | false | | | -| G00008 | 当 `Ippools` 是 IP cidr 格式时,创建 EgressGateway 成功,`EgressGatewayStatus` 检查通过 | p2 | false | | | -| G00009 | 向 `Ippools` 中添加 不合法的 IP 地址时,更新 EgressGateway 会失败 | p2 | false | | | -| G00010 | 从 `Ippools` 中删除 正在被使用的 IP 地址时,更新 EgressGateway 会失败 | p2 | false | | | -| G00011 | 向 `Ippools.IPv4` 和 `Ippools.IPv6` 添加不同数量的 IP 时,更新 EgressGateway 会失败 | p2 | false | | | -| G00012 | 向 `Ippools.IPv4` 和 `Ippools.IPv6` 添加相同数量的 IP 时,更新 EgressGateway 会成功 | p2 | false | | | -| G00013 | 向 `Ippools` 中添加合法的 IP 地址,更新 EgressGateway 成功 | p2 | false | | | -| G00014 | 编辑 `NodeSelector` 使其匹配另一个节点,`Status.NodeList` 更新为新匹配的节点,使用该 EgressGateway 的 policy `Status.Node` 更新为新匹配的节点, `pod` 的出口 `ip` 为 `eip`
编辑 `NodeSelector` 使其不匹配任何节点,`Status.NodeList` 为空,用该 EgressGateway 的 policy `Status.Node` 为空, `pod` 使用访问外部 IP 会报错
编辑 `NodeSelector` 使其匹配一个节点,`Status.NodeList` 为所匹配的节点,使用该 EgressGateway 的 policy `Status.Node` 更新为新匹配的节点,`pod` 的出口 `ip` 为 `eip` | p2 | false | | | -| G00017 | 创建 `EgressCluster` 或者 `EgressClusterPolicy` 时使用未指定 `spec.egressGatewayName` 时,可以使用自动设置租户或者集群默认网关,并创建成功 | p2 | false | | | -| G00018 | 当 `Ippools.IPv4` 和 `Ippools.IPv6` 为空时,创建 EgressGateway 成功 | p2 | false | | | -| G00019 | 当 `Ippools.IPv4` 和 `Ippools.IPv6` 为空时,创建 `EgressCluster` 或者 `EgressClusterPolicy`,未指定 `spec.egressIP.useNodeIP` 时,policy 创建失败,`spec.egressIP.useNodeIP` 为 true 时,policy 创建成功 | p2 | false | | | -| G00020 | 存在 `policy` 引用 `gateway` 时,删除 `gateway`,会处于 `deleting` 状态,直到所有引用 `gateway` 的 `policy` 都被删除,`gateway` 会被删除成功 | p2 | false | | | \ No newline at end of file +| G00001 | 使用不合法的 `Ippools` 时,创建 EgressGateway 会失败 | p2 | false | done | | +| G00002 | 当 `NodeSelector` 为空时,创建 EgressGateway 会失败 | p2 | false | done | | +| G00003 | 当 `DefaultEIP` 不在 `Ippools` 范围内,创建 EgressGateway 会失败 | p2 | false | done | | +| G00004 | 当 `Ippools.IPv4` 和 `Ippools.IPv6` 的数量不一致时,创建 EgressGateway 会失败 | p2 | false | done | | +| G00005 | 当 `DefaultEIP` 为空,创建 EgressGateway 时,此字段会从 `Ippools` 中随机分配一个 IP | p2 | false | done | | +| G00006 | 当 `Ippools` 为单个 IP 时,创建 EgressGateway 成功,`EgressGatewayStatus` 检查通过 | p2 | false | done | | +| G00007 | 当 `Ippools` 是 `a-b` 格式的 IP 范围时,创建 EgressGateway 成功,`EgressGatewayStatus` 检查通过 | p2 | false | done | | +| G00008 | 当 `Ippools` 是 IP cidr 格式时,创建 EgressGateway 成功,`EgressGatewayStatus` 检查通过 | p2 | false | done | | +| G00009 | 向 `Ippools` 中添加 不合法的 IP 地址时,更新 EgressGateway 会失败 | p2 | false | done | | +| G00010 | 从 `Ippools` 中删除 正在被使用的 IP 地址时,更新 EgressGateway 会失败 | p2 | false | done | | +| G00011 | 向 `Ippools.IPv4` 和 `Ippools.IPv6` 添加不同数量的 IP 时,更新 EgressGateway 会失败 | p2 | false | done | | +| G00012 | 向 `Ippools.IPv4` 和 `Ippools.IPv6` 添加相同数量的 IP 时,更新 EgressGateway 会成功 | p2 | false | done | | +| G00013 | 向 `Ippools` 中添加合法的 IP 地址,更新 EgressGateway 成功 | p2 | false | done | | +| G00014 | 编辑 `NodeSelector` 使其匹配另一个节点,`Status.NodeList` 更新为新匹配的节点,使用该 EgressGateway 的 policy `Status.Node` 更新为新匹配的节点, `pod` 的出口 `ip` 为 `eip`
编辑 `NodeSelector` 使其不匹配任何节点,`Status.NodeList` 为空,用该 EgressGateway 的 policy `Status.Node` 为空, `pod` 使用访问外部 IP 会报错
编辑 `NodeSelector` 使其匹配一个节点,`Status.NodeList` 为所匹配的节点,使用该 EgressGateway 的 policy `Status.Node` 更新为新匹配的节点,`pod` 的出口 `ip` 为 `eip` | p2 | false | done | | +| G00017 | 创建 `EgressCluster` 或者 `EgressClusterPolicy` 时使用未指定 `spec.egressGatewayName` 时,可以使用自动设置租户或者集群默认网关,并创建成功 | p2 | false | done | | +| G00018 | 当 `Ippools.IPv4` 和 `Ippools.IPv6` 为空时,创建 EgressGateway 成功 | p2 | false | done | | +| G00019 | 当 `Ippools.IPv4` 和 `Ippools.IPv6` 为空时,创建 `EgressCluster` 或者 `EgressClusterPolicy`,未指定 `spec.egressIP.useNodeIP` 时,policy 创建失败,`spec.egressIP.useNodeIP` 为 true 时,policy 创建成功 | p2 | false | done | | +| G00020 | 存在 `policy` 引用 `gateway` 时,删除 `gateway`,会处于 `deleting` 状态,直到所有引用 `gateway` 的 `policy` 都被删除,`gateway` 会被删除成功 | p2 | false | done | | \ No newline at end of file diff --git a/test/doc/egresspolicy.md b/test/doc/egresspolicy.md index 4ece6fe20..4876568a3 100644 --- a/test/doc/egresspolicy.md +++ b/test/doc/egresspolicy.md @@ -2,25 +2,26 @@ - all case about check the `eip` will including tcp, udp and web socket -| Case ID | Title | Priority | Smoke | Status | Other | -|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|-------|--------|-------| -| P00001 | Creating an EgressPolicy fails when an illegal `EgressIP` is used | p2 | false | | | -| P00002 | When `EgressGatewayName` is empty, when creating a cluster-level `EgressPolicy`, the default `EgressGatewa` of the cluster will be used, and the status of `EgressPolicySpec.EgressGatewayName` and `EgressPolicyStatus` is correct | p2 | false | | | -| P00003 | When `EgressGatewayName` is empty, when creating a namespace-level `EgressPolicy`,
if there is an annotation related to `EgressGateway` in the annotation of the corresponding namespace, use the `EgressGatewa` marked, if not, use the default `EgressGatewa` of the cluster, check` EgressPolicySpec.EgressGatewayName` and `EgressPolicyStatus` status is correct | p2 | false | | | -| P00004 | Creating an EgressPolicy fails when the `EgressIP` is not in the `Ippools` range of the `egressGateway` selected by the `Policy` | p2 | false | | | -| P00005 | Creating an EgressPolicy fails when `AppliedTo` is empty | p2 | false | | | -| P00006 | Creating an EgressPolicy fails when both `AppliedTo.PodSubnet` and `AppliedTo.PodSelector` are set | p2 | false | | | -| P00007 | When only `AppliedTo.PodSubnet` is set, the egress IP of `Pod` matched with it should be `eip`, and the egress IP of `Pod` not matched should be non-`eip`, and `endpointSlice` is not will be created | p1 | true | done | | -| P00008 | When `EgressIP` is empty, both `EgressPolicyStatus.Eip` of `Policy` and the egress IP of the Pod is `defaultEIP` of `egressGateway`, `allocatorPolicy` of `policy` is `default`, `useNodeIP` is `false`, `EgressGatewayStatus` is updated as expected | p1 | true | done | | -| P00009 | When the IP of `EgressIP` is empty and `EgressIP.AllocatorPolicy` is in `rr` mode, `eip` will be obtained from the IP of `EgressGatewaySpec.Ippools`, and the status of `EgressPolicyStatus` and `EgressGatewayStatus` is correct | p2 | false | | | -| P00010 | When the IP of `EgressIP` is not empty and `EgressIP.AllocatorPolicy` is in `rr` mode, `EgressIP` will take effect, check `EgressPolicyStatus` and `EgressGatewayStatus` are correct | p2 | false | | | -| P00011 | When the `DestSubnet` of `Policy` is empty and the destination IP of the access is not within the range of the IP list in `egressClusterInfo.Status`,
Pod’s egress IP is `eip` | p1 | true | done | | -| P00012 | When the `DestSubnet` of `Policy` is empty and the destination IP of the access is within the IP list range in `egressClusterInfo.Status`,
Pod’s egress IP is not `eip` | p1 | true | | | -| P00013 | Set `DestSubnet` and `PodSelector`, when accessing the external IP that matches `DestSubnet`, the Pod’s egress IP is `eip`,
When accessing the external IP that does not match `DestSubnet`, the Pod’s egress IP is not `eip` | p1 | true | done | | -| P00014 | Edit `PodSelector` that originally matched `DaemonSet-A` to change it to match `DaemonSet-B`,
`EgressEndpoint` will be updated from `DaemonSet-A` to `DaemonSet-B`,
And the export IP of all Pods in `DaemonSet-A` is changed from `eip` to non-`eip`, and the export IP of all Pods in `DaemonSet-B` is changed from non-`eip` to `eip` | p1 | true | done | | -| P00015 | When `EgressIP.UseNodeIP` is `false` and `EgressIP` IP is empty, create `EgressPolicy`,
`EgressPolicyStatus.Eip` and `EgressGatewayStatus.Eips` IP should be empty, and the pod’s egress IP is the IP of the node matched by egressGateway `nodeSelector` | p1 | true | | | -| P00016 | Creating an `EgressPolicy` fails when `EgressIP.UseNodeIP` is `false` and the IP of `EgressIP` is not empty | p2 | false | | | -| P00017 | Failed to edite the IP of `EgressIP` of Policy | p2 | false | | | -| P00018 | Failed to edite the IP of `EgressGatewayName` of Policy | p2 | false | | | -| P00019 | `EgressGatewayStatus` and `EgressEndpoint` will update as expected after delete the policy, and the Pod's egress IP will change from `eip` to non-`eip` | p1 | true | done | | -| P00020 | `namespace-level` policy only takes effect in the namespace it specifies | p2 | false | | | +| Test Case ID | Title | Priority | Smoke | Status | Others | +|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|-------|--------|--------| +| P00001 | Creating EgressPolicy fails when using an invalid `EgressIP`. | p2 | false | done | | +| P00002 | When `EgressGatewayName` is empty, creating cluster-level `EgressPolicy` should use the cluster's default `EgressGateway`, and check if `EgressPolicySpec.EgressGatewayName` and `EgressPolicyStatus` are updated correctly. | p2 | false | done | | +| P00003 | When `EgressGatewayName` is empty, creating tenant-level `EgressPolicy` should use the annotated `EgressGateway` if specified in the corresponding tenant's annotations; otherwise, use the cluster's default `EgressGateway`, and check if `EgressPolicySpec.EgressGatewayName` and `EgressPolicyStatus` are updated correctly. | p2 | false | done | | +| P00004 | Creating EgressPolicy fails when `EgressIP` is not within the `Ippools` range of the selected `egressGateway`. | p2 | false | done | | +| P00005 | Creating EgressPolicy fails when `AppliedTo` is empty. | p2 | false | done | | +| P00006 | Creating `Policy` fails when both `AppliedTo.PodSubnet` and `AppliedTo.PodSelector` are set simultaneously. | p2 | false | done | | +| P00007 | When only `AppliedTo.PodSubnet` is set, the exit IP of Pods matching the subnet should be `eip`, and Pods without a match should have non-`eip` exit IP; `endpointSlice` should not be created. | p1 | true | done | | +| P00008 | When `EgressIP` is empty and `AppliedTo.PodSelector` is set, `EgressPolicyStatus.Eip` and Pod exit IP should be the `defaultEIP` of the `egressGateway`, with `allocatorPolicy` as `default` and `useNodeIP` as `false`. Update `EgressGatewayStatus` as expected. | p1 | true | done | | +| P00009 | When `EgressIP` is empty, and `EgressIP.AllocatorPolicy` is set to round-robin, `EgressPolicyStatus` and `EgressGatewayStatus` should be updated correctly using an IP from `EgressGatewaySpec.Ippools`. | p2 | false | done | | +| P00010 | When `EgressIP` is not empty, and `EgressIP.AllocatorPolicy` is set to round-robin, `EgressIP` should take effect. Check if `EgressPolicyStatus` and `EgressGatewayStatus` are updated correctly. | p2 | false | done | | +| P00011 | When `Policy.DestSubnet` is empty and accessing an external IP outside the range of IPs in `egressClusterInfo.Status`, Pod exit IP should be `eip`. | p1 | true | done | | +| P00012 | When `Policy.DestSubnet` is empty and accessing an external IP within the range of IPs in `egressClusterInfo.Status`, Pod exit IP should not be `eip`. | p1 | true | done | | +| P00013 | Set both `DestSubnet` and `PodSelector`. When accessing an external IP matching `DestSubnet`, Pod exit IP should be `eip`; when accessing an external IP not matching `DestSubnet`, Pod exit IP should not be `eip`. | p1 | true | done | | +| P00014 | Edit `PodSelector` originally matching `DaemonSet-A` to match `DaemonSet-B`. `EgressEndpoint` should be updated from `DaemonSet-A` to `DaemonSet-B`, and exit IP for all Pods in `DaemonSet-A` should change from `eip` to non-`eip`, and for `DaemonSet-B` from non-`eip` to `eip`. | p1 | true | done | | +| P00015 | When `EgressIP.UseNodeIP` is `true`, and `EgressIP` is empty, creating `EgressPolicy` should set `EgressPolicyStatus.Eip` and `EgressGatewayStatus.Eips` to empty; Pod exit IP should be the node IP matching `egressGateway` `nodeSelector`. | p1 | true | done | | +| P00016 | When `EgressIP.UseNodeIP` is `true`, and `EgressIP` is empty, modifying `nodeSelector` of `EgressGateway` to match another node should update Pod exit IP to the new node's IP. | p1 | true | done | | +| P00017 | Creating `EgressPolicy` fails when `EgressIP.UseNodeIP` is `true`, and `EgressIP` is not empty. | p2 | false | done | | +| P00018 | Editing `EgressIP` IP in `Policy` should result in an error. | p2 | false | done | | +| P00019 | Editing `EgressGatewayName` in `Policy` should result in an error. | p2 | false | done | | +| P00020 | When deleting `Policy`, `EgressGatewayStatus` and `EgressEndpoint` should be updated as expected, and Pod exit IP should change from `eip` to non-`eip`. | p1 | true | done | | +| P00021 | `Namespace-level` Policy should only take effect in the specified namespace. | p2 | false | done | | diff --git a/test/doc/egresspolicy_zh.md b/test/doc/egresspolicy_zh.md index d3c73a919..0b729aaf5 100644 --- a/test/doc/egresspolicy_zh.md +++ b/test/doc/egresspolicy_zh.md @@ -2,53 +2,55 @@ # E2E Cases for EgressPolicy - all case about check the `eip` will including tcp, udp and web socket -| Case ID | Title | Priority | Smoke | Status | Other | -|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|-------|--------|-------| -| P00001 | Creating an EgressPolicy fails when an illegal `EgressIP` is used | p2 | false | | | -| P00002 | When `EgressGatewayName` is empty, when creating a cluster-level `EgressPolicy`, the default `EgressGatewa` of the cluster will be used, and the status of `EgressPolicySpec.EgressGatewayName` and `EgressPolicyStatus` is correct | p2 | false | | | -| P00003 | When `EgressGatewayName` is empty, when creating a namespace-level `EgressPolicy`,
if there is an annotation related to `EgressGateway` in the annotation of the corresponding namespace, use the `EgressGatewa` marked, if not, use the default `EgressGatewa` of the cluster, check` EgressPolicySpec.EgressGatewayName` and `EgressPolicyStatus` status is correct | p2 | false | | | -| P00004 | Creating an EgressPolicy fails when the `EgressIP` is not in the `Ippools` range of the `egressGateway` selected by the `Policy` | p2 | false | | | -| P00005 | Creating an EgressPolicy fails when `AppliedTo` is empty | p2 | false | | | -| P00006 | Creating an EgressPolicy fails when both `AppliedTo.PodSubnet` and `AppliedTo.PodSelector` are set | p2 | false | | | -| P00007 | When only `AppliedTo.PodSubnet` is set, the egress IP of `Pod` matched with it should be `eip`, and the egress IP of `Pod` not matched should be non-`eip`, and `endpointSlice` is not will be created | p1 | true | | | -| P00008 | When `EgressIP` is empty, both `EgressPolicyStatus.Eip` of `Policy` and the egress IP of the Pod is `defaultEIP` of `egressGateway`, `EgressGatewayStatus` is updated as expected | p1 | true | | | -| P00009 | When the IP of `EgressIP` is empty and `EgressIP.AllocatorPolicy` is in `rr` mode, `eip` will be obtained from the IP of `EgressGatewaySpec.Ippools`, and the status of `EgressPolicyStatus` and `EgressGatewayStatus` is correct | p2 | false | | | -| P00010 | When the IP of `EgressIP` is not empty and `EgressIP.AllocatorPolicy` is in `rr` mode, `EgressIP` will take effect, check `EgressPolicyStatus` and `EgressGatewayStatus` are correct | p2 | false | | | -| P00011 | When the `DestSubnet` of `Policy` is empty and the destination IP of the access is not within the range of the IP list in `egressClusterInfo.Status`,
Pod’s egress IP is `eip` | p1 | true | | | -| P00012 | When the `DestSubnet` of `Policy` is empty and the destination IP of the access is within the IP list range in `egressClusterInfo.Status`,
Pod’s egress IP is not `eip` | p1 | true | | | -| P00013 | Set `DestSubnet` and `PodSelector`, when accessing the external IP that matches `DestSubnet`, the Pod’s egress IP is `eip`,
When accessing the external IP that does not match `DestSubnet`, the Pod’s egress IP is not `eip` | p1 | true | | | -| P00014 | Edit `PodSelector` that originally matched `DaemonSet-A` to change it to match `DaemonSet-B`,
`EgressEndpoint` will be updated from `DaemonSet-A` to `DaemonSet-B`,
And the export IP of all Pods in `DaemonSet-A` is changed from `eip` to non-`eip`, and the export IP of all Pods in `DaemonSet-B` is changed from non-`eip` to `eip` | p1 | true | | | -| P00015 | When `EgressIP.UseNodeIP` is `false` and `EgressIP` IP is empty, create `EgressPolicy`,
`EgressPolicyStatus.Eip` and `EgressGatewayStatus.Eips` IP should be empty, and the pod’s egress IP is the IP of the node matched by egressGateway `nodeSelector` | p1 | true | | | -| P00016 | Creating an `EgressPolicy` fails when `EgressIP.UseNodeIP` is `false` and the IP of `EgressIP` is not empty | p2 | false | | | -| P00017 | Failed to edite the IP of `EgressIP` of Policy | p2 | false | | | -| P00018 | Failed to edite the IP of `EgressGatewayName` of Policy | p2 | false | | | -| P00019 | `EgressGatewayStatus` and `EgressEndpoint` will update as expected after delete the policy, and the Pod's egress IP will change from `eip` to non-`eip` | p1 | true | | | -| P00020 | `namespace-level` policy only takes effect in the namespace it specifies | p2 | false | | | +| Test Case ID | Title | Priority | Smoke | Status | Others | +|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|-------|--------|--------| +| P00001 | Creating EgressPolicy fails when using an invalid `EgressIP`. | p2 | false | done | | +| P00002 | When `EgressGatewayName` is empty, creating cluster-level `EgressPolicy` should use the cluster's default `EgressGateway`, and check if `EgressPolicySpec.EgressGatewayName` and `EgressPolicyStatus` are updated correctly. | p2 | false | done | | +| P00003 | When `EgressGatewayName` is empty, creating tenant-level `EgressPolicy` should use the annotated `EgressGateway` if specified in the corresponding tenant's annotations; otherwise, use the cluster's default `EgressGateway`, and check if `EgressPolicySpec.EgressGatewayName` and `EgressPolicyStatus` are updated correctly. | p2 | false | done | | +| P00004 | Creating EgressPolicy fails when `EgressIP` is not within the `Ippools` range of the selected `egressGateway`. | p2 | false | done | | +| P00005 | Creating EgressPolicy fails when `AppliedTo` is empty. | p2 | false | done | | +| P00006 | Creating `Policy` fails when both `AppliedTo.PodSubnet` and `AppliedTo.PodSelector` are set simultaneously. | p2 | false | done | | +| P00007 | When only `AppliedTo.PodSubnet` is set, the exit IP of Pods matching the subnet should be `eip`, and Pods without a match should have non-`eip` exit IP; `endpointSlice` should not be created. | p1 | true | done | | +| P00008 | When `EgressIP` is empty and `AppliedTo.PodSelector` is set, `EgressPolicyStatus.Eip` and Pod exit IP should be the `defaultEIP` of the `egressGateway`, with `allocatorPolicy` as `default` and `useNodeIP` as `false`. Update `EgressGatewayStatus` as expected. | p1 | true | done | | +| P00009 | When `EgressIP` is empty, and `EgressIP.AllocatorPolicy` is set to round-robin, `EgressPolicyStatus` and `EgressGatewayStatus` should be updated correctly using an IP from `EgressGatewaySpec.Ippools`. | p2 | false | done | | +| P00010 | When `EgressIP` is not empty, and `EgressIP.AllocatorPolicy` is set to round-robin, `EgressIP` should take effect. Check if `EgressPolicyStatus` and `EgressGatewayStatus` are updated correctly. | p2 | false | | | +| P00011 | When `Policy.DestSubnet` is empty and accessing an external IP outside the range of IPs in `egressClusterInfo.Status`, Pod exit IP should be `eip`. | p1 | true | done | | +| P00012 | When `Policy.DestSubnet` is empty and accessing an external IP within the range of IPs in `egressClusterInfo.Status`, Pod exit IP should not be `eip`. | p1 | true | done | | +| P00013 | Set both `DestSubnet` and `PodSelector`. When accessing an external IP matching `DestSubnet`, Pod exit IP should be `eip`; when accessing an external IP not matching `DestSubnet`, Pod exit IP should not be `eip`. | p1 | true | done | | +| P00014 | Edit `PodSelector` originally matching `DaemonSet-A` to match `DaemonSet-B`. `EgressEndpoint` should be updated from `DaemonSet-A` to `DaemonSet-B`, and exit IP for all Pods in `DaemonSet-A` should change from `eip` to non-`eip`, and for `DaemonSet-B` from non-`eip` to `eip`. | p1 | true | done | | +| P00015 | When `EgressIP.UseNodeIP` is `true`, and `EgressIP` is empty, creating `EgressPolicy` should set `EgressPolicyStatus.Eip` and `EgressGatewayStatus.Eips` to empty; Pod exit IP should be the node IP matching `egressGateway` `nodeSelector`. | p1 | true | done | | +| P00016 | When `EgressIP.UseNodeIP` is `true`, and `EgressIP` is empty, modifying `nodeSelector` of `EgressGateway` to match another node should update Pod exit IP to the new node's IP. | p1 | true | done | | +| P00017 | Creating `EgressPolicy` fails when `EgressIP.UseNodeIP` is `true`, and `EgressIP` is not empty. | p2 | false | done | | +| P00018 | Editing `EgressIP` IP in `Policy` should result in an error. | p2 | false | done | | +| P00019 | Editing `EgressGatewayName` in `Policy` should result in an error. | p2 | false | done | | +| P00020 | When deleting `Policy`, `EgressGatewayStatus` and `EgressEndpoint` should be updated as expected, and Pod exit IP should change from `eip` to non-`eip`. | p1 | true | done | | +| P00021 | `Namespace-level` Policy should only take effect in the specified namespace. | p2 | false | done | | + --> # EgressPolicy E2E 用例 - 用例中,所有有关 `eip` 校验的内容,都包含了 tcp,udp 和 web socket -| 用例编号 | 标题 | 优先级 | 冒烟 | 状态 | 其他 | -|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----|-------|-----|-----| -| P00001 | 当使用不合法的 `EgressIP`,创建 EgressPolicy 失败 | p2 | false | | | -| P00002 | 当 `EgressGatewayName` 为空时,创建集群级 `EgressPolicy` 时,会使用集群默认的 `EgressGateway`,检查 `EgressPolicySpec.EgressGatewayName` 及 `EgressPolicyStatus` 状态正确 | p2 | false | | | -| P00003 | 当 `EgressGatewayName` 为空时,创建租户级 `EgressPolicy`时,如果对应租户注解上有相关 `EgressGateway` 的标注,则使用标注的 `EgressGatewa`,如果没有则使用集群默认的 `EgressGateway`,检查 `EgressPolicySpec.EgressGatewayName` 及 `EgressPolicyStatus` 状态正确 | p2 | false | | | -| P00004 | 当 `EgressIP` 没有在 `Policy` 所选择的 `egressGateway` 的 `Ippools` 范围内,创建 EgressPolicy 会失败 | p2 | false | | | -| P00005 | 当 `AppliedTo` 为空时,创建 EgressPolicy 会失败 | p2 | false | | | -| P00006 | 当同时设置 `AppliedTo.PodSubnet` 和 `AppliedTo.PodSelector` 时,创建 `Policy` 失败 | p2 | false | | | -| P00007 | 当只设置了 `AppliedTo.PodSubnet`,与之匹配到的 `Pod` 的出口 IP 应是 `eip`,没有匹配到的 `Pod` 的出口 IP,应为非 `eip`,并且 `endpointSlice` 不会被创建 | p1 | true | | | -| P00008 | 当 `EgressIP` 为空并且设置了 `AppliedTo.PodSelector` 时,`Policy` 的 `EgressPolicyStatus.Eip` 和 Pod 的出口 IP 为 `egressGateway` 的 `defaultEIP`,`policy` 的 `allocatorPolicy` 为 `default`、`useNodeIP` 为 `false`, `EgressGatewayStatus` 会如预期更新 | p1 | true | | | -| P00009 | 当 `EgressIP` 的 IP 为空,并且 `EgressIP.AllocatorPolicy` 为轮询模式时, `eip` 会从 `EgressGatewaySpec.Ippools` 的 IP 中获取,检查 `EgressPolicyStatus` 和 `EgressGatewayStatus` 状态正确 | p2 | false | | | -| P00010 | 当 `EgressIP` 的 IP 不为空,并且 `EgressIP.AllocatorPolicy` 为轮询模式时, `EgressIP` 会生效, 检查 `EgressPolicyStatus` 和 `EgressGatewayStatus` 状态正确 | p2 | false | | | -| P00011 | 当 `Policy` 的 `DestSubnet` 为空并且访问的目的 IP 不在 `egressClusterInfo.Status` 中的 IP 列表范围之内时,
Pod 的出口 IP 为 `eip` | p1 | true | | | -| P00012 | 当 `Policy` 的 `DestSubnet` 为空并且访问的目的 IP 在 `egressClusterInfo.Status` 中的 IP 列表范围之内时,
Pod 的出口 IP 不为 `eip` | p1 | true | | | -| P00013 | 设置 `DestSubnet` 和 `PodSelector`, 当访问与 `DestSubnet` 匹配的外部 IP 时,Pod 的出口 IP 为 `eip`,
当访问与 `DestSubnet` 不匹配的外部 IP 时, Pod 的出口 IP 为非 `eip` | p1 | true | | | -| P00014 | 编辑原本匹配 `DaemonSet-A` 的 `PodSelector` ,使之改为匹配 `DaemonSet-B`,
`EgressEndpoint` 会由 `DaemonSet-A` 更新为 `DaemonSet-B` 的信息,
并且 `DaemonSet-A` 所有 Pod 的 出口 IP 由 `eip` 改为非 `eip`,`DaemonSet-B` 所有 Pod 的出口 IP 由非 `eip` 改为 `eip` | p1 | true | | | -| P00015 | 当 `EgressIP.UseNodeIP` 为 `true` 并且 `EgressIP` 的 IP 为空时,创建 `EgressPolicy`,
`EgressPolicyStatus.Eip` 和 `EgressGatewayStatus.Eips` 的 IP 应该为空,并且 Pod 的出口 IP 为 egressGateway `nodeSelector` 所匹配的 node 的 IP | p1 | true | | | -| P00016 | 当 `EgressIP.UseNodeIP` 为 `true` 并且 `EgressIP` 的 IP 为空时,
修改EgressGateway 的 `nodeSelector` 匹配另一个节点,并且 Pod 的出口 IP 为 egressGateway `nodeSelector` 新匹配的 node 的 IP | p1 | true | | | -| P00017 | 当 `EgressIP.UseNodeIP` 为 `true` 并且 `EgressIP` 的 IP 不为空时,创建 `EgressPolicy` 会失败 | p2 | false | | | -| P00018 | 当编辑 Policy 的 `EgressIP` 的 IP 时,会报错 | p2 | false | | | -| P00019 | 当编辑 Policy 的 `EgressGatewayName` 时,会报错 | p2 | false | | | -| P00020 | 当删除 Policy,`EgressGatewayStatus` 和 `EgressEndpoint` 将如预期更新,并且 Pod 的出口 IP 由 `eip` 改为非 `eip` | p1 | true | | | -| P00021 | `namespace-level` 的 Policy 只生效在它所指定的命名空间 | p2 | false | | | \ No newline at end of file +| 用例编号 | 标题 | 优先级 | 冒烟 | 状态 | 其他 | +|--------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----|-------|-----|-----| +| P00001 | 当使用不合法的 `EgressIP`,创建 EgressPolicy 失败 | p2 | false | done | | +| P00002 | 当 `EgressGatewayName` 为空时,创建集群级 `EgressPolicy` 时,会使用集群默认的 `EgressGateway`,检查 `EgressPolicySpec.EgressGatewayName` 及 `EgressPolicyStatus` 状态正确 | p2 | false | done | | +| P00003 | 当 `EgressGatewayName` 为空时,创建租户级 `EgressPolicy`时,如果对应租户注解上有相关 `EgressGateway` 的标注,则使用标注的 `EgressGatewa`,如果没有则使用集群默认的 `EgressGateway`,检查 `EgressPolicySpec.EgressGatewayName` 及 `EgressPolicyStatus` 状态正确 | p2 | false | done | | +| P00004 | 当 `EgressIP` 没有在 `Policy` 所选择的 `egressGateway` 的 `Ippools` 范围内,创建 EgressPolicy 会失败 | p2 | false | done | | +| P00005 | 当 `AppliedTo` 为空时,创建 EgressPolicy 会失败 | p2 | false | done | | +| P00006 | 当同时设置 `AppliedTo.PodSubnet` 和 `AppliedTo.PodSelector` 时,创建 `Policy` 失败 | p2 | false | done | | +| P00007 | 当只设置了 `AppliedTo.PodSubnet`,与之匹配到的 `Pod` 的出口 IP 应是 `eip`,没有匹配到的 `Pod` 的出口 IP,应为非 `eip`,并且 `endpointSlice` 不会被创建 | p1 | true | done | | +| P00008 | 当 `EgressIP` 为空并且设置了 `AppliedTo.PodSelector` 时,`Policy` 的 `EgressPolicyStatus.Eip` 和 Pod 的出口 IP 为 `egressGateway` 的 `defaultEIP`,`policy` 的 `allocatorPolicy` 为 `default`、`useNodeIP` 为 `false`, `EgressGatewayStatus` 会如预期更新 | p1 | true | done | | +| P00009 | 当 `EgressIP` 的 IP 为空,并且 `EgressIP.AllocatorPolicy` 为轮询模式时, `eip` 会从 `EgressGatewaySpec.Ippools` 的 IP 中获取,检查 `EgressPolicyStatus` 和 `EgressGatewayStatus` 状态正确 | p2 | false | done | | +| P00010 | 当 `EgressIP` 的 IP 不为空,并且 `EgressIP.AllocatorPolicy` 为轮询模式时, `EgressIP` 会生效, 检查 `EgressPolicyStatus` 和 `EgressGatewayStatus` 状态正确 | p2 | false | done | | +| P00011 | 当 `Policy` 的 `DestSubnet` 为空并且访问的目的 IP 不在 `egressClusterInfo.Status` 中的 IP 列表范围之内时,
Pod 的出口 IP 为 `eip` | p1 | true | done | | +| P00012 | 当 `Policy` 的 `DestSubnet` 为空并且访问的目的 IP 在 `egressClusterInfo.Status` 中的 IP 列表范围之内时,
Pod 的出口 IP 不为 `eip` | p1 | true | done | | +| P00013 | 设置 `DestSubnet` 和 `PodSelector`, 当访问与 `DestSubnet` 匹配的外部 IP 时,Pod 的出口 IP 为 `eip`,
当访问与 `DestSubnet` 不匹配的外部 IP 时, Pod 的出口 IP 为非 `eip` | p1 | true | done | | +| P00014 | 编辑原本匹配 `DaemonSet-A` 的 `PodSelector` ,使之改为匹配 `DaemonSet-B`,
`EgressEndpoint` 会由 `DaemonSet-A` 更新为 `DaemonSet-B` 的信息,
并且 `DaemonSet-A` 所有 Pod 的 出口 IP 由 `eip` 改为非 `eip`,`DaemonSet-B` 所有 Pod 的出口 IP 由非 `eip` 改为 `eip` | p1 | true | done | | +| P00015 | 当 `EgressIP.UseNodeIP` 为 `true` 并且 `EgressIP` 的 IP 为空时,创建 `EgressPolicy`,
`EgressPolicyStatus.Eip` 和 `EgressGatewayStatus.Eips` 的 IP 应该为空,并且 Pod 的出口 IP 为 egressGateway `nodeSelector` 所匹配的 node 的 IP | p1 | true | done | | +| P00016 | 当 `EgressIP.UseNodeIP` 为 `true` 并且 `EgressIP` 的 IP 为空时,
修改EgressGateway 的 `nodeSelector` 匹配另一个节点,并且 Pod 的出口 IP 为 egressGateway `nodeSelector` 新匹配的 node 的 IP | p1 | true | done | | +| P00017 | 当 `EgressIP.UseNodeIP` 为 `true` 并且 `EgressIP` 的 IP 不为空时,创建 `EgressPolicy` 会失败 | p2 | false | done | | +| P00018 | 当编辑 Policy 的 `EgressIP` 的 IP 时,会报错 | p2 | false | done | | +| P00019 | 当编辑 Policy 的 `EgressGatewayName` 时,会报错 | p2 | false | done | | +| P00020 | 当删除 Policy,`EgressGatewayStatus` 和 `EgressEndpoint` 将如预期更新,并且 Pod 的出口 IP 由 `eip` 改为非 `eip` | p1 | true | done | | +| P00021 | `namespace-level` 的 Policy 只生效在它所指定的命名空间 | p2 | false | done | | \ No newline at end of file diff --git a/test/e2e/common/ds.go b/test/e2e/common/ds.go index 3e966ac82..977aac7f5 100644 --- a/test/e2e/common/ds.go +++ b/test/e2e/common/ds.go @@ -72,3 +72,14 @@ func CreateDaemonSet(ctx context.Context, cli client.Client, name string, image } } } + +func GetDaemonSetPodIPs(ctx context.Context, cli client.Client, ds *appsv1.DaemonSet) (ipv4List, ipv6List []string, err error) { + podList := new(corev1.PodList) + listOps := client.MatchingLabels(ds.Spec.Selector.MatchLabels) + err = cli.List(ctx, podList, listOps) + if err != nil { + return nil, nil, err + } + ipv4List, ipv6List = GetPodListIPs(podList) + return ipv4List, ipv6List, nil +} diff --git a/test/e2e/common/eci.go b/test/e2e/common/eci.go index 16d2ef178..1b307a994 100644 --- a/test/e2e/common/eci.go +++ b/test/e2e/common/eci.go @@ -15,6 +15,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" egressv1 "github.com/spidernet-io/egressgateway/pkg/k8s/apis/v1beta1" + "github.com/spidernet-io/egressgateway/test/e2e/tools" ) func UpdateEgressClusterInfoNew(ctx context.Context, cli client.Client, @@ -134,6 +135,10 @@ func CheckEgressClusterInfoStatusSynced( checked++ } } + if tools.IsSameSlice(eci.Spec.ExtraCidr, eci.Status.ExtraCidr) { + exp++ + checked++ + } if checked == exp { return nil diff --git a/test/e2e/common/pod.go b/test/e2e/common/pod.go index 35dbf829e..e8f204e5c 100644 --- a/test/e2e/common/pod.go +++ b/test/e2e/common/pod.go @@ -153,3 +153,12 @@ func GetPodIPs(pod *corev1.Pod) (ipv4List, ipv6List []string) { } return ipv4List, ipv6List } + +func GetPodListIPs(podList *corev1.PodList) (ipv4List, ipv6List []string) { + for _, pod := range podList.Items { + v4s, v6s := GetPodIPs(&pod) + ipv4List = append(ipv4List, v4s...) + ipv6List = append(ipv6List, v6s...) + } + return ipv4List, ipv6List +} diff --git a/test/e2e/egresspolicy/egresspolicy_test.go b/test/e2e/egresspolicy/egresspolicy_test.go index 58d251ac2..e91f51b5c 100644 --- a/test/e2e/egresspolicy/egresspolicy_test.go +++ b/test/e2e/egresspolicy/egresspolicy_test.go @@ -27,13 +27,19 @@ import ( ) var _ = Describe("EgressPolicy", Serial, func() { - var egw *egressv1.EgressGateway + var ( + egw *egressv1.EgressGateway + ipNum int + pool egressv1.Ippools + ) BeforeEach(func() { ctx := context.Background() + var err error + ipNum = 3 // create EgressGateway - pool, err := common.GenIPPools(ctx, cli, egressConfig.EnableIPv4, egressConfig.EnableIPv6, 3, 1) + pool, err = common.GenIPPools(ctx, cli, egressConfig.EnableIPv4, egressConfig.EnableIPv6, int64(ipNum), 1) Expect(err).NotTo(HaveOccurred()) nodeSelector := egressv1.NodeSelector{Selector: &metav1.LabelSelector{MatchLabels: nodeLabel}} @@ -50,16 +56,29 @@ var _ = Describe("EgressPolicy", Serial, func() { }) }) - Context("Test EgressPolicy", Label("EgressPolicy", "P00007", "P00008", "P00013", "P00014", "P00019"), func() { + Context("Test EgressPolicy", Label("EgressPolicy", "P00007", "P00008", "P00011", "P00012", "P00013", "P00014", "P00020"), func() { var ( dsA *appsv1.DaemonSet dsB *appsv1.DaemonSet policy *egressv1.EgressPolicy clusterPolicy *egressv1.EgressClusterPolicy + + // ip usage + ipUsage egressv1.IPUsage ) BeforeEach(func() { + // ip usage + if len(pool.IPv4) != 0 { + ipUsage.IPv4Total = ipNum + ipUsage.IPv4Free = ipNum - 1 + } + if len(pool.IPv6) != 0 { + ipUsage.IPv6Total = ipNum + ipUsage.IPv6Free = ipNum - 1 + } + ctx := context.Background() var err error // create DaemonSet-A DaemonSet-B for A/B test @@ -89,8 +108,8 @@ var _ = Describe("EgressPolicy", Serial, func() { var err error ctx := context.Background() - // P00008 - By("case P00008: create policy with empty `EgressIP`") + // P00008 and P00011 + By("case P00008, P00011: create policy with empty `EgressIP`") policy, err = common.CreateEgressPolicyNew(ctx, cli, egressConfig, egw.Name, dsA.Labels, "") Expect(err).NotTo(HaveOccurred()) @@ -101,12 +120,66 @@ var _ = Describe("EgressPolicy", Serial, func() { err = common.CheckDaemonSetEgressIP(ctx, cli, config, egressConfig, dsA, e.Ipv4, e.Ipv6, true) Expect(err).NotTo(HaveOccurred()) - // P00011 - By("case P00011: update policy to empty `DestSubnet`") - e = policy.Status.Eip + // check the status of the policy and gateway + GinkgoWriter.Printf("check the status of the policy: %s\n", policy.Name) + expectPolicyStatus := &egressv1.EgressPolicyStatus{ + Eip: egressv1.Eip{ + Ipv4: egw.Spec.Ippools.Ipv4DefaultEIP, + Ipv6: egw.Spec.Ippools.Ipv6DefaultEIP, + }, + Node: node1.Name, + } + Expect(common.CheckEgressPolicyStatusSynced(ctx, cli, policy, expectPolicyStatus, time.Second*5)).NotTo(HaveOccurred()) + + GinkgoWriter.Printf("check the status of the gateway: %s\n", egw.Name) + expectGatewayStatus := &egressv1.EgressGatewayStatus{ + NodeList: []egressv1.EgressIPStatus{ + { + Name: node1.Name, + Eips: []egressv1.Eips{ + { + IPv4: egw.Spec.Ippools.Ipv4DefaultEIP, + IPv6: egw.Spec.Ippools.Ipv6DefaultEIP, + Policies: []egressv1.Policy{ + { + Name: policy.Name, + Namespace: policy.Namespace, + }, + }, + }, + }, + Status: string(egressv1.EgressTunnelReady), + }, + }, + IPUsage: ipUsage, + } + err = common.CheckEgressGatewayStatusSynced(ctx, cli, egw, expectGatewayStatus, time.Second*5) + Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("expect: %v\ngot: %v\n", expectGatewayStatus, egw.Status)) + + GinkgoWriter.Println("the exported IP of the unmatched dsB should not be the EIP") err = common.CheckDaemonSetEgressIP(ctx, cli, config, egressConfig, dsB, e.Ipv4, e.Ipv6, false) Expect(err).NotTo(HaveOccurred()) + // P00012 + By("case P00012: add the ips of the nettools-server-a to the spec.extraCidr field of the egressClusterInfo") + + egci, err := updateEgressClusterInfoExtraCidr(ctx, []string{config.ServerAIPv4, config.ServerAIPv6}) + Expect(err).NotTo(HaveOccurred()) + + // check dsA + GinkgoWriter.Printf("we expect the exportIP of the dsA should not be the EIP") + err = common.CheckDaemonSetEgressIP(ctx, cli, config, egressConfig, dsA, e.Ipv4, e.Ipv6, false) + Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("egressClusterInfo yaml: %s\npolicy yaml: %s\n", common.GetObjYAML(egci), common.GetObjYAML(policy))) + + GinkgoWriter.Println("set the spec.ExtraCidr back to be empty") + egci, err = updateEgressClusterInfoExtraCidr(ctx, []string{config.ServerAIPv4, config.ServerAIPv6}) + Expect(err).NotTo(HaveOccurred()) + + // check dsA again + GinkgoWriter.Printf("we expect the exportIP of the matched dsA should be the EIP") + err = common.CheckDaemonSetEgressIP(ctx, cli, config, egressConfig, dsA, e.Ipv4, e.Ipv6, true) + Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("egressClusterInfo yaml: %s\npolicy yaml: %s\n", common.GetObjYAML(egci), common.GetObjYAML(policy))) + // P00014 By("case P00014: update policy matched dsA to match dsB") policy.Spec.AppliedTo.PodSelector.MatchLabels = dsB.Spec.Template.Labels @@ -137,8 +210,8 @@ var _ = Describe("EgressPolicy", Serial, func() { err = common.CheckDaemonSetEgressIP(ctx, cli, config, egressConfig, dsB, e.Ipv4, e.Ipv6, false) Expect(err).NotTo(HaveOccurred()) - // P00019 - By("case P00019: delete policy, we expect the egress address not egressIP") + // P00020 + By("case P00020: delete policy, we expect the egress address not egressIP") err = common.DeleteObj(ctx, cli, policy) Expect(err).NotTo(HaveOccurred()) @@ -153,8 +226,8 @@ var _ = Describe("EgressPolicy", Serial, func() { var err error ctx := context.Background() - // P00008 - By("case P00008: create policy with empty `EgressIP`") + // P00008 and P00011 + By("case P00008, P00011: create policy with empty `EgressIP`") clusterPolicy, err = common.CreateEgressClusterPolicy(ctx, cli, egressConfig, egw.Name, dsA.Labels) Expect(err).NotTo(HaveOccurred()) @@ -165,12 +238,63 @@ var _ = Describe("EgressPolicy", Serial, func() { err = common.CheckDaemonSetEgressIP(ctx, cli, config, egressConfig, dsA, e.Ipv4, e.Ipv6, true) Expect(err).NotTo(HaveOccurred()) - // P00011 - By("case P00011: update policy to empty `DestSubnet`") - e = clusterPolicy.Status.Eip + // check the status of the policy and gateway + GinkgoWriter.Printf("check the status of the policy: %s\n", clusterPolicy.Name) + expectPolicyStatus := &egressv1.EgressPolicyStatus{ + Eip: egressv1.Eip{ + Ipv4: egw.Spec.Ippools.Ipv4DefaultEIP, + Ipv6: egw.Spec.Ippools.Ipv6DefaultEIP, + }, + Node: node1.Name, + } + Expect(common.CheckEgressClusterPolicyStatusSynced(ctx, cli, clusterPolicy, expectPolicyStatus, time.Second*5)).NotTo(HaveOccurred()) + + GinkgoWriter.Printf("check the status of the gateway: %s\n", egw.Name) + expectGatewayStatus := &egressv1.EgressGatewayStatus{ + NodeList: []egressv1.EgressIPStatus{ + { + Name: node1.Name, + Eips: []egressv1.Eips{ + { + IPv4: egw.Spec.Ippools.Ipv4DefaultEIP, + IPv6: egw.Spec.Ippools.Ipv6DefaultEIP, + Policies: []egressv1.Policy{ + { + Name: clusterPolicy.Name, + }, + }, + }, + }, + Status: string(egressv1.EgressTunnelReady), + }, + }, + IPUsage: ipUsage, + } + Expect(common.CheckEgressGatewayStatusSynced(ctx, cli, egw, expectGatewayStatus, time.Second*5)).NotTo(HaveOccurred()) + + GinkgoWriter.Println("the exported IP of the unmatched dsB should not be the EIP") err = common.CheckDaemonSetEgressIP(ctx, cli, config, egressConfig, dsB, e.Ipv4, e.Ipv6, false) Expect(err).NotTo(HaveOccurred()) + // P00012 + By("case P00012: add the ips of the nettools-server-a to the spec.extraCidr field of the egressClusterInfo") + egci, err := updateEgressClusterInfoExtraCidr(ctx, []string{config.ServerAIPv4, config.ServerAIPv6}) + Expect(err).NotTo(HaveOccurred()) + + // check dsA + GinkgoWriter.Printf("we expect the exportIP of the dsA should not be the EIP") + err = common.CheckDaemonSetEgressIP(ctx, cli, config, egressConfig, dsA, e.Ipv4, e.Ipv6, false) + Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("egressClusterInfo yaml: %s\npolicy yaml: %s\n", common.GetObjYAML(egci), common.GetObjYAML(policy))) + + GinkgoWriter.Println("set the spec.ExtraCidr back to be empty") + egci, err = updateEgressClusterInfoExtraCidr(ctx, []string{config.ServerAIPv4, config.ServerAIPv6}) + Expect(err).NotTo(HaveOccurred()) + + // check dsA again + GinkgoWriter.Printf("we expect the exportIP of the matched dsA should be the EIP") + err = common.CheckDaemonSetEgressIP(ctx, cli, config, egressConfig, dsA, e.Ipv4, e.Ipv6, true) + Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("egressClusterInfo yaml: %s\npolicy yaml: %s\n", common.GetObjYAML(egci), common.GetObjYAML(policy))) + // P00014 By("case P00014: update policy matched dsA to match dsB") clusterPolicy.Spec.AppliedTo.PodSelector.MatchLabels = dsB.Spec.Template.Labels @@ -201,8 +325,8 @@ var _ = Describe("EgressPolicy", Serial, func() { err = common.CheckDaemonSetEgressIP(ctx, cli, config, egressConfig, dsB, e.Ipv4, e.Ipv6, false) Expect(err).NotTo(HaveOccurred()) - // P00019 - By("case P00019: delete policy, we expect the egress address not egressIP") + // P00020 + By("case P00020: delete policy, we expect the egress address not egressIP") err = common.DeleteObj(ctx, cli, clusterPolicy) Expect(err).NotTo(HaveOccurred()) @@ -289,6 +413,18 @@ var _ = Describe("EgressPolicy", Serial, func() { egp.Spec.EgressIP.IPv6 = egw.Spec.Ippools.Ipv6DefaultEIP } }), + Entry("should success when the `Spec.EgressIP` of the policy is not empty and the Spec.EgressIP.AllocatorPolicy is 'rr'", Label("P00010"), false, + func(egp *egressv1.EgressPolicy) { + egp.Spec.EgressGatewayName = egw.Name + egp.Spec.AppliedTo.PodSubnet = []string{"10.10.0.0/16"} + if egressConfig.EnableIPv4 { + egp.Spec.EgressIP.IPv4 = egw.Spec.Ippools.Ipv4DefaultEIP + } + if egressConfig.EnableIPv6 { + egp.Spec.EgressIP.IPv6 = egw.Spec.Ippools.Ipv6DefaultEIP + } + egp.Spec.EgressIP.AllocatorPolicy = egressv1.EipAllocatorRR + }), ) DescribeTable("cluster policy", func(expectErr bool, setUp func(egp *egressv1.EgressClusterPolicy)) { @@ -343,6 +479,19 @@ var _ = Describe("EgressPolicy", Serial, func() { egcp.Spec.EgressIP.IPv6 = egw.Spec.Ippools.Ipv6DefaultEIP } }), + + Entry("should success when the `Spec.EgressIP` of the policy is not empty and the Spec.EgressIP.AllocatorPolicy is 'rr'", Label("P00010"), false, + func(egcp *egressv1.EgressClusterPolicy) { + egcp.Spec.EgressGatewayName = egw.Name + egcp.Spec.AppliedTo.PodSubnet = &[]string{"10.10.0.0/16"} + if egressConfig.EnableIPv4 { + egcp.Spec.EgressIP.IPv4 = egw.Spec.Ippools.Ipv4DefaultEIP + } + if egressConfig.EnableIPv6 { + egcp.Spec.EgressIP.IPv6 = egw.Spec.Ippools.Ipv6DefaultEIP + } + egcp.Spec.EgressIP.AllocatorPolicy = egressv1.EipAllocatorRR + }), ) /* @@ -912,7 +1061,7 @@ var _ = Describe("EgressPolicy", Serial, func() { Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("the status of the gateway is: %v\nthe status of expect is: %v\n", defaultClusterEgw.Status, expectGatewayStatus)) }) - It("namespace-level policy", Label("P00002"), func() { + It("namespace-level policy", Label("P00003"), func() { // create namespace testNS = &corev1.Namespace{ ObjectMeta: metav1.ObjectMeta{ @@ -1001,3 +1150,18 @@ func createNamespaceLevelPolicyAndCheck(ctx context.Context, egw *egressv1.Egres err = common.CheckEgressGatewayStatusSynced(ctx, cli, egw, expectGatewayStatus, time.Second*5) Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("the status of the gateway is: %v\nthe status of expect is: %v\n", egw.Status, expectGatewayStatus)) } + +func updateEgressClusterInfoExtraCidr(ctx context.Context, extraCidr []string) (*egressv1.EgressClusterInfo, error) { + egci := new(egressv1.EgressClusterInfo) + egci.Name = "default" + Expect(cli.Get(ctx, types.NamespacedName{Name: egci.Name}, egci)).NotTo(HaveOccurred()) + // egci.Spec.ExtraCidr = []string{config.ServerAIPv4, config.ServerAIPv6} + egci.Spec.ExtraCidr = extraCidr + Expect(common.UpdateEgressClusterInfoNew(ctx, cli, egci)).NotTo(HaveOccurred()) + err := common.CheckEgressClusterInfoStatusSynced(ctx, cli, egci) + if err != nil { + GinkgoWriter.Printf("failed to check the status of egressClusterInfo: %v\n", common.GetObjYAML(egci)) + return nil, err + } + return egci, err +}