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

Staging #559

Merged
merged 33 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
60693e5
update tests
asabya Oct 1, 2023
be295ea
feat: save outgoing feeds in LRU and update in batch
asabya Oct 3, 2023
b3cd75e
fix: lint
asabya Oct 3, 2023
02402b8
use lruv2
asabya Oct 4, 2023
a48f6ba
reduce test times
asabya Oct 4, 2023
45d4354
fix test race
asabya Oct 4, 2023
cc33ae0
cacheSize and cacheTTL
asabya Oct 6, 2023
4b603d3
bee http client request close, minor bug fixes
asabya Nov 9, 2023
084402d
add max files test
asabya Nov 9, 2023
08e86b8
feat: add fedd cache config and flags
asabya Nov 14, 2023
51f1346
fix: increase timeout
asabya Nov 14, 2023
a9d3d35
chore: update deps
asabya Nov 15, 2023
9d4c425
fix: minor text fixes
asabya Nov 15, 2023
c8302d3
feat: unlimited pod
asabya Nov 16, 2023
bf179e6
feat: unlimited files
asabya Nov 17, 2023
c5929f7
dir meta upload working with tests
asabya Nov 22, 2023
544286d
code improvements
asabya Nov 27, 2023
2b53f73
minor fixes
asabya Dec 8, 2023
ccd4c8e
fix: race test
asabya Dec 13, 2023
970de6d
feat: dev command
asabya Dec 14, 2023
043d412
fix: lint
asabya Dec 14, 2023
1a60e78
Merge pull request #564 from fairDataSociety/issue563
asabya Dec 15, 2023
7bc5bfa
Merge pull request #560 from fairDataSociety/issue551
asabya Dec 15, 2023
499cb52
chore(deps): bump golang.org/x/term from 0.14.0 to 0.15.0
dependabot[bot] Dec 15, 2023
650326c
chore(deps): bump github.com/golang-jwt/jwt/v5 from 5.0.0 to 5.2.0
dependabot[bot] Dec 15, 2023
282a642
chore(deps): bump github.com/gorilla/websocket from 1.5.0 to 1.5.1
dependabot[bot] Dec 15, 2023
44793d8
Merge pull request #565 from fairDataSociety/dependabot/go_modules/st…
asabya Dec 15, 2023
9f82817
Merge pull request #569 from fairDataSociety/dependabot/go_modules/st…
asabya Dec 15, 2023
6f94982
chore(deps): bump github.com/spf13/viper from 1.16.0 to 1.18.1
dependabot[bot] Dec 15, 2023
00b90db
Merge pull request #566 from fairDataSociety/dependabot/go_modules/st…
asabya Dec 15, 2023
6875975
Merge pull request #567 from fairDataSociety/dependabot/go_modules/st…
asabya Dec 15, 2023
34bb995
chore(deps): bump go.uber.org/goleak from 1.2.1 to 1.3.0
dependabot[bot] Dec 15, 2023
bc8b777
Merge pull request #568 from fairDataSociety/dependabot/go_modules/st…
asabya Dec 15, 2023
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: 2 additions & 2 deletions .github/workflows/coverge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.20.1'
go-version: '1.21.4'
- name: Checkout
uses: actions/checkout@v3
with:
Expand All @@ -24,6 +24,6 @@ jobs:
env:
DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }}
run: |
go test -coverprofile=cover.out $(go list ./... | grep -v wasm)
go test -coverprofile=cover.out $(go list ./... | grep -v wasm) -timeout=30m
curl https://deepsource.io/cli | sh
./bin/deepsource report --analyzer test-coverage --key go --value-file ./cover.out
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go: ['1.20.1']
go: ['1.21.4']
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Setup Go
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.20.1'
go-version: '1.21.4'
- name: Checkout
uses: actions/checkout@v3
with:
Expand All @@ -45,7 +45,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.20.1'
go-version: '1.21.4'
- name: Checkout
uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.20.1'
go-version: '1.21.4'
- name: Checkout
uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20.2-alpine AS build
FROM golang:1.21.4-alpine AS build

WORKDIR /usr/fairos
COPY go.mod go.sum /usr/fairos/
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GO ?= go
GOLANGCI_LINT ?= $$($(GO) env GOPATH)/bin/golangci-lint
GOLANGCI_LINT_VERSION ?= v1.52.2
GOLANGCI_LINT_VERSION ?= v1.55.2
GOGOPROTOBUF ?= protoc-gen-gogofaster
GOGOPROTOBUF_VERSION ?= v1.3.1

Expand Down Expand Up @@ -41,11 +41,11 @@ vet:

.PHONY: test-race
test-race:
$(GO) test -race -timeout 1000000ms -v "$(DEST)"
$(GO) test -race -timeout 30m -v "$(DEST)"

