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

kola network.go: fix cl.network.listeners proc truncate #62

Merged
merged 2 commits into from
Mar 12, 2020

Conversation

t-lo
Copy link
Member

@t-lo t-lo commented Mar 11, 2020

The test cl.network.listeners checks for active listener sockets.
It uses netstat -plutn to list listeners which may truncate the
program name. Since the output is compared to predefined strings
the test may fail if the combination of PID, "/", and program
name exceeds 19 characters.

This change truncates the expected string to the constraints lined
out above, which fixes the test.

To reproduce the error, run this test e.g. on Azure, where it
reproducibly fails because the PID of systemd-networkd has
4 digits:

bin/kola run cl.network.listeners --platform azure --azure-disk-uri <flatcar-image-URI> --azure-location <location-of-image>

For testing, the following URI / location may be used (transient, images will be removed eventually):

Image URI: /subscriptions/d38033ba-ec21-470c-96cf-4c6db9658d8b/resourceGroups/flatcar-release-testing-francecentral/providers/Microsoft.Compute/images/flatcar-linux-2345.3.0-stable-release-testing-francecentral
location: francecentral

Currently the test fails with:

=== RUN   cl.network.listeners
--- FAIL: cl.network.listeners (581.85s)
        network.go:120: full netstat output: "Active Internet connections (only servers)\nProto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    \ntcp6       0      0 :::22                   :::*                    LISTEN      1/systemd           \nudp        0      0 10.0.0.4:68             0.0.0.0:*                           1082/systemd-networ"
        network.go:120: full netstat output: "Active Internet connections (only servers)\nProto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    \ntcp6       0      0 :::22                   :::*                    LISTEN      1/systemd           \nudp        0      0 10.0.0.4:68             0.0.0.0:*                           1082/systemd-networ"
        network.go:120: full netstat output: "Active Internet connections (only servers)\nProto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    \ntcp6       0      0 :::22                   :::*                    LISTEN      1/systemd           \nudp        0      0 10.0.0.4:68             0.0.0.0:*                           1082/systemd-networ"
        network.go:138: Unexpected listener process: "udp        0      0 10.0.0.4:68             0.0.0.0:*                           1082/systemd-networ"

After applying the change the test succeeds:

=== RUN   cl.network.listeners
--- PASS: cl.network.listeners (408.91s)

Signed-off-by: Thilo Fromm [email protected]

The test cl.network.listeners checks for active listener sockets.
It uses `netstat -plutn` to list listeners which may truncate the
program name. Since the output is compared to predefined strings
the test may fail if the combination of PID, "/", and program
name exceeds 19 characters.

This change truncates the expected string to the constraints lined
out above, which fixes the test.

To reproduce the error, run this test e.g. on Azure, where it
reproducibly fails because the PID of systemd-networkd has
4 digits:

```
bin/kola run cl.network.listeners --platform azure --azure-disk-uri <flatcar-image-URI> --azure-location <location-of-image>
```

For testing, the following URI / location may be used:

URI: /subscriptions/d38033ba-ec21-470c-96cf-4c6db9658d8b/resourceGroups/flatcar-release-testing-francecentral/providers/Microsoft.Compute/images/flatcar-linux-2345.3.0-stable-release-testing-francecentral
location: francecentral

Currently the test fails with:
```
=== RUN   cl.network.listeners
--- FAIL: cl.network.listeners (581.85s)
        network.go:120: full netstat output: "Active Internet connections (only servers)\nProto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    \ntcp6       0      0 :::22                   :::*                    LISTEN      1/systemd           \nudp        0      0 10.0.0.4:68             0.0.0.0:*                           1082/systemd-networ"
        network.go:120: full netstat output: "Active Internet connections (only servers)\nProto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    \ntcp6       0      0 :::22                   :::*                    LISTEN      1/systemd           \nudp        0      0 10.0.0.4:68             0.0.0.0:*                           1082/systemd-networ"
        network.go:120: full netstat output: "Active Internet connections (only servers)\nProto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    \ntcp6       0      0 :::22                   :::*                    LISTEN      1/systemd           \nudp        0      0 10.0.0.4:68             0.0.0.0:*                           1082/systemd-networ"
        network.go:138: Unexpected listener process: "udp        0      0 10.0.0.4:68             0.0.0.0:*                           1082/systemd-networ"
```

After applying the change the test succeeds:
```
=== RUN   cl.network.listeners
--- PASS: cl.network.listeners (408.91s)
```

Signed-off-by: Thilo Fromm <[email protected]>
@t-lo t-lo requested review from alban, pothos and dongsupark March 11, 2020 16:21
@pothos
Copy link
Member

pothos commented Mar 11, 2020

Please append the d to https://github.com/flatcar-linux/mantle/blob/2e6bc1bec20b5f37b85485fa48a47b578541a0e7/kola/tests/misc/network.go#L131-L132 so that the initial name is not truncated.

@t-lo
Copy link
Member Author

t-lo commented Mar 11, 2020

Please append the d to https://github.com/flatcar-linux/mantle/pull/62/files#diff-0728790a5ad82f3442db78100dc94ee3L131-L132 so that the initial name is not truncated.

Done.

@t-lo t-lo merged commit f668b3a into flatcar-master Mar 12, 2020
@t-lo t-lo deleted the t-lo/fix-proc-truncate-cl.network.listeners branch March 12, 2020 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants