diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5437c3f..99502b6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -21,8 +21,8 @@ jobs: uses: actions/setup-go@v4 with: go-version: ${{ matrix.go }} - - name: go test -race -v ./... - run: go test -race -v ./... + - name: go test -v ./... + run: go test -v ./... coverage: runs-on: 'ubuntu-latest' @@ -34,7 +34,7 @@ jobs: with: go-version: '1.20' - name: Run coverage - run: go test -race -covermode=atomic -coverprofile=coverage.out -v ./... + run: go test -covermode=atomic -coverprofile=coverage.out -v ./... - name: Convert coverage.out to coverage.lcov uses: jandelgado/gcov2lcov-action@v1 - name: Coveralls diff --git a/README.md b/README.md index a673d15..ba81fca 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,11 @@ It's primary focus is implementing [TVIX](https://cs.tvl.fyi/depot/-/tree/tvix) ## Roadmap -- [ ] Store +- [x] Store - [x] Blob Service - - [ ] Path Info Service - - [ ] Directory Service + - [x] Path Info Service + - [x] Directory Service +- [ ] Improve test coverage ## Requirements diff --git a/internal/cli/store/run.go b/internal/cli/store/run.go index 568ea5c..f46c620 100644 --- a/internal/cli/store/run.go +++ b/internal/cli/store/run.go @@ -1,13 +1,14 @@ package store import ( - tvpb "code.tvl.fyi/tvix/store/protos" - "github.com/brianmcgee/nvix/pkg/pathinfo" "net" "net/http" "runtime/debug" "syscall" + tvpb "code.tvl.fyi/tvix/store/protos" + "github.com/brianmcgee/nvix/pkg/pathinfo" + "github.com/brianmcgee/nvix/pkg/directory" "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/recovery" diff --git a/nix/dev/tvix.nix b/nix/dev/tvix.nix index e7eaa52..26c7997 100644 --- a/nix/dev/tvix.nix +++ b/nix/dev/tvix.nix @@ -21,13 +21,11 @@ } { name = "PATH_INFO_SERVICE_ADDR"; -# eval = "sled://$TVIX_HOME/store/path-info"; value = "grpc+http://localhost:5000"; } { name = "DIRECTORY_SERVICE_ADDR"; value = "grpc+http://localhost:5000"; - # eval = "sled://$TVIX_HOME/store/directory"; } { name = "TVIX_MOUNT_DIR"; diff --git a/pkg/blob/grpc_test.go b/pkg/blob/grpc_test.go index 05bf3b5..61d3761 100644 --- a/pkg/blob/grpc_test.go +++ b/pkg/blob/grpc_test.go @@ -3,8 +3,8 @@ package blob import ( "bytes" "context" + "crypto/rand" "io" - "math/rand" "net" "testing" @@ -83,9 +83,11 @@ func BenchmarkBlobService_Put(b *testing.B) { b.ResetTimer() b.RunParallel(func(p *testing.PB) { - rng := rand.New(rand.NewSource(1)) data := make([]byte, size) - rng.Read(data) + _, err := rand.Read(data) + if err != nil { + b.Fatal(err) + } r := bytes.NewReader(data) @@ -133,9 +135,11 @@ func BenchmarkBlobService_Read(b *testing.B) { for _, size := range sizes { size := size - rng := rand.New(rand.NewSource(1)) data := make([]byte, size) - rng.Read(data) + _, err := rand.Read(data) + if err != nil { + b.Fatal(err) + } r := bytes.NewReader(data) @@ -210,7 +214,7 @@ func TestBlobService_Put(t *testing.T) { conn := test.GrpcConn(lis, t) client := pb.NewBlobServiceClient(conn) - payload := make([]byte, 100*1024*1024) + payload := make([]byte, 16*1024*1024) _, err := rand.Read(payload) if err != nil { t.Fatalf("failed to generate random bytes: %v", err) diff --git a/pkg/pathinfo/grpc.go b/pkg/pathinfo/grpc.go index c2689a3..594cff0 100644 --- a/pkg/pathinfo/grpc.go +++ b/pkg/pathinfo/grpc.go @@ -2,9 +2,12 @@ package pathinfo import ( "bytes" + "context" + "io" + capb "code.tvl.fyi/tvix/castore/protos" tvpb "code.tvl.fyi/tvix/store/protos" - "context" + "github.com/brianmcgee/nvix/pkg/blob" "github.com/brianmcgee/nvix/pkg/directory" "github.com/brianmcgee/nvix/pkg/store" @@ -17,7 +20,6 @@ import ( "github.com/nix-community/go-nix/pkg/nixbase32" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "io" ) func NewServer(conn *nats.Conn, blob *blob.Server, directory *directory.Server) (*Service, error) { @@ -76,7 +78,6 @@ func (s *Service) Get(ctx context.Context, req *tvpb.GetPathInfoRequest) (*tvpb. l.Debug("executing", "outHash", outHash) reader, err := s.outIdx.Get(outHash, ctx) - if err != nil { return nil, err } diff --git a/pkg/store/cdc.go b/pkg/store/cdc.go index d12fcc8..298f360 100644 --- a/pkg/store/cdc.go +++ b/pkg/store/cdc.go @@ -80,7 +80,6 @@ func (c *CdcStore) Get(digest Digest, ctx context.Context) (io.ReadCloser, error } func (c *CdcStore) Put(reader io.ReadCloser, ctx context.Context) (*Digest, error) { - hasher := blake3.New(32, nil) chunkHasher := blake3.New(32, nil) diff --git a/pkg/store/cdc_test.go b/pkg/store/cdc_test.go index 91c8e5c..1a4e1b8 100644 --- a/pkg/store/cdc_test.go +++ b/pkg/store/cdc_test.go @@ -137,9 +137,9 @@ func TestCdcStore_List(t *testing.T) { digests := make(map[string]bool) - writeCount := 100 + writeCount := 10 for i := 0; i < writeCount; i++ { - data := make([]byte, 20*1024*1024) + data := make([]byte, 8*1024*1024) rng.Read(data) digest, err := store.Put(io.NopCloser(bytes.NewReader(data)), context.Background())