Skip to content

Commit

Permalink
feat: add async propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
micbar committed Nov 26, 2024
1 parent 985d7ef commit d626045
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 354 deletions.
2 changes: 1 addition & 1 deletion .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def tests(ctx):
},
{
"name": "test",
"image": "owncloudci/golang:1.21",
"image": "owncloudci/golang:1.23",
"commands": [
"go test --endpoint=ocis:9142 -v",
],
Expand Down
22 changes: 9 additions & 13 deletions cs3apivalidator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package main
import (
"os"
"testing"
"time"

"github.com/cucumber/godog"
"github.com/cucumber/godog/colors"
"github.com/owncloud/cs3api-validator/featurecontext"
"github.com/owncloud/cs3api-validator/scenario"
flag "github.com/spf13/pflag"
)
Expand All @@ -15,29 +17,23 @@ var opts = godog.Options{
Format: "pretty", // can define default values
}

// endpoint GRPC address of a running CS3 implementation
var endpoint string

// httpInsecure controls whether insecure HTTP connections are allowed or not
var httpInsecure bool

// grpcTLSMode TLS mode for grpc client connections
var grpcTLSMode string

func init() {
godog.BindCommandLineFlags("godog.", &opts)
}

func TestMain(m *testing.M) {
flag.StringVar(&endpoint, "endpoint", "localhost:9142", "Endpoint Url and port of a running cs3 implementation")
flag.StringVar(&grpcTLSMode, "grpc-tls-mode", "off", "TLS mode for grpc client connections ('off', 'on' or 'insecure')")
flag.BoolVar(&httpInsecure, "http-insecure", true, "Allow insecure HTTP connections")
cfg := featurecontext.Config{}
flag.StringVar(&cfg.Endpoint, "endpoint", "localhost:9142", "Endpoint Url and port of a running cs3 implementation")
flag.StringVar(&cfg.GrpcTLSMode, "grpc-tls-mode", "off", "TLS mode for grpc client connections ('off', 'on' or 'insecure')")
flag.BoolVar(&cfg.AsyncPropagation, "async-propagation", false, "Enable async propagation")
flag.DurationVar(&cfg.AsyncPropagationDelay, "async-propagation-delay", 200*time.Millisecond, "Delay for async propagation")
flag.BoolVar(&cfg.HttpInsecure, "http-insecure", true, "Allow insecure HTTP connections")
flag.Parse()
opts.Paths = flag.Args()

status := godog.TestSuite{
Name: "cs3apiValidator",
ScenarioInitializer: scenario.InitializeScenario(endpoint, httpInsecure, grpcTLSMode),
ScenarioInitializer: scenario.InitializeScenario(cfg),
Options: &opts,
}.Run()

Expand Down
10 changes: 10 additions & 0 deletions featurecontext/featurecontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package featurecontext

import (
"net/http"
"time"

gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
userv1beta1 "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
Expand All @@ -19,10 +20,19 @@ type ResourceAlias struct {
Info *providerv1beta1.ResourceInfo
}

type Config struct {
Endpoint string
HttpInsecure bool
GrpcTLSMode string
AsyncPropagation bool
AsyncPropagationDelay time.Duration
}

// FeatureContext holds values which are used across test steps
type FeatureContext struct {
Client gateway.GatewayAPIClient
HTTPClient http.Client
Config Config

// remember the last response to check the outcome
Response interface{}
Expand Down
9 changes: 5 additions & 4 deletions featurecontext/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ import (
"github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool"
)

func (f *FeatureContext) Init(endpoint string, httpInsecure bool, grpcTLSMode string) {
func (f *FeatureContext) Init(cfg Config) {
f.Config = cfg
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
tm, err := pool.StringToTLSMode(grpcTLSMode)
tm, err := pool.StringToTLSMode(cfg.GrpcTLSMode)
if err != nil {
log.Fatal().Msg("Could not set TLS mode for grpc client")
}
client, err := pool.GetGatewayServiceClient(endpoint, pool.WithTLSMode(tm))
client, err := pool.GetGatewayServiceClient(cfg.Endpoint, pool.WithTLSMode(tm))
if err != nil {
log.Fatal().Msg("Could not initialize a grpc client")
}
Expand All @@ -27,7 +28,7 @@ func (f *FeatureContext) Init(endpoint string, httpInsecure bool, grpcTLSMode st
f.HTTPClient = http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: httpInsecure,
InsecureSkipVerify: cfg.HttpInsecure,
},
},
Timeout: time.Second * 10,
Expand Down
31 changes: 15 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
module github.com/owncloud/cs3api-validator

go 1.18
go 1.22.7

require (
github.com/cs3org/go-cs3apis v0.0.0-20221012090518-ef2996678965
github.com/cs3org/reva/v2 v2.10.1-0.20221019091055-df0a189e218d
github.com/cucumber/godog v0.12.2
github.com/cucumber/messages-go/v16 v16.0.1
github.com/cucumber/godog v0.15.0
github.com/cucumber/messages/go/v21 v21.0.1
github.com/rs/zerolog v1.28.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.0
google.golang.org/grpc v1.49.0
github.com/stretchr/testify v1.8.2
google.golang.org/grpc v1.68.0
)

require (
cloud.google.com/go/compute v1.10.0 // indirect
github.com/Azure/go-ntlmssp v0.0.0-20220621081337-cb9428e4ac1e // indirect
github.com/bluele/gcache v0.0.2 // indirect
github.com/cucumber/gherkin-go/v19 v19.0.3 // indirect
github.com/cucumber/gherkin/go/v26 v26.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/go-asn1-ber/asn1-ber v1.5.4 // indirect
github.com/go-ldap/ldap/v3 v3.4.4 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gofrs/uuid v4.3.0+incompatible // indirect
github.com/gofrs/uuid v4.3.1+incompatible // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/go-hclog v1.3.1 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-memdb v1.3.0 // indirect
github.com/hashicorp/go-memdb v1.3.4 // indirect
github.com/hashicorp/go-plugin v1.4.4 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 // indirect
Expand All @@ -49,12 +49,11 @@ require (
go.opentelemetry.io/otel/exporters/jaeger v1.10.0 // indirect
go.opentelemetry.io/otel/sdk v1.10.0 // indirect
go.opentelemetry.io/otel/trace v1.10.0 // indirect
golang.org/x/crypto v0.0.0-20220919173607-35f4265a4bc0 // indirect
golang.org/x/net v0.0.0-20220921155015-db77216a4ee9 // indirect
golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1 // indirect
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect
google.golang.org/genproto v0.0.0-20220920201722-2b89144ce006 // indirect
google.golang.org/protobuf v1.28.1 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit d626045

Please sign in to comment.