Skip to content

Commit

Permalink
Merge pull request etcd-io#14691 from serathius/lazyfs
Browse files Browse the repository at this point in the history
tests: Add support for lazyfs
  • Loading branch information
serathius authored Jul 27, 2023
2 parents 145cae3 + eb32d9c commit 9f72c64
Show file tree
Hide file tree
Showing 15 changed files with 352 additions and 114 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/robustness-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ jobs:
uses: ./.github/workflows/robustness-template.yaml
with:
etcdBranch: main
count: 100
count: 80
testTimeout: 200m
artifactName: main
main-arm64:
uses: ./.github/workflows/robustness-template-arm64.yaml
with:
etcdBranch: main
count: 100
count: 80
testTimeout: 200m
artifactName: main-arm64
runs-on: "['self-hosted', 'Linux', 'ARM64']"
release-35:
uses: ./.github/workflows/robustness-template.yaml
with:
etcdBranch: release-3.5
count: 100
count: 80
testTimeout: 200m
artifactName: release-35
release-35-arm64:
Expand All @@ -41,6 +41,6 @@ jobs:
uses: ./.github/workflows/robustness-template.yaml
with:
etcdBranch: release-3.4
count: 100
count: 80
testTimeout: 200m
artifactName: release-34
4 changes: 4 additions & 0 deletions .github/workflows/robustness-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ jobs:
set -euo pipefail
go clean -testcache
# Build LazyFS
sudo apt-get -y install cmake libfuse3-dev libfuse3-3 fuse3
make install-lazyfs
# Use --failfast to avoid overriding report generated by failed test
GO_TEST_FLAGS="-v --count ${{ inputs.count }} --timeout ${{ inputs.testTimeout }} --failfast --run TestRobustness"
case "${ETCD_BRANCH}" in
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/robustness.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ jobs:
uses: ./.github/workflows/robustness-template.yaml
with:
etcdBranch: main
count: 15
count: 12
testTimeout: 30m
artifactName: main
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,27 @@ ifeq (, $(shell which yamlfmt))
endif
yamlfmt -conf tools/.yamlfmt .

# Tools

.PHONY: install-lazyfs
install-lazyfs: bin/lazyfs

bin/lazyfs:
rm /tmp/lazyfs -rf
git clone --depth 1 --branch 0.2.0 https://github.com/dsrhaslab/lazyfs /tmp/lazyfs
cd /tmp/lazyfs/libs/libpcache; ./build.sh
cd /tmp/lazyfs/lazyfs; ./build.sh
mkdir -p ./bin
cp /tmp/lazyfs/lazyfs/build/lazyfs ./bin/lazyfs

# Cleanup

