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 packetLoss parameter to Quality #111

Merged
merged 2 commits into from
Oct 24, 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
6 changes: 3 additions & 3 deletions ci/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func Run() error {
defer sh.RunV("docker-compose", "-f", e2e.DockerFile, "down", "-v")
defer sh.RunV("docker", "compose", "-f", e2e.DockerFile, "down", "-v")
err := UpDevDependencies()
if err != nil {
return err
Expand All @@ -34,7 +34,7 @@ func UpDevDependencies() error {
}

func upDependencies() error {
err := sh.RunV("docker-compose", "-f", e2e.DockerFile, "up", "-d", "dev")
err := sh.RunV("docker", "compose", "-f", e2e.DockerFile, "up", "-d", "dev")
if err != nil {
return err
}
Expand All @@ -43,5 +43,5 @@ func upDependencies() error {
}

func upApp() error {
return sh.RunV("docker-compose", "-f", e2e.DockerFile, "up", "--build", "-d", "discovery", "discopricer")
return sh.RunV("docker", "compose", "-f", e2e.DockerFile, "up", "--build", "-d", "discovery", "discopricer")
}
1 change: 1 addition & 0 deletions proposal/metrics/enhancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func EnhanceWithMetrics(proposals []v3.Proposal, or map[string]*oracleapi.Detail
p.Quality.Latency = q.Latency
p.Quality.Bandwidth = q.Bandwidth
p.Quality.Uptime = q.Uptime
p.Quality.PacketLoss = q.PacketLoss
p.Quality.MonitoringFailed = q.MonitoringFailed

if !matchPreset(f.PresetID, p) {
Expand Down
12 changes: 6 additions & 6 deletions proposal/v3/metadata_json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions proposal/v3/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ type Quality struct {
Bandwidth float64 `json:"bandwidth"`
// Uptime in hours per day
Uptime float64 `json:"uptime"`
// PacketLoss in percantage
PacketLoss float64 `json:"packetLoss"`
// MonitoringFailed did monitoring agent succeed to connect to the node.
MonitoringFailed bool `json:"monitoring_failed,omitempty"`
}
7 changes: 7 additions & 0 deletions proposal/v3/proposal_json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions proposal/v3/proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package v3_test

import (
"encoding/json"
v3 "github.com/mysteriumnetwork/discovery/proposal/v3"
"reflect"
"testing"

v3 "github.com/mysteriumnetwork/discovery/proposal/v3"
)

func TestProposal_MarshalBinary(t *testing.T) {
proposalJson := `{"id":0,"format":"service-proposal/v3","compatibility":2,"provider_id":"0x55d9995cf3482ee0628fe25e3c95a95899f23cad","service_type":"scraping","location":{"continent":"EU","country":"PL","region":"Malopolskie","city":"Nowy Sacz","asn":5617,"isp":"Orange Polska Spolka Akcyjna","ip_type":"residential"},"contacts":[{"type":"nats/p2p/v1","definition":{"broker_addresses":["nats://broker.mysterium.network:4222","nats://broker.mysterium.network:4222","nats://51.15.22.197:4222","nats://51.15.23.12:4222","nats://51.15.23.14:4222","nats://51.15.23.16:4222"]}}],"access_policies":[{"id":"mysterium","source":"https://trust.mysterium.network/api/v1/access-policies/mysterium"}],"quality":{"quality":2.0250000000000004,"latency":824.898867,"bandwidth":10.275812,"uptime":24}}`
proposalJson := `{"id":0,"format":"service-proposal/v3","compatibility":2,"provider_id":"0x55d9995cf3482ee0628fe25e3c95a95899f23cad","service_type":"scraping","location":{"continent":"EU","country":"PL","region":"Malopolskie","city":"Nowy Sacz","asn":5617,"isp":"Orange Polska Spolka Akcyjna","ip_type":"residential"},"contacts":[{"type":"nats/p2p/v1","definition":{"broker_addresses":["nats://broker.mysterium.network:4222","nats://broker.mysterium.network:4222","nats://51.15.22.197:4222","nats://51.15.23.12:4222","nats://51.15.23.14:4222","nats://51.15.23.16:4222"]}}],"access_policies":[{"id":"mysterium","source":"https://trust.mysterium.network/api/v1/access-policies/mysterium"}],"quality":{"quality":2.0250000000000004,"latency":824.898867,"bandwidth":10.275812,"uptime":24,"packetLoss":0.5}}`
def := json.RawMessage(`{
"broker_addresses": [
"nats://broker.mysterium.network:4222",
Expand Down Expand Up @@ -51,6 +52,7 @@ func TestProposal_MarshalBinary(t *testing.T) {
Latency: 824.898867,
Bandwidth: 10.275812,
Uptime: 24,
PacketLoss: 0.5,
MonitoringFailed: false,
},
}
Expand Down Expand Up @@ -97,6 +99,7 @@ func BenchmarkProposal_UnmarshalBinary(b *testing.B) {
Latency: 497.234331,
Bandwidth: 1.825416,
Uptime: 24,
PacketLoss: 0.5,
MonitoringFailed: true,
},
}
Expand Down
1 change: 1 addition & 0 deletions quality/oracleapi/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type DetailedQuality struct {
Latency float64 `json:"latency" example:"75.5"`
Uptime float64 `json:"uptime" example:"7.7"`
Bandwidth float64 `json:"bandwidth" example:"15.5"`
PacketLoss float64 `json:"packetLoss" example:"0.5"`
}

// CountryLoad represents the ratio of providers to active sessions for country.
Expand Down
Loading