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

nydusify: fix unit test fail #1530

Merged
merged 3 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ on:

env:
CARGO_TERM_COLOR: always
IMAGE: wordpress
TAG: 6.1.1

jobs:
contrib-build:
Expand Down Expand Up @@ -195,7 +193,7 @@ jobs:
- name: Unit Test
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b /usr/bin v1.54.2
sudo make -e DOCKER=false contrib-test
make -e DOCKER=false contrib-test
- name: Upload contrib coverage file
uses: actions/upload-artifact@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion contrib/nydusify/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ coverage: test

clean:
rm -f cmd/nydusify
rm -f coverage.out
rm -f coverage.txt
19 changes: 0 additions & 19 deletions contrib/nydusify/pkg/utils/archive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
package utils

import (
"context"
"io"
"os"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestPackTargzInfo(t *testing.T) {
Expand All @@ -29,19 +26,3 @@ func TestPackTargzInfo(t *testing.T) {
assert.Equal(t, "sha256:6cdd1b26d54d5852fbea95a81cbb25383975b70b4ffad9f9b6d25c7a434a51eb", digest.String())
assert.Equal(t, size, int64(315))
}

func TestUnpackTargz(t *testing.T) {
file, err := os.CreateTemp("", "nydusify-test")
defer os.RemoveAll(file.Name())
require.NoError(t, err)
err = os.WriteFile(file.Name(), []byte("123456789"), 0666)
require.NoError(t, err)
reader, err := PackTargz(file.Name(), file.Name(), true)
require.NoError(t, err)

err = UnpackTargz(context.Background(), "test", io.Reader(reader), false)
defer os.RemoveAll("test")
require.NoError(t, err)
err = UnpackTargz(context.Background(), "test", io.Reader(reader), true)
require.NoError(t, err)
}
7 changes: 4 additions & 3 deletions contrib/nydusify/pkg/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ package utils
import (
"archive/tar"
"compress/gzip"
"fmt"
"io"
"net/http"
"os"
"strings"
"syscall"
"testing"

"github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -241,11 +242,11 @@ func TestWithRetry(t *testing.T) {
_, err := http.Get("http://localhost:5000")
return err
})
require.Contains(t, err.Error(), "connect: connection refused")
require.ErrorIs(t, err, syscall.ECONNREFUSED)
}

func TestRetryWithHTTP(t *testing.T) {
require.True(t, RetryWithHTTP(fmt.Errorf("server gave HTTP response to HTTPS client")))
require.True(t, RetryWithHTTP(errors.Wrap(http.ErrSchemeMismatch, "parse Nydus image")))
require.False(t, RetryWithHTTP(nil))
}

Expand Down