TestVolumeOwnership: compare GID, not group name
The name of the GID 65534 differs across distros.
("nogroup" on Debian derivatives, "nobody" on Red Hat derivatives)
Fix the following test failure:
```
=== RUN   TestVolumeOwnership
    volume_copy_up_test.go:103: Create a sandbox
    main_test.go:667: Pull test image "ghcr.io/containerd/volume-ownership:2.1"
    volume_copy_up_test.go:108: Create a container with volume-ownership test image
    volume_copy_up_test.go:117: Start the container
    volume_copy_up_test.go:125: Check ownership of test directory inside container
    volume_copy_up_test.go:146: Check ownership of test directory on the host
    volume_copy_up_test.go:153:
        	Error Trace:	/root/go/src/github.com/containerd/containerd/volume_copy_up_test.go:153
        	Error:      	Not equal:
        	            	expected: "nobody:nogroup\n"
        	            	actual  : "nobody:nobody\n"
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1,2 +1,2 @@
        	            	-nobody:nogroup
        	            	+nobody:nobody
        	Test:       	TestVolumeOwnership
--- FAIL: TestVolumeOwnership (3.45s)
```
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
			
			
This commit is contained in:
		| @@ -118,17 +118,17 @@ func TestVolumeOwnership(t *testing.T) { | |||||||
| 	require.NoError(t, runtimeService.StartContainer(cn)) | 	require.NoError(t, runtimeService.StartContainer(cn)) | ||||||
|  |  | ||||||
| 	// ghcr.io/containerd/volume-ownership:2.1 contains a test_dir | 	// ghcr.io/containerd/volume-ownership:2.1 contains a test_dir | ||||||
| 	// volume, which is owned by nobody:nogroup. | 	// volume, which is owned by 65534:65534 (nobody:nogroup, or nobody:nobody). | ||||||
| 	// On Windows, the folder is situated in C:\volumes\test_dir and is owned | 	// On Windows, the folder is situated in C:\volumes\test_dir and is owned | ||||||
| 	// by ContainerUser (SID: S-1-5-93-2-2). A helper tool get_owner.exe should | 	// by ContainerUser (SID: S-1-5-93-2-2). A helper tool get_owner.exe should | ||||||
| 	// exist inside the container that returns the owner in the form of USERNAME:SID. | 	// exist inside the container that returns the owner in the form of USERNAME:SID. | ||||||
| 	t.Logf("Check ownership of test directory inside container") | 	t.Logf("Check ownership of test directory inside container") | ||||||
|  |  | ||||||
| 	cmd := []string{ | 	cmd := []string{ | ||||||
| 		"stat", "-c", "%U:%G", "/test_dir", | 		"stat", "-c", "%u:%g", "/test_dir", | ||||||
| 	} | 	} | ||||||
| 	expectedContainerOutput := "nobody:nogroup\n" | 	expectedContainerOutput := "65534:65534\n" | ||||||
| 	expectedHostOutput := "nobody:nogroup\n" | 	expectedHostOutput := "65534:65534\n" | ||||||
| 	if goruntime.GOOS == "windows" { | 	if goruntime.GOOS == "windows" { | ||||||
| 		cmd = []string{ | 		cmd = []string{ | ||||||
| 			"C:\\bin\\get_owner.exe", | 			"C:\\bin\\get_owner.exe", | ||||||
|   | |||||||
| @@ -25,7 +25,7 @@ import ( | |||||||
| ) | ) | ||||||
|  |  | ||||||
| func getOwnership(path string) (string, error) { | func getOwnership(path string) (string, error) { | ||||||
| 	hostCmd := fmt.Sprintf("stat -c %%U:%%G '%s'", path) | 	hostCmd := fmt.Sprintf("stat -c %%u:%%g '%s'", path) | ||||||
| 	output, err := exec.Command("sh", "-c", hostCmd).CombinedOutput() | 	output, err := exec.Command("sh", "-c", hostCmd).CombinedOutput() | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return "", err | 		return "", err | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Akihiro Suda
					Akihiro Suda