Skip to content

Commit 20b67dd

Browse files
committed
Enable rootful unit testing on linux
Signed-off-by: apostasie <[email protected]>
1 parent 687aac5 commit 20b67dd

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

.github/workflows/job-test-unit.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,9 @@ jobs:
8080
name: "Run"
8181
run: |
8282
make test-unit
83+
84+
# On linux, also run with root
85+
- if: ${{ env.GO_VERSION != '' && env.RUNNER_OS == 'Linux' }}
86+
name: "Run: with root"
87+
run: |
88+
sudo make test-unit

pkg/imgutil/dockerconfigresolver/credentialsstore_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import (
2525
"testing"
2626

2727
"gotest.tools/v3/assert"
28+
29+
"github.com/containerd/nerdctl/v2/pkg/rootlessutil"
2830
)
2931

3032
func createTempDir(t *testing.T, mode os.FileMode) string {
@@ -40,12 +42,10 @@ func createTempDir(t *testing.T, mode os.FileMode) string {
4042
}
4143

4244
func TestBrokenCredentialsStore(t *testing.T) {
43-
if runtime.GOOS == "freebsd" {
44-
// It is unclear why these tests are failing on FreeBSD, and if it is a problem with Vagrant or differences
45-
// with FreeBSD
46-
// Anyhow, this test is about extreme cases & conditions (filesystem errors wrt credentials loading).
47-
t.Skip("skipping broken credential store tests for freebsd")
45+
if !rootlessutil.IsRootless() {
46+
t.Skip("test is for rootless")
4847
}
48+
4949
if runtime.GOOS == "windows" {
5050
// Same as above
5151
t.Skip("test is not compatible with windows")

pkg/netutil/netutil_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import (
3434
"github.com/containerd/nerdctl/v2/pkg/testutil"
3535
)
3636

37-
const testBridgeIP = "10.1.100.1/24" // nolint:unused
37+
const testBridgeIP = "10.42.100.1/24" // nolint:unused
3838

3939
const preExistingNetworkConfigTemplate = `
4040
{
@@ -278,8 +278,8 @@ func testDefaultNetworkCreationWithBridgeIP(t *testing.T) {
278278
// Assert on bridge plugin configuration
279279
assert.Equal(t, "bridge", bridgeConfig.Type)
280280
// Assert on IPAM configuration
281-
assert.Equal(t, "10.1.100.1", bridgeConfig.IPAM.Ranges[0][0].Gateway)
282-
assert.Equal(t, "10.1.100.0/24", bridgeConfig.IPAM.Ranges[0][0].Subnet)
281+
assert.Equal(t, "10.42.100.1", bridgeConfig.IPAM.Ranges[0][0].Gateway)
282+
assert.Equal(t, "10.42.100.0/24", bridgeConfig.IPAM.Ranges[0][0].Subnet)
283283
assert.Equal(t, "0.0.0.0/0", bridgeConfig.IPAM.Routes[0].Dst)
284284
assert.Equal(t, "host-local", bridgeConfig.IPAM.Type)
285285

0 commit comments

Comments
 (0)