Skip to content

Commit 4725fe1

Browse files
Hayk10002tcarmelveilleuxandy31415andreilitvin
authored
Fix Github CI for v1.4-branch (project-chip#40589)
* Fix TestInetEndPoint to pass even when computer is offline (project-chip#38015) Description: - TestInetEndPoint was not hermetic, it required at least one network interface connected to a link and up. - There was a comment before to skip tests if the link was not up, but it was not actually skipping the test. This made it fail for me when working offline and trying to run unit tests. Testing done: - Test passes with and without link up. * Add debug logs for test inet limits (project-chip#38790) * Add debug log for endpoint full error * Also add assertions that no in use items * Clean up includes * Fix typo in message * Setup ipv6 environment in `REPL Tests - Linux` CI job This change is picked from the PR [project-chip#38845](project-chip#38845) * Setup ipv6 environment in other places where it's needed * Add sudo to IPV6 setup commands for proper permissions * Revert "Add sudo to IPV6 setup commands for proper permissions" This reverts commit 025cc0c. * Remove `add-apv6` action from `Build on Linux (python_lib)` This doesn't work because of permission issues. * Stop using old ubuntu version (project-chip#37870) Co-authored-by: Andrei Litvin <[email protected]> --------- Co-authored-by: Tennessee Carmel-Veilleux <[email protected]> Co-authored-by: Andrei Litvin <[email protected]> Co-authored-by: Andrei Litvin <[email protected]>
1 parent 2acb65b commit 4725fe1

File tree

6 files changed

+78
-7
lines changed

6 files changed

+78
-7
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Set up an IPV6 environment
2+
description: Creates a socket pair with a "peer" network namespace that supports IPV6
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Set up IPV6
7+
if: ${{ runner.os == 'Linux' }}
8+
shell: bash
9+
run: |
10+
ip netns add peer
11+
12+
ip link add name veth0 type veth peer name veth0-peer
13+
ip -6 addr add fd00:0:1:1::1/64 dev veth0
14+
ip link set dev veth0 up
15+
16+
ip link set veth0-peer netns peer
17+
ip netns exec peer ip -6 addr add fd00:0:1:1::2/64 dev veth0-peer
18+
ip netns exec peer ip link set dev veth0-peer up

.github/workflows/build.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ jobs:
6666
run: |
6767
mkdir /tmp/cores || true
6868
sysctl -w kernel.core_pattern=/tmp/cores/core.%u.%p.%t || true
69+
- name: Set up a IPV6 known environment
70+
uses: ./.github/actions/add-ipv6
6971
- name: Checkout submodules & Bootstrap
7072
uses: ./.github/actions/checkout-submodules-and-bootstrap
7173
with:
@@ -162,6 +164,8 @@ jobs:
162164
run: |
163165
mkdir /tmp/cores || true
164166
sysctl -w kernel.core_pattern=/tmp/cores/core.%u.%p.%t || true
167+
- name: Set up a IPV6 known environment
168+
uses: ./.github/actions/add-ipv6
165169
- name: Checkout submodules & Bootstrap
166170
uses: ./.github/actions/checkout-submodules-and-bootstrap
167171
with:
@@ -468,6 +472,10 @@ jobs:
468472
steps:
469473
- name: Checkout
470474
uses: actions/checkout@v4
475+
476+
- name: Set up a IPV6 known environment
477+
uses: ./.github/actions/add-ipv6
478+
471479
- name: Checkout submodules & Bootstrap
472480
uses: ./.github/actions/checkout-submodules-and-bootstrap
473481
with:

.github/workflows/tests.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ jobs:
7878
sysctl -w kernel.core_pattern=/tmp/cores/core.%u.%p.%t || true
7979
mkdir objdir-clone || true
8080
81+
- name: Set up a IPV6 known environment
82+
uses: ./.github/actions/add-ipv6
83+
8184
- name: Validate that xml are parsable
8285
# The sub-items being run here are the same as the input XMLs listed
8386
# at src/app/zap-templates/zcl/zcl.json
@@ -473,6 +476,9 @@ jobs:
473476
sysctl -w kernel.core_pattern=/tmp/cores/core.%u.%p.%t || true
474477
mkdir objdir-clone || true
475478
479+
- name: Set up a IPV6 known environment
480+
uses: ./.github/actions/add-ipv6
481+
476482
- name: Build Python REPL and example apps
477483
# NOTE: the data-mode-check + check-failure-die is not 100% perfect as different
478484
# encoding sizes for data that keeps changing may alter over time (e.g. anything relating to time

.github/workflows/zap_regeneration.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
zap_regeneration:
2929
name: ZAP Regeneration
3030

31-
runs-on: ubuntu-20.04
31+
runs-on: ubuntu-latest
3232
container:
3333
image: ghcr.io/project-chip/chip-build:81
3434
defaults:

.github/workflows/zap_templates.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
zap_templates:
3434
name: ZAP templates generation
3535

36-
runs-on: ubuntu-20.04
36+
runs-on: ubuntu-latest
3737
container:
3838
image: ghcr.io/project-chip/chip-build:81
3939
defaults:

src/inet/tests/TestInetEndPoint.cpp

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333

3434
#include <CHIPVersion.h>
3535
#include <inet/IPPrefix.h>
36+
#include <inet/InetConfig.h>
3637
#include <inet/InetError.h>
38+
#include <inet/UDPEndPoint.h>
3739
#include <lib/core/StringBuilderAdapters.h>
3840
#include <lib/support/CHIPArgParser.hpp>
3941
#include <lib/support/CHIPMem.h>
@@ -277,8 +279,13 @@ TEST_F(TestInetEndPoint, TestInetEndPointInternal)
277279

278280
err = InterfaceId::Null().GetLinkLocalAddr(&addr);
279281

280-
// We should skip the following checks if the interface does not have the Link local address
281-
ASSERT_NE(err, INET_ERROR_ADDRESS_NOT_FOUND);
282+
// We should skip the following checks if the interface does not have the Link local address.
283+
// This can happen if you don't have network interfaces connected to any link (like happened
284+
// to the author of this comment at YYZ before CSA 2025 Chicago Member Meeting).
285+
if (err == INET_ERROR_ADDRESS_NOT_FOUND)
286+
{
287+
return;
288+
}
282289

283290
EXPECT_EQ(err, CHIP_NO_ERROR);
284291
intId = InterfaceId::FromIPAddress(addr);
@@ -381,12 +388,29 @@ TEST_F(TestInetEndPoint, TestInetEndPointLimit)
381388

382389
CHIP_ERROR err = CHIP_NO_ERROR;
383390

391+
// we assume NO open endpoints
392+
gUDP.ForEachEndPoint([](UDPEndPoint * ep) {
393+
ChipLogError(Test, "NOTE: Unexpected UDP endpoint in use. Will free it");
394+
ep->Free();
395+
return Loop::Continue;
396+
});
397+
384398
int udpCount = 0;
385399
SYSTEM_STATS_RESET(System::Stats::kInetLayer_NumUDPEps);
386400
for (int i = INET_CONFIG_NUM_UDP_ENDPOINTS; i >= 0; --i)
387401
{
388402
err = gUDP.NewEndPoint(&testUDPEP[i]);
389-
EXPECT_EQ(err, (i ? CHIP_NO_ERROR : CHIP_ERROR_ENDPOINT_POOL_FULL));
403+
404+
CHIP_ERROR expected_error = (i ? CHIP_NO_ERROR : CHIP_ERROR_ENDPOINT_POOL_FULL);
405+
if (err != expected_error)
406+
{
407+
// have a log to debug things
408+
ChipLogError(Test, "UDP: Failure on index %d: (out of %d)", i, INET_CONFIG_NUM_UDP_ENDPOINTS);
409+
410+
// this will fail after the above log
411+
EXPECT_EQ(err, expected_error);
412+
}
413+
390414
if (err == CHIP_NO_ERROR)
391415
{
392416
++udpCount;
@@ -397,12 +421,27 @@ TEST_F(TestInetEndPoint, TestInetEndPointLimit)
397421
EXPECT_TRUE(SYSTEM_STATS_TEST_HIGH_WATER_MARK(System::Stats::kInetLayer_NumUDPEps, udpHighWaterMark));
398422

399423
#if INET_CONFIG_ENABLE_TCP_ENDPOINT
424+
// we assume NO open endpoints
425+
gTCP.ForEachEndPoint([](TCPEndPoint * ep) {
426+
ChipLogError(Test, "NOTE: Unexpected TCP endpoint in use. Will free it");
427+
ep->Free();
428+
return Loop::Continue;
429+
});
430+
400431
int tcpCount = 0;
401432
SYSTEM_STATS_RESET(System::Stats::kInetLayer_NumTCPEps);
402433
for (int i = INET_CONFIG_NUM_TCP_ENDPOINTS; i >= 0; --i)
403434
{
404-
err = gTCP.NewEndPoint(&testTCPEP[i]);
405-
EXPECT_EQ(err, (i ? CHIP_NO_ERROR : CHIP_ERROR_ENDPOINT_POOL_FULL));
435+
err = gTCP.NewEndPoint(&testTCPEP[i]);
436+
CHIP_ERROR expected_error = (i ? CHIP_NO_ERROR : CHIP_ERROR_ENDPOINT_POOL_FULL);
437+
if (err != expected_error)
438+
{
439+
// have a log to debug things
440+
ChipLogError(Test, "TCP: Failure on index %d: (out of %d)", i, INET_CONFIG_NUM_TCP_ENDPOINTS);
441+
442+
// this will fail after the above log
443+
EXPECT_EQ(err, expected_error);
444+
}
406445
if (err == CHIP_NO_ERROR)
407446
{
408447
++tcpCount;

0 commit comments

Comments
 (0)