clean:
rm -f ./codecov
rm -rf ./covdir
rm -f ./bin/Dockerfile-release
rm -rf ./bin/etcd*
rm -rf ./bin/lazyfs
rm -rf ./default.etcd
rm -rf ./tests/e2e/default.etcd
rm -rf ./release
Expand Down
12 changes: 9 additions & 3 deletions tests/framework/e2e/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ type EtcdProcessClusterConfig struct {
CompactHashCheckEnabled bool
CompactHashCheckTime time.Duration
GoFailEnabled bool
LazyFSEnabled bool
CompactionBatchLimit int
CompactionSleepInterval time.Duration

Expand Down Expand Up @@ -344,6 +345,10 @@ func WithGoFailEnabled(enabled bool) EPClusterOption {
return func(c *EtcdProcessClusterConfig) { c.GoFailEnabled = enabled }
}

func WithLazyFSEnabled(enabled bool) EPClusterOption {
return func(c *EtcdProcessClusterConfig) { c.LazyFSEnabled = enabled }
}

func WithWarningUnaryRequestDuration(time time.Duration) EPClusterOption {
return func(c *EtcdProcessClusterConfig) { c.WarningUnaryRequestDuration = time }
}
Expand Down Expand Up @@ -407,7 +412,7 @@ func InitEtcdProcessCluster(t testing.TB, cfg *EtcdProcessClusterConfig) (*EtcdP

// launch etcd processes
for i := range etcdCfgs {
proc, err := NewEtcdProcess(etcdCfgs[i])
proc, err := NewEtcdProcess(t, etcdCfgs[i])
if err != nil {
epc.Close()
return nil, fmt.Errorf("cannot configure: %v", err)
Expand Down Expand Up @@ -659,6 +664,7 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i in
InitialToken: cfg.InitialToken,
GoFailPort: gofailPort,
Proxy: proxyCfg,
LazyFSEnabled: cfg.LazyFSEnabled,
}
}

Expand Down Expand Up @@ -826,7 +832,7 @@ func (epc *EtcdProcessCluster) StartNewProc(ctx context.Context, cfg *EtcdProces

// Then start process
tb.Log("start new member")
proc, err := NewEtcdProcess(serverCfg)
proc, err := NewEtcdProcess(tb, serverCfg)
if err != nil {
epc.Close()
return 0, fmt.Errorf("cannot configure: %v", err)
Expand Down Expand Up @@ -855,7 +861,7 @@ func (epc *EtcdProcessCluster) UpdateProcOptions(i int, tb testing.TB, opts ...E
}
epc.Cfg.SetInitialOrDiscovery(serverCfg, initialCluster, "new")

proc, err := NewEtcdProcess(serverCfg)
proc, err := NewEtcdProcess(tb, serverCfg)
if err != nil {
return err
}
Expand Down
6 changes: 4 additions & 2 deletions tests/framework/e2e/cluster_direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package e2e

func NewEtcdProcess(cfg *EtcdServerProcessConfig) (EtcdProcess, error) {
return NewEtcdServerProcess(cfg)
import "testing"

func NewEtcdProcess(t testing.TB, cfg *EtcdServerProcessConfig) (EtcdProcess, error) {
return NewEtcdServerProcess(t, cfg)
}
9 changes: 5 additions & 4 deletions tests/framework/e2e/cluster_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"path"
"strconv"
"strings"
"testing"

"go.uber.org/zap"

Expand All @@ -38,12 +39,12 @@ type proxyEtcdProcess struct {
proxyV3 *proxyV3Proc
}

func NewEtcdProcess(cfg *EtcdServerProcessConfig) (EtcdProcess, error) {
return NewProxyEtcdProcess(cfg)
func NewEtcdProcess(t testing.TB, cfg *EtcdServerProcessConfig) (EtcdProcess, error) {
return NewProxyEtcdProcess(t, cfg)
}

func NewProxyEtcdProcess(cfg *EtcdServerProcessConfig) (*proxyEtcdProcess, error) {
ep, err := NewEtcdServerProcess(cfg)
func NewProxyEtcdProcess(t testing.TB, cfg *EtcdServerProcessConfig) (*proxyEtcdProcess, error) {
ep, err := NewEtcdServerProcess(t, cfg)
if err != nil {
return nil, err
}
Expand Down
33 changes: 31 additions & 2 deletions tests/framework/e2e/etcd_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type EtcdProcess interface {
Config() *EtcdServerProcessConfig
PeerProxy() proxy.Server
Failpoints() *BinaryFailpoints
LazyFS() *LazyFS
Logs() LogsExpect
Kill() error
}
Expand All @@ -70,6 +71,7 @@ type EtcdServerProcess struct {
cfg *EtcdServerProcessConfig
proc *expect.ExpectProcess
proxy proxy.Server
lazyfs *LazyFS
failpoints *BinaryFailpoints
donec chan struct{} // closed when Interact() terminates
}
Expand All @@ -96,22 +98,29 @@ type EtcdServerProcessConfig struct {
InitialCluster string
GoFailPort int

Proxy *proxy.ServerConfig
LazyFSEnabled bool
Proxy *proxy.ServerConfig
}

func NewEtcdServerProcess(cfg *EtcdServerProcessConfig) (*EtcdServerProcess, error) {
func NewEtcdServerProcess(t testing.TB, cfg *EtcdServerProcessConfig) (*EtcdServerProcess, error) {
if !fileutil.Exist(cfg.ExecPath) {
return nil, fmt.Errorf("could not find etcd binary: %s", cfg.ExecPath)
}
if !cfg.KeepDataDir {
if err := os.RemoveAll(cfg.DataDirPath); err != nil {
return nil, err
}
if err := os.Mkdir(cfg.DataDirPath, 0700); err != nil {
return nil, err
}
}
ep := &EtcdServerProcess{cfg: cfg, donec: make(chan struct{})}
if cfg.GoFailPort != 0 {
ep.failpoints = &BinaryFailpoints{member: ep}
}
if cfg.LazyFSEnabled {
ep.lazyfs = newLazyFS(cfg.lg, cfg.DataDirPath, t)
}
return ep, nil
}

Expand Down Expand Up @@ -146,6 +155,14 @@ func (ep *EtcdServerProcess) Start(ctx context.Context) error {
return err
}
}
if ep.lazyfs != nil {
ep.cfg.lg.Info("starting lazyfs...", zap.String("name", ep.cfg.Name))
err := ep.lazyfs.Start(ctx)
if err != nil {
return err
}
}

ep.cfg.lg.Info("starting server...", zap.String("name", ep.cfg.Name))
proc, err := SpawnCmdWithLogger(ep.cfg.lg, append([]string{ep.cfg.ExecPath}, ep.cfg.Args...), ep.cfg.EnvVars, ep.cfg.Name)
if err != nil {
Expand Down Expand Up @@ -205,6 +222,14 @@ func (ep *EtcdServerProcess) Stop() (err error) {
return err
}
}
if ep.lazyfs != nil {
ep.cfg.lg.Info("stopping lazyfs...", zap.String("name", ep.cfg.Name))
err = ep.lazyfs.Stop()
ep.lazyfs = nil
if err != nil {
return err
}
}
return nil
}

Expand Down Expand Up @@ -298,6 +323,10 @@ func (ep *EtcdServerProcess) PeerProxy() proxy.Server {
return ep.proxy
}

func (ep *EtcdServerProcess) LazyFS() *LazyFS {
return ep.lazyfs
}

func (ep *EtcdServerProcess) Failpoints() *BinaryFailpoints {
return ep.failpoints
}
Expand Down
13 changes: 13 additions & 0 deletions tests/framework/e2e/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ type binPath struct {
EtcdLastRelease string
Etcdctl string
Etcdutl string
LazyFS string
}

func (bp *binPath) LazyFSAvailable() bool {
_, err := os.Stat(bp.LazyFS)
if err != nil {
if !os.IsNotExist(err) {
panic(err)
}
return false
}
return true
}

func InitFlags() {
Expand All @@ -65,6 +77,7 @@ func InitFlags() {
EtcdLastRelease: *binDir + "/etcd-last-release",
Etcdctl: *binDir + "/etcdctl",
Etcdutl: *binDir + "/etcdutl",
LazyFS: *binDir + "/lazyfs",
}
CertPath = CertDir + "/server.crt"
PrivateKeyPath = CertDir + "/server.key.insecure"
Expand Down
Loading

0 comments on commit 9f72c64

Please sign in to comment.