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

add all available endpoints to zos environment #2415

Merged
merged 5 commits into from
Sep 9, 2024
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
2 changes: 1 addition & 1 deletion pkg/api_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
type SubstrateGateway interface {
CreateNode(node substrate.Node) (uint32, error)
CreateTwin(relay string, pk []byte) (uint32, error)
EnsureAccount(activationURL string, termsAndConditionsLink string, termsAndConditionsHash string) (info substrate.AccountInfo, err error)
EnsureAccount(activationURL []string, termsAndConditionsLink string, termsAndConditionsHash string) (info substrate.AccountInfo, err error)
GetContract(id uint64) (substrate.Contract, SubstrateError)
GetContractIDByNameRegistration(name string) (uint64, SubstrateError)
GetFarm(id uint32) (substrate.Farm, error)
Expand Down
44 changes: 30 additions & 14 deletions pkg/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type Environment struct {
// SINCE RELAYS FOR A NODE IS STORED ON THE CHAIN IN A LIMITED SPACE
// PLEASE MAKE SURE THAT ANY ENV HAS NO MORE THAN FOUR RELAYS CONFIGURED
RelayURL []string
ActivationURL string
ActivationURL []string
GraphQL []string

// private vlan to join
Expand Down Expand Up @@ -108,14 +108,18 @@ var (
RunningMode: RunningDev,
SubstrateURL: []string{
"wss://tfchain.dev.grid.tf/",
"wss://tfchain.02.dev.grid.tf",
},
RelayURL: []string{
"wss://relay.dev.grid.tf",
"wss://relay.02.dev.grid.tf",
},
ActivationURL: "https://activation.dev.grid.tf/activation/activate",
FlistURL: "redis://hub.grid.tf:9900",
BinRepo: "tf-zos-v3-bins.dev",
ActivationURL: []string{
"https://activation.dev.grid.tf/activation/activate",
"https://activation.02.dev.grid.tf/activation/activate",
},
FlistURL: "redis://hub.grid.tf:9900",
BinRepo: "tf-zos-v3-bins.dev",
GraphQL: []string{
"https://graphql.dev.grid.tf/graphql",
"https://graphql.02.dev.grid.tf/graphql",
Expand All @@ -126,14 +130,18 @@ var (
RunningMode: RunningTest,
SubstrateURL: []string{
"wss://tfchain.test.grid.tf/",
"wss://tfchain.02.test.grid.tf",
},
RelayURL: []string{
"wss://relay.test.grid.tf",
"wss://relay.02.test.grid.tf",
},
ActivationURL: "https://activation.test.grid.tf/activation/activate",
FlistURL: "redis://hub.grid.tf:9900",
BinRepo: "tf-zos-v3-bins.test",
ActivationURL: []string{
"https://activation.test.grid.tf/activation/activate",
"https://activation.02.test.grid.tf/activation/activate",
},
FlistURL: "redis://hub.grid.tf:9900",
BinRepo: "tf-zos-v3-bins.test",
GraphQL: []string{
"https://graphql.test.grid.tf/graphql",
"https://graphql.02.test.grid.tf/graphql",
Expand All @@ -148,10 +156,14 @@ var (
},
RelayURL: []string{
"wss://relay.qa.grid.tf",
"wss://relay.02.qa.grid.tf",
},
ActivationURL: "https://activation.qa.grid.tf/activation/activate",
FlistURL: "redis://hub.grid.tf:9900",
BinRepo: "tf-zos-v3-bins.qanet",
ActivationURL: []string{
"https://activation.qa.grid.tf/activation/activate",
"https://activation.02.qa.grid.tf/activation/activate",
},
FlistURL: "redis://hub.grid.tf:9900",
BinRepo: "tf-zos-v3-bins.qanet",
GraphQL: []string{
"https://graphql.qa.grid.tf/graphql",
"https://graphql.02.qa.grid.tf/graphql",
Expand All @@ -162,6 +174,7 @@ var (
RunningMode: RunningMain,
SubstrateURL: []string{
"wss://tfchain.grid.tf/",
"wss://tfchain.02.grid.tf",
"wss://02.tfchain.grid.tf/",
"wss://03.tfchain.grid.tf/",
"wss://04.tfchain.grid.tf/",
Expand All @@ -170,9 +183,12 @@ var (
"wss://relay.grid.tf",
"wss://relay.02.grid.tf",
},
ActivationURL: "https://activation.grid.tf/activation/activate",
FlistURL: "redis://hub.grid.tf:9900",
BinRepo: "tf-zos-v3-bins",
ActivationURL: []string{
"https://activation.grid.tf/activation/activate",
"https://activation.02.grid.tf/activation/activate",
},
FlistURL: "redis://hub.grid.tf:9900",
BinRepo: "tf-zos-v3-bins",
GraphQL: []string{
"https://graphql.grid.tf/graphql",
"https://graphql.02.grid.tf/graphql",
Expand Down Expand Up @@ -253,7 +269,7 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) {

if activation, ok := params.Get("activation"); ok {
if len(activation) > 0 {
env.ActivationURL = activation[len(activation)-1]
env.ActivationURL = activation
rawdaGastan marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
7 changes: 3 additions & 4 deletions pkg/perf/healthcheck/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ const defaultRequestTimeout = 5 * time.Second

func networkCheck(ctx context.Context) []error {
env := environment.MustGet()
servicesUrl := []string{
env.ActivationURL, env.FlistURL,
}
servicesUrl := []string{env.FlistURL}

servicesUrl = append(append(servicesUrl, env.SubstrateURL...), env.RelayURL...)
servicesUrl = append(servicesUrl, env.GraphQL...)
servicesUrl = append(append(servicesUrl, env.ActivationURL...), env.GraphQL...)

var errors []error

Expand Down
2 changes: 1 addition & 1 deletion pkg/stubs/api_gateway_stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (s *SubstrateGatewayStub) CreateTwin(ctx context.Context, arg0 string, arg1
return
}

func (s *SubstrateGatewayStub) EnsureAccount(ctx context.Context, arg0 string, arg1 string, arg2 string) (ret0 tfchainclientgo.AccountInfo, ret1 error) {
func (s *SubstrateGatewayStub) EnsureAccount(ctx context.Context, arg0 []string, arg1 string, arg2 string) (ret0 tfchainclientgo.AccountInfo, ret1 error) {
args := []interface{}{arg0, arg1, arg2}
result, err := s.client.RequestContext(ctx, s.module, s.object, "EnsureAccount", args...)
if err != nil {
Expand Down
15 changes: 12 additions & 3 deletions pkg/substrate_gateway/substrate_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,25 @@ func (g *substrateGateway) CreateTwin(relay string, pk []byte) (uint32, error) {
return g.sub.CreateTwin(g.identity, relay, pk)
}

func (g *substrateGateway) EnsureAccount(activationURL string, termsAndConditionsLink string, termsAndConditionsHash string) (info substrate.AccountInfo, err error) {
func (g *substrateGateway) EnsureAccount(activationURL []string, termsAndConditionsLink string, termsAndConditionsHash string) (info substrate.AccountInfo, err error) {
log.Debug().
Str("method", "EnsureAccount").
Str("activation url", activationURL).
Strs("activation url", activationURL).
Str("terms and conditions link", termsAndConditionsLink).
Str("terms and conditions hash", termsAndConditionsHash).
Msg("method called")
g.mu.Lock()
defer g.mu.Unlock()
return g.sub.EnsureAccount(g.identity, activationURL, termsAndConditionsLink, termsAndConditionsHash)

for _, url := range activationURL {
info, err = g.sub.EnsureAccount(g.identity, url, termsAndConditionsLink, termsAndConditionsHash)
// check other activationURL only if EnsureAccount failed with ActivationServiceError
if err == nil || !errors.As(err, &substrate.ActivationServiceError{}) {
return
}
log.Debug().Str("activation url", url).Err(err).Msg("failed to EnsureAccount with ActivationServiceError")
}
return
}

func (g *substrateGateway) GetContract(id uint64) (result substrate.Contract, serr pkg.SubstrateError) {
Expand Down
Loading