mirror of
https://github.com/tendermint/tendermint.git
synced 2026-02-03 10:32:05 +00:00
* e2e: Extract Docker-specific functionality Extract Docker-specific functionality and put it behind an interface that should hopefully, without too much modification, allow us to implement a Digital Ocean-based infrastructure provider. Signed-off-by: Thane Thomson <connect@thanethomson.com> * Thread contexts through all potentially long-running functions Signed-off-by: Thane Thomson <connect@thanethomson.com> * Drop the "API" from interface/struct/var naming Signed-off-by: Thane Thomson <connect@thanethomson.com> * Simplify function returns Signed-off-by: Thane Thomson <connect@thanethomson.com> * Rename GenerateConfig to Setup to make it more generic Signed-off-by: Thane Thomson <connect@thanethomson.com> * Consolidate all infra functions into a single interface Signed-off-by: Thane Thomson <connect@thanethomson.com> * Localize linter directives Signed-off-by: Thane Thomson <connect@thanethomson.com> * Look up and use complete node in ShowNodeLogs and TailNodeLogs calls Signed-off-by: Thane Thomson <connect@thanethomson.com> * Restructure infra provider API into a separate package Signed-off-by: Thane Thomson <connect@thanethomson.com> * Rename interface again Signed-off-by: Thane Thomson <connect@thanethomson.com> * Rename exec functions for readability Signed-off-by: Thane Thomson <connect@thanethomson.com> * Relocate staticcheck lint directive Signed-off-by: Thane Thomson <connect@thanethomson.com> * Remove staticcheck lint directive Signed-off-by: Thane Thomson <connect@thanethomson.com> * Make testnet infra struct private Signed-off-by: Thane Thomson <connect@thanethomson.com> * Only pass testnetDir to Cleanup function Signed-off-by: Thane Thomson <connect@thanethomson.com>
70 lines
1.6 KiB
Go
70 lines
1.6 KiB
Go
package docker
|
|
|
|
import (
|
|
"bytes"
|
|
"text/template"
|
|
|
|
e2e "github.com/tendermint/tendermint/test/e2e/pkg"
|
|
)
|
|
|
|
// makeDockerCompose generates a Docker Compose config for a testnet.
|
|
func makeDockerCompose(testnet *e2e.Testnet) ([]byte, error) {
|
|
// Must use version 2 Docker Compose format, to support IPv6.
|
|
tmpl, err := template.New("docker-compose").Funcs(template.FuncMap{
|
|
"addUint32": func(x, y uint32) uint32 {
|
|
return x + y
|
|
},
|
|
"isBuiltin": func(protocol e2e.Protocol, mode e2e.Mode) bool {
|
|
return mode == e2e.ModeLight || protocol == e2e.ProtocolBuiltin
|
|
},
|
|
}).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
|
|
{{- if isBuiltin $.ABCIProtocol .Mode }}
|
|
entrypoint: /usr/bin/entrypoint-builtin
|
|
{{- else if .LogLevel }}
|
|
command: start --log-level {{ .LogLevel }}
|
|
{{- end }}
|
|
init: true
|
|
ports:
|
|
- 26656
|
|
- {{ if .ProxyPort }}{{ addUint32 .ProxyPort 1000 }}:{{ end }}26660
|
|
- {{ 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
|
|
}
|