Skip to content

Allow testing multiple etcd releases #20013

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

Merged
merged 1 commit into from
May 27, 2025
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
7 changes: 6 additions & 1 deletion .github/workflows/antithesis-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ on:
required: true
type: string
default: "etcd nightly antithesis run"
etcd_ref:
description: 'etcd version to build etcd-server from'
required: false
type: string
default: 'release-3.5'
email:
description: 'Additional email notification recipient (separate with ;)'
required: true
Expand Down Expand Up @@ -85,7 +90,7 @@ jobs:
- name: Build and push etcd image
working-directory: ./tests/antithesis
run: |
make antithesis-build-etcd-image
make antithesis-build-etcd-image-${{ inputs.etcd_ref }}
export TAG="${{ env.REGISTRY }}/${{ env.REPOSITORY }}/etcd-server:latest"
docker tag etcd-server:latest $TAG
docker push $TAG
Expand Down
71 changes: 62 additions & 9 deletions tests/antithesis/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,51 @@ REPOSITORY_ROOT := $(shell git rev-parse --show-toplevel)
USER_ID := $(shell id -u)
GROUP_ID := $(shell id -g)
ARCH ?= $(shell go env GOARCH)
REF = HEAD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a huge fun of building from HEAD, what about unstaged changes? In robustness tests we have separate target for local running on local code and branch:

Local run assumes that etcd is already build and available in ./bin directory. User just need to call make build before.

etcd/Makefile

Lines 64 to 66 in b7db556

.PHONY: test-robustness
test-robustness:
PASSES="robustness" ./scripts/test.sh $(GO_TEST_FLAGS)

For building from branches the build and run is combined.

.PHONY: test-robustness-main
test-robustness-main: /tmp/etcd-main-failpoints/bin /tmp/etcd-release-3.6-failpoints/bin
GO_TEST_FLAGS="$${GO_TEST_FLAGS} --bin-dir=/tmp/etcd-main-failpoints/bin --bin-last-release=/tmp/etcd-release-3.6-failpoints/bin/etcd" $(TOPLEVEL_MAKE) test-robustness
.PHONY: test-robustness-release-3.6
test-robustness-release-3.6: /tmp/etcd-release-3.6-failpoints/bin /tmp/etcd-release-3.5-failpoints/bin
GO_TEST_FLAGS="$${GO_TEST_FLAGS} --bin-dir=/tmp/etcd-release-3.6-failpoints/bin --bin-last-release=/tmp/etcd-release-3.5-failpoints/bin/etcd" $(TOPLEVEL_MAKE) test-robustness
.PHONY: test-robustness-release-3.5
test-robustness-release-3.5: /tmp/etcd-release-3.5-failpoints/bin /tmp/etcd-release-3.4-failpoints/bin
GO_TEST_FLAGS="$${GO_TEST_FLAGS} --bin-dir=/tmp/etcd-release-3.5-failpoints/bin --bin-last-release=/tmp/etcd-release-3.4-failpoints/bin/etcd" $(TOPLEVEL_MAKE) test-robustness
.PHONY: test-robustness-release-3.4
test-robustness-release-3.4: /tmp/etcd-release-3.4-failpoints/bin
GO_TEST_FLAGS="$${GO_TEST_FLAGS} --bin-dir=/tmp/etcd-release-3.4-failpoints/bin" $(TOPLEVEL_MAKE) test-robustness

Copy link
Member Author

@nwnt nwnt May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about the latest one I just pushed? I added a new target called antithesis-build-etcd-image-local which will build with unstaged and untracked local changes. This will allow building the current branch without having to stash the changes.

This involved a bit of refactoring, but I tested them all this time.

DOCKERFILE = ./Dockerfile
REMOTE = origin

.PHONY: antithesis-build-client-docker-image
antithesis-build-client-docker-image:
docker build --build-arg GO_VERSION=$(shell cat $(REPOSITORY_ROOT)/.go-version) -f $(REPOSITORY_ROOT)/tests/antithesis/test-template/Dockerfile $(REPOSITORY_ROOT) -t etcd-client:latest

