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

e2e: Implement latency emulation for DigitalOcean #1587

Merged
merged 53 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
77c838d
e2e: added latency-setter script
cason Oct 29, 2023
a6802cc
e2e: removed 'sudo' from latency-setter script
cason Oct 29, 2023
1f6986f
e2e: table of latencies between AWS zones
cason Oct 29, 2023
5d94d12
e2e: improved latency-setter script logging
cason Oct 29, 2023
10d3e67
e2e: added packages required by latency-setter script
cason Oct 29, 2023
b738265
Add zone to node manifest (only handled by docker)
hvanz Oct 29, 2023
f68c44c
Merge branch 'cason/e2e-latency-setter' into e2e-latencies
hvanz Oct 29, 2023
2d992ec
Zone as string instead of int + SetLatency for docker
hvanz Oct 30, 2023
7e685ed
Add aws-latencies.csv
hvanz Oct 30, 2023
b0721db
e2e: latency-setter script returns error code
cason Oct 30, 2023
9cf5c9a
e2e: fixing docker command to set latencies
cason Oct 30, 2023
12bb319
e2e: better logging for latency-setter script
cason Oct 30, 2023
a4d704e
e2e: verbose output for latency setter in docker
cason Oct 30, 2023
2f43dde
e2e: only runs set latency for nodes with a zone set
cason Oct 30, 2023
8f23d53
e2e: moved aws-latencies.csv to scripts/ dir
cason Oct 30, 2023
1ad7a6c
e2e: latency setter script included in docker image
cason Oct 30, 2023
b1d7580
e2e: latency setter infra moved to latency/ dir
cason Oct 30, 2023
6ab42c6
e2e: fixing aws-latencies.csv table file
cason Oct 30, 2023
493d124
e2e: latency setter not supported by Digital Ocean
cason Oct 30, 2023
7bb7c9e
e2e: minor fixes in comments
cason Oct 31, 2023
c18e541
e2e: fix lint errors and warnings
cason Oct 31, 2023
4df2a9e
Merge branch 'main' into e2e-latencies
cason Oct 31, 2023
948b094
e2e: ignore zone validation when zone is unset
cason Oct 31, 2023
dadb01a
e2e: fixing introduced bug on runner
cason Oct 31, 2023
197b749
Set latency after start log message; fix start message
hvanz Nov 9, 2023
306ed66
Refactor python script
hvanz Nov 9, 2023
c179e97
Update test/e2e/pkg/infra/digitalocean/digitalocean.go
hvanz Nov 9, 2023
91c95ee
Rename error
hvanz Nov 9, 2023
a4ca1ae
Rename error (2)
hvanz Nov 9, 2023
2312066
Rename error (3)
hvanz Nov 9, 2023
9b1fcbb
Add support for digitalocean
hvanz Oct 31, 2023
2e32bea
Provider method IPZonesFilePath
hvanz Nov 3, 2023
595bd9b
Fix path to remote zones.csv
hvanz Nov 3, 2023
5a68299
Check error on GenerateIPZonesTable (docker)
hvanz Nov 9, 2023
c3361ad
Add comment
hvanz Nov 10, 2023
eaf715e
Apply suggestions from code review
hvanz Nov 21, 2023
57239b5
Merge branch 'main' into e2e-latencies-digitalocean
hvanz Nov 23, 2023
68c2096
Merge branch 'main' into e2e-latencies-digitalocean
hvanz Nov 23, 2023
e123b8d
Fix SetLatency function
hvanz Nov 27, 2023
c03f02b
Merge branch 'main' into e2e-latencies
hvanz Nov 27, 2023
f087dc1
Merge branch 'e2e-latencies' into e2e-latencies-digitalocean
hvanz Nov 27, 2023
08d1e11
fix merge
hvanz Nov 27, 2023
4cc525f
Add default zone: allow either all nodes without zone, or all nodes w…
hvanz Nov 27, 2023
12a03fc
Add changelog
hvanz Nov 27, 2023
b8e3205
Merge branch 'e2e-latencies' into e2e-latencies-digitalocean
hvanz Nov 27, 2023
adbba67
Fix SetLatency function
hvanz Nov 27, 2023
e097b84
Use internal IPs for docker and external for DO
hvanz Nov 27, 2023
19a848a
Merge branch 'main' into e2e-latencies-digitalocean
hvanz Nov 29, 2023
a3e55d6
Remove latency directory in old location
hvanz Nov 29, 2023
1d3579b
Update changelog
hvanz Nov 29, 2023
fc5cb6b
Comments
hvanz Nov 29, 2023
c299a30
Merge branch 'main' into e2e-latencies-digitalocean
hvanz Dec 14, 2023
167c8f9
Apply suggestions from code review (docstrings)
hvanz Dec 14, 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
Prev Previous commit
Next Next commit
Merge branch 'main' into e2e-latencies-digitalocean
  • Loading branch information
