Files
tendermint/test/e2e/pkg/infra/docker/docker.go
Thane Thomson 6878b38812 abci: Adapt unsynchronized local client to replicate remote client concurrency (#9830)
* Revert "abci: Add unsynchronized local client (#9660)"

This reverts commit 45071d1f23.

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* proxy: Add unsync local client creator

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* e2e: Extend tests

Extend the E2E tests to randomly choose between the sync (default) and
unsync (new) local client creator.

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* abci: Remove redundant interface constraint

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* abci: Remove irrelevant doc comment

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* proxy: Remove backticks in doc comments

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* e2e: Remove unnecessary gap between doc comment and struct

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Add pending changelog entry

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* e2e: Expand on BuiltinProxyMode param docstring

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Remove builtin proxy mode config option from CI test

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* e2e: Make builtin proxy mode option testnet-wide

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* e2e: Embed sync/unsync notion in node protocol

The approach of randomly generating the proxy mode across testnets
resulted in a totally uneven ratio of sync to unsync modes for all
testnets that happened to have a protocol of "builtin".

This commit adapts the E2E tests to have a new ABCI protocol option:
"builtin_unsync". This results in a better spread of sync/unsync choices
for generated testnets.

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* e2e: Remove unused type

Signed-off-by: Thane Thomson <connect@thanethomson.com>

Signed-off-by: Thane Thomson <connect@thanethomson.com>
2022-12-16 10:19:02 -05:00

89 lines
2.0 KiB
Go

package docker
import (
"bytes"
"os"
"path/filepath"
"text/template"
e2e "github.com/tendermint/tendermint/test/e2e/pkg"
"github.com/tendermint/tendermint/test/e2e/pkg/infra"
)
var _ infra.Provider = &Provider{}
// Provider implements a docker-compose backed infrastructure provider.
type Provider struct {
Testnet *e2e.Testnet
}
// Setup generates the docker-compose file and write it to disk, erroring if
// any of these operations fail.
func (p *Provider) Setup() error {
compose, err := dockerComposeBytes(p.Testnet)
if err != nil {
return err
}
//nolint: gosec
// G306: Expect WriteFile permissions to be 0600 or less
err = os.WriteFile(filepath.Join(p.Testnet.Dir, "docker-compose.yml"), compose, 0o644)
if err != nil {
return err
}
return nil
}
// dockerComposeBytes generates a Docker Compose config file for a testnet and returns the
// file as bytes to be written out to disk.
func dockerComposeBytes(testnet *e2e.Testnet) ([]byte, error) {
// Must use version 2 Docker Compose format, to support IPv6.
tmpl, err := template.New("docker-compose").Parse(`version: '2.4'
networks:
{{ .Name }}:
labels:
e2e: true
driver: bridge
{{- if .IPv6 }}
enable_ipv6: true
{{- end }}
ipam:
driver: default
config:
- subnet: {{ .IP }}
services:
{{- range .Nodes }}
{{ .Name }}:
labels:
e2e: true
container_name: {{ .Name }}
image: tendermint/e2e-node:{{ .Version }}
{{- if eq .ABCIProtocol "builtin" }}
entrypoint: /usr/bin/entrypoint-builtin
{{- else }}{{ if eq .ABCIProtocol "builtin_unsync" }}
entrypoint: /usr/bin/entrypoint-builtin
{{- end }}
{{- end }}
init: true
ports:
- 26656
- {{ if .ProxyPort }}{{ .ProxyPort }}:{{ end }}26657
- 6060
volumes:
- ./{{ .Name }}:/tendermint
networks:
{{ $.Name }}:
ipv{{ if $.IPv6 }}6{{ else }}4{{ end}}_address: {{ .IP }}
{{end}}`)
if err != nil {
return nil, err
}
var buf bytes.Buffer
err = tmpl.Execute(&buf, testnet)
if err != nil {
return nil, err
}
return buf.Bytes(), nil
}