.PHONY: antithesis-build-etcd-image
antithesis-build-etcd-image:
git fetch origin release-3.5
git worktree remove -f /tmp/etcd3.5 || true
git worktree add /tmp/etcd3.5 origin/release-3.5
cd /tmp/etcd3.5 && make build
cd /tmp/etcd3.5 && cp ./Dockerfile-release.$(ARCH) ./bin/Dockerfile
cd /tmp/etcd3.5 && docker build \
.PHONY: antithesis-build-etcd-create-worktree
antithesis-build-etcd-create-worktree:
git fetch $(REMOTE) $(REF)
git worktree remove -f /tmp/etcd$(REF) || true
git worktree add /tmp/etcd$(REF) $(REMOTE)/$(REF)
$(eval BUILDDIR=/tmp/etcd$(REF))

.PHONY: antithesis-build-etcd
antithesis-build-etcd:
cd $(BUILDDIR) && make build
cd $(BUILDDIR) && cp $(DOCKERFILE) ./bin/Dockerfile
cd $(BUILDDIR) && docker build \
--tag etcd-server:latest \
./bin
git worktree remove -f /tmp/etcd3.5
rm $(BUILDDIR)/bin/Dockerfile

.PHONY: antithesis-build-etcd-remove-worktree
antithesis-build-etcd-remove-worktree:
git worktree remove -f $(BUILDDIR)

.PHONY: antithesis-build-etcd-image
antithesis-build-etcd-image: antithesis-build-etcd-create-worktree antithesis-build-etcd antithesis-build-etcd-remove-worktree

.PHONY: antithesis-build-etcd-image-release-3.4
antithesis-build-etcd-image-release-3.4: set-version-3.4 antithesis-build-etcd-image

.PHONY: antithesis-build-etcd-image-release-3.5
antithesis-build-etcd-image-release-3.5: set-version-3.5 antithesis-build-etcd-image

.PHONY: antithesis-build-etcd-image-release-3.6
antithesis-build-etcd-image-release-3.6: set-version-3.6 antithesis-build-etcd-image

.PHONY: antithesis-build-etcd-image-release-main
antithesis-build-etcd-image-release-main: set-version-main antithesis-build-etcd-image

.PHONY: antithesis-build-etcd-image-local
antithesis-build-etcd-image-local: set-local antithesis-build-etcd

.PHONY: antithesis-docker-compose-up
antithesis-docker-compose-up:
Expand All @@ -43,3 +72,27 @@ antithesis-run-local-validation:
antithesis-clean:
export USER_ID=$(USER_ID) && export GROUP_ID=$(GROUP_ID) && docker-compose down
rm -rf /tmp/etcddata0 /tmp/etcddata1 /tmp/etcddata2 /tmp/etcdreport

.PHONY: set-version-3.4
set-version-3.4:
$(eval REF=release-3.4)
$(eval DOCKERFILE=./Dockerfile-release)

.PHONY: set-version-3.5
set-version-3.5:
$(eval REF=release-3.5)
$(eval DOCKERFILE=./Dockerfile-release.amd64)

.PHONY: set-version-3.6
set-version-3.6:
$(eval REF=release-3.6)
$(eval DOCKERFILE=./Dockerfile)

.PHONY: set-version-main
set-version-main:
$(eval REF=main)
$(eval DOCKERFILE=./Dockerfile)

.PHONY: set-local
set-local:
$(eval BUILDDIR=$(REPOSITORY_ROOT))
8 changes: 8 additions & 0 deletions tests/antithesis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ make antithesis-build-client-docker-image
make antithesis-build-etcd-image
```

Both commands build etcd-server and etcd-client from the current branch. To build a different version of etcd you can use:

```bash
make antithesis-build-etcd-image REF=${GIT_REF}
```

### 2. (Optional) Check the Image Locally

You can verify your new image is built:
Expand All @@ -33,6 +39,8 @@ Run the following command from the root directory for Antithesis tests (`tests/a
make antithesis-docker-compose-up
```

The command uses the etcd client and server images built from step 1.

The client will continuously check the health of the etcd nodes and print logs similar to:

```
Expand Down