Skip to content

Commit

Permalink
Merge pull request #2386 from fasaxc/race-detect-option
Browse files Browse the repository at this point in the history
Make race detector optional.  Enable by default.
  • Loading branch information
Brian-McM authored Jun 15, 2020
2 parents 22a4ef3 + f27861c commit a24d509
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ FV_NUM_BATCHES?=1
# (with FV_NUM_BATCHES=1) to check that it's not a flake.
FV_BATCHES_TO_RUN?=$(shell seq $(FV_NUM_BATCHES))
FV_SLOW_SPEC_THRESH=90
FV_RACE_DETECTOR_ENABLED?=true

# Linker flags for building Felix.
#
Expand Down Expand Up @@ -246,8 +247,14 @@ ifeq ($(ARCH),amd64)
docker tag $(BUILD_IMAGE):latest-$(ARCH) $(BUILD_IMAGE):latest
endif

image-test: image fv/Dockerfile.test.amd64 bin/pktgen bin/test-workload bin/test-connection bin/calico-felix-race-amd64 image-wgtool
docker build -t $(BUILD_IMAGE)-test:latest-$(ARCH) --build-arg QEMU_IMAGE=$(CALICO_BUILD) --file ./fv/Dockerfile.test.$(ARCH) bin;
ifeq ($(FV_RACE_DETECTOR_ENABLED),true)
FV_BINARY=calico-felix-race-amd64
else
FV_BINARY=calico-felix-amd64
endif

image-test: image fv/Dockerfile.test.amd64 bin/pktgen bin/test-workload bin/test-connection bin/$(FV_BINARY) image-wgtool
docker build -t $(BUILD_IMAGE)-test:latest-$(ARCH) --build-arg FV_BINARY=$(FV_BINARY) --file ./fv/Dockerfile.test.$(ARCH) bin;
ifeq ($(ARCH),amd64)
docker tag $(BUILD_IMAGE)-test:latest-$(ARCH) $(BUILD_IMAGE)-test:latest
endif
Expand Down Expand Up @@ -405,6 +412,7 @@ fv fv/latency.log fv/data-races.log: $(REMOTE_DEPS) image-test bin/iptables-lock
GINKGO_ARGS='$(GINKGO_ARGS)' \
GINKGO_FOCUS="$(GINKGO_FOCUS)" \
FELIX_FV_ENABLE_BPF="$(FELIX_FV_ENABLE_BPF)" \
FV_RACE_DETECTOR_ENABLED=$(FV_RACE_DETECTOR_ENABLED) \
./run-batches
@if [ -e fv/latency.log ]; then \
echo; \
Expand Down
4 changes: 3 additions & 1 deletion fv/Dockerfile.test.amd64
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,7 @@ RUN apt-get update && apt-get install -y \
ethtool \
tcpdump

ARG FV_BINARY=calico-felix-amd64

ADD test-connection test-workload pktgen /
ADD calico-felix-race-amd64 /code/calico-felix
ADD $FV_BINARY /code/calico-felix
12 changes: 9 additions & 3 deletions fv/fv_infra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,15 @@ var _ = infrastructure.DatastoreDescribe("Container self tests",
options.ExtraEnvVars["FELIX_DebugSimulateDataRace"] = "true"
})

It("should detect a race", func() {
Eventually(felixes[0].DataRaces).ShouldNot(BeEmpty())
})
if os.Getenv("FV_RACE_DETECTOR_ENABLED") == "true" {
It("should detect a race", func() {
Eventually(felixes[0].DataRaces).ShouldNot(BeEmpty())
})
} else {
It("should not detect a race because race detector is disabled", func() {
Consistently(felixes[0].DataRaces).Should(BeEmpty())
})
}
})
},
)

0 comments on commit a24d509

Please sign in to comment.