hvanz committed Nov 29, 2023
commit 19a848aece8c332562f109f7d8fa91ea3c5cd9e8
4 changes: 2 additions & 2 deletions test/e2e/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ RUN apt-get -qq install -y libleveldb-dev librocksdb-dev >/dev/null
# For the latency-setter script
RUN apt-get -qq install -y iputils-ping iproute2 python3-netifaces >/dev/null
RUN mkdir -p /scripts
COPY test/e2e/latency/aws-latencies.csv /scripts/
COPY test/e2e/latency/latency-setter.py /scripts/
COPY test/e2e/pkg/latency/aws-latencies.csv /scripts/
COPY test/e2e/pkg/latency/latency-setter.py /scripts/

# Set up build directory /src/cometbft
ENV COMETBFT_BUILD_OPTIONS badgerdb,boltdb,cleveldb,rocksdb
Expand Down
18 changes: 0 additions & 18 deletions test/e2e/pkg/infra/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,24 +181,6 @@ services:
return buf.Bytes(), nil
}

func zonesTableBytes(nodes []*e2e.Node) ([]byte, error) {
tmpl, err := template.New("zones").Parse(`Node,IP,Zone
{{- range . }}
{{- if .Zone }}
{{ .Name }},{{ .InternalIP }},{{ .Zone }}
{{- end }}
{{- end }}`)
if err != nil {
return nil, err
}
var buf bytes.Buffer
err = tmpl.Execute(&buf, nodes)
if err != nil {
return nil, err
}
return buf.Bytes(), nil
}

// ExecCompose runs a Docker Compose command for a testnet.
func ExecCompose(ctx context.Context, dir string, args ...string) error {
return exec.Command(ctx, append(
Expand Down
32 changes: 11 additions & 21 deletions test/e2e/pkg/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"io"
"io/fs"
"math/rand"
"net"
"os"
Expand Down Expand Up @@ -384,10 +383,8 @@ func (t Testnet) Validate() error {
}

func (t Testnet) validateZones(nodes []*Node) error {
latencyFile := filepath.Join(t.Dir, "../../latency/aws-latencies.csv")
zoneMatrix, err := loadZoneLatenciesMatrix(latencyFile)
fileNotFoundErr := errors.Is(err, fs.ErrNotExist)
if !fileNotFoundErr && err != nil {
zoneMatrix, err := loadZoneLatenciesMatrix()
if err != nil {
return err
}

Expand All @@ -404,13 +401,9 @@ func (t Testnet) validateZones(nodes []*Node) error {
nodesWithoutZone = append(nodesWithoutZone, node.Name)
continue
}
if fileNotFoundErr {
return fmt.Errorf("node %s has zone set to %s but zone-latencies matrix file was not found in %s",
node.Name, string(node.Zone), latencyFile)
}
if !slices.Contains(zones, node.Zone) {
return fmt.Errorf("invalid zone %s for node %s, not present in zone-latencies matrix file %s",
string(node.Zone), node.Name, latencyFile)
return fmt.Errorf("invalid zone %s for node %s, not present in zone-latencies matrix",
string(node.Zone), node.Name)
}
}

Expand Down Expand Up @@ -732,8 +725,11 @@ func (g *ipGenerator) Next() net.IP {
return ip
}

func loadZoneLatenciesMatrix(filePath string) (map[ZoneID][]uint32, error) {
records, err := readCsvFile(filePath)
//go:embed latency/aws-latencies.csv
var awsLatenciesMatrixCsvContent string

func loadZoneLatenciesMatrix() (map[ZoneID][]uint32, error) {
records, err := parseCsv(awsLatenciesMatrixCsvContent)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -762,14 +758,8 @@ func (e ErrInvalidZoneID) Error() string {
return fmt.Sprintf("invalid zone id (%s): %v", e.ZoneID, e.Err)
}

func readCsvFile(filePath string) ([][]string, error) {
f, err := os.Open(filePath)
if err != nil {
return nil, err
}
defer f.Close()

csvReader := csv.NewReader(f)
func parseCsv(csvString string) ([][]string, error) {
csvReader := csv.NewReader(strings.NewReader(csvString))
csvReader.Comment = '#'
records, err := csvReader.ReadAll()
if err != nil {
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.