Skip to content
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

Fix L7 NetworkPolicy e2e test failure #6138

Merged
merged 1 commit into from
Mar 25, 2024

Commits on Mar 25, 2024

  1. Fix L7 NetworkPolicy e2e test failure

    Fix antrea-io#6129
    
    In the failure tests, the following function is called to
    verify whether a connection should be allowed or denied.
    To verify a connection should be denied, it requires 5 seconds.
    
    ```go
    func probeClientIPFromPod(data *TestData, pod, container string, baseUrl string) (string, error) {
    	url := fmt.Sprintf("%s/%s", baseUrl, "clientip")
    	hostPort, _, err := data.runWgetCommandFromTestPodWithRetry(pod, data.testNamespace, container, url, 5)
    	if err != nil {
    		return "", err
    	}
    	host, _, err := net.SplitHostPort(hostPort)
    	return host, err
    }
    ```
    
    Before antrea-io#5843, these e2e tests utilized the function `PollImmediate`
    from `k8s.io/apimachinery/pkg/util/wait`, which immediately calls an
    anonymous function including the above function. Since the timeout
    is 5 seconds, and the ticker time is 1 second, and the anonymous
    function runs immediately, the 5-second timeout is sufficient to
    verify the denied state of a connection as mentioned above. However,
    after antrea-io#5843, the function `Eventually` from `github.com/stretchr/testify/assert`
    is used with the same parameters, which implies that the anonymous
    function runs after the first ticker time, leaving 4 seconds. 4 seconds
    are insufficient to verify the denied state of a connection.
    
    To resolve the issue, `RunCommandFromPod` called in
    `data.runWgetCommandFromTestPodWithRetry` is called directly in function
     `Eventually` to verify the connection state.
    
    Signed-off-by: Hongliang Liu <lhongliang@vmware.com>
    hongliangl committed Mar 25, 2024
    Configuration menu
    Copy the full SHA
    21a572b View commit details
    Browse the repository at this point in the history