.PHONY: test
test:
$(GO) test -v "$(DEST)"
$(GO) test -v "$(DEST)" -timeout=30m

.PHONY: githooks
githooks:
Expand Down Expand Up @@ -74,7 +74,7 @@ release:
-v `pwd`:/go/src/github.com/fairDataSociety/fairOS-dfs \
-v /var/run/docker.sock:/var/run/docker.sock \
-w /go/src/github.com/fairDataSociety/fairOS-dfs \
ghcr.io/goreleaser/goreleaser-cross:v1.20.2 release --rm-dist
ghcr.io/goreleaser/goreleaser-cross:v1.21.0 release --rm-dist

.PHONY: release-dry-run
release-dry-run:
Expand All @@ -84,7 +84,7 @@ release-dry-run:
-v `pwd`:/go/src/github.com/fairDataSociety/fairOS-dfs \
-v /var/run/docker.sock:/var/run/docker.sock \
-w /go/src/github.com/fairDataSociety/fairOS-dfs \
ghcr.io/goreleaser/goreleaser-cross:v1.20.2 release --rm-dist \
ghcr.io/goreleaser/goreleaser-cross:v1.21.0 release --rm-dist \
--skip-validate=true \
--skip-publish

Expand Down
2 changes: 2 additions & 0 deletions cmd/dfs/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ var (
optionVerbosity = "verbosity"
optionBeeApi = "bee.bee-api-endpoint"
optionBeePostageBatchId = "bee.postage-batch-id"
optionFeedCacheSize = "feed.cache-size"
optionFeedCacheTTL = "feed.cache-ttl"
optionCookieDomain = "cookie-domain"
optionNetwork = "ens-network"
optionRPC = "rpc"
Expand Down
78 changes: 78 additions & 0 deletions cmd/dfs/cmd/dev.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package cmd

import (
"context"
"fmt"
"io"
"os"
"os/signal"
"syscall"
"testing"

mockpost "github.com/ethersphere/bee/pkg/postage/mock"
mockstorer "github.com/ethersphere/bee/pkg/storer/mock"
"github.com/fairdatasociety/fairOS-dfs/pkg/api"
"github.com/fairdatasociety/fairOS-dfs/pkg/blockstore/bee"
"github.com/fairdatasociety/fairOS-dfs/pkg/blockstore/bee/mock"
"github.com/fairdatasociety/fairOS-dfs/pkg/dfs"
mock2 "github.com/fairdatasociety/fairOS-dfs/pkg/ensm/eth/mock"
"github.com/fairdatasociety/fairOS-dfs/pkg/logging"
"github.com/fairdatasociety/fairOS-dfs/pkg/user"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

var devCmd = &cobra.Command{
Use: "dev",
Short: "run fairOS-dfs in development mode",
Run: func(cmd *cobra.Command, args []string) {
startDevServer()
},
}

func init() {
rootCmd.AddCommand(devCmd)
}

func startDevServer() {
storer := mockstorer.New()
t := &testing.T{}
fmt.Println(`▓█████▄ ▓█████ ██▒ █▓
▒██▀ ██▌▓█ ▀▓██░ █▒
░██ █▌▒███ ▓██ █▒░
░▓█▄ ▌▒▓█ ▄ ▒██ █░░
░▒████▓ ░▒████▒ ▒▀█░
▒▒▓ ▒ ░░ ▒░ ░ ░ ▐░
░ ▒ ▒ ░ ░ ░ ░ ░░
░ ░ ░ ░ ░░
░ ░ ░ ░
░ ░ `)
beeUrl := mock.NewTestBeeServer(t, mock.TestServerOptions{
Storer: storer,
PreventRedirect: true,
Post: mockpost.New(mockpost.WithAcceptAll()),
})
fmt.Println("Bee running at: ", beeUrl)
logger := logging.New(io.Discard, logrus.DebugLevel)
mockClient := bee.NewBeeClient(beeUrl, mock.BatchOkStr, true, logger)
ens := mock2.NewMockNamespaceManager()

users := user.NewUsers(mockClient, ens, -1, 0, logger)
dfsApi := dfs.NewMockDfsAPI(mockClient, users, logger)
handler = api.NewMockHandler(dfsApi, logger, []string{"http://localhost:3000"})
defer handler.Close()
httpPort = ":9090"
pprofPort = ":9091"
srv := startHttpService(logger)
fmt.Printf("Server running at:http://127.0.0.1%s\n", httpPort)
defer func() {
err := srv.Shutdown(context.TODO())
if err != nil {
logger.Error("failed to shutdown server", err.Error())
}
}()
done := make(chan os.Signal, 1)
signal.Notify(done, syscall.SIGINT, syscall.SIGTERM)

<-done
}
19 changes: 17 additions & 2 deletions cmd/dfs/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ can consume it.`,
if err := config.BindPFlag(optionDFSPprofPort, cmd.Flags().Lookup("pprofPort")); err != nil {
return err
}
if err := config.BindPFlag(optionFeedCacheSize, cmd.Flags().Lookup("feedCacheSize")); err != nil {
return err
}
if err := config.BindPFlag(optionFeedCacheTTL, cmd.Flags().Lookup("feedCacheTTL")); err != nil {
return err
}
if err := config.BindPFlag(optionDFSPprofPort, cmd.Flags().Lookup("pprofPort")); err != nil {
return err
}
if err := config.BindPFlag(optionCookieDomain, cmd.Flags().Lookup("cookieDomain")); err != nil {
return err
}
Expand Down Expand Up @@ -175,9 +184,11 @@ can consume it.`,
logger.Info("verbosity : ", verbosity)
logger.Info("httpPort : ", httpPort)
logger.Info("pprofPort : ", pprofPort)
logger.Info("pprofPort : ", pprofPort)
logger.Info("pprofPort : ", pprofPort)
logger.Info("cookieDomain : ", cookieDomain)
logger.Info("postageBlockId : ", postageBlockId)
logger.Info("corsOrigins : ", corsOrigins)
logger.Info("feedCacheSize : ", config.GetInt(optionFeedCacheSize))
logger.Info("feedCacheTTL : ", config.GetString(optionFeedCacheTTL))

ctx, cancel := context.WithCancel(cmd.Context())
defer cancel()
Expand All @@ -190,6 +201,8 @@ can consume it.`,
EnsConfig: ensConfig,
SubscriptionConfig: subscriptionConfig,
Logger: logger,
FeedCacheSize: config.GetInt(optionFeedCacheSize),
FeedCacheTTL: config.GetString(optionFeedCacheTTL),
}

hdlr, err := api.New(ctx, opts)
Expand Down Expand Up @@ -229,6 +242,8 @@ func init() {
serverCmd.Flags().BoolVar(&swag, "swag", false, "should run swagger-ui")
serverCmd.Flags().String("httpPort", defaultDFSHttpPort, "http port")
serverCmd.Flags().String("pprofPort", defaultDFSPprofPort, "pprof port")
serverCmd.Flags().Int("feedCacheSize", -1, "Keep feed updates in lru cache for faster access. -1 to disable")
serverCmd.Flags().String("feedCacheTTL", "0s", "How long to keep feed updates in lru cache. 0s to disable")
serverCmd.Flags().String("cookieDomain", defaultCookieDomain, "the domain to use in the cookie")
serverCmd.Flags().String("postageBlockId", "", "the postage block used to store the data in bee")
serverCmd.Flags().StringSlice("cors-origins", defaultCORSAllowedOrigins, "allow CORS headers for the given origins")
Expand Down
18 changes: 14 additions & 4 deletions cmd/dfs/cmd/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ import (
"testing"
"time"

mockpost "github.com/ethersphere/bee/pkg/postage/mock"
mockstorer "github.com/ethersphere/bee/pkg/storer/mock"
"github.com/fairdatasociety/fairOS-dfs/cmd/common"
"github.com/fairdatasociety/fairOS-dfs/pkg/api"
"github.com/fairdatasociety/fairOS-dfs/pkg/blockstore/bee"
"github.com/fairdatasociety/fairOS-dfs/pkg/blockstore/bee/mock"
"github.com/fairdatasociety/fairOS-dfs/pkg/dfs"
mock2 "github.com/fairdatasociety/fairOS-dfs/pkg/ensm/eth/mock"
Expand All @@ -43,11 +46,18 @@ func randStringRunes(n int) string {
}

func TestApis(t *testing.T) {
mockClient := mock.NewMockBeeClient()
storer := mockstorer.New()
beeUrl := mock.NewTestBeeServer(t, mock.TestServerOptions{
Storer: storer,
PreventRedirect: true,
Post: mockpost.New(mockpost.WithAcceptAll()),
})

logger := logging.New(io.Discard, logrus.DebugLevel)
mockClient := bee.NewBeeClient(beeUrl, mock.BatchOkStr, true, logger)
ens := mock2.NewMockNamespaceManager()
logger := logging.New(io.Discard, logrus.ErrorLevel)

users := user.NewUsers(mockClient, ens, logger)
users := user.NewUsers(mockClient, ens, 500, 0, logger)
dfsApi := dfs.NewMockDfsAPI(mockClient, users, logger)
handler = api.NewMockHandler(dfsApi, logger, []string{"http://localhost:3000"})
defer handler.Close()
Expand All @@ -64,7 +74,7 @@ func TestApis(t *testing.T) {
}
}()

// wait 10 seconds for the server to start
// wait for the server to start
<-time.After(time.Second * 3)
t.Run("login-fail-test", func(t *testing.T) {
c := http.Client{Timeout: time.Duration(1) * time.Minute}
Expand Down
Loading
Loading