Skip to content

Commit

Permalink
Merge pull request #26 from iovisor/feature/integration-tests
Browse files Browse the repository at this point in the history
feat(integration): Integration tests skeleton
  • Loading branch information
fntlnz authored Jan 9, 2019
2 parents 5e2e080 + 229f303 commit 933a110
Show file tree
Hide file tree
Showing 908 changed files with 130,693 additions and 6,283 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ services:
script:
- make test
- make _output/bin/kubectl-trace
- ./hack/release-image.sh
- ./hack/ci-build-image.sh
- make integration
after_success:
- ./hack/ci-release-image.sh
52 changes: 0 additions & 52 deletions Dockerfile.bpftrace

This file was deleted.

35 changes: 35 additions & 0 deletions Dockerfile.bpftracebase
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
ARG bpftracesha

FROM alpine:3.8 as builder
ENV STATIC_LINKING=ON
ENV RUN_TESTS=0
RUN apk add --update \
bison \
build-base \
clang-dev \
clang-static \
cmake \
elfutils-dev \
flex-dev \
git \
linux-headers \
llvm5-dev \
llvm5-static \
zlib-dev

# Put LLVM directories where CMake expects them to be
RUN ln -s /usr/lib/cmake/llvm5 /usr/lib/cmake/llvm
RUN ln -s /usr/include/llvm5/llvm /usr/include/llvm
RUN ln -s /usr/include/llvm5/llvm-c /usr/include/llvm-c

WORKDIR /

RUN git clone https://github.com/iovisor/bpftrace.git /bpftrace

WORKDIR /bpftrace

#RUN git checkout ${bpftracesha}

WORKDIR /bpftrace/docker

RUN sh build.sh /bpftrace/build-release Release
21 changes: 21 additions & 0 deletions Dockerfile.tracerunner
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ARG bpftracesha

FROM quay.io/fntlnz/kubectl-trace-bpftrace-base:${bpftracesha} as bpftrace
FROM golang:1.11.4-alpine3.8 as gobuilder

RUN apk update
RUN apk add make bash git

ADD . /go/src/github.com/iovisor/kubectl-trace
WORKDIR /go/src/github.com/iovisor/kubectl-trace

RUN make _output/bin/trace-runner

FROM alpine:3.8

RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
COPY --from=bpftrace /bpftrace/build-release/src/bpftrace /bin/bpftrace
COPY --from=gobuilder /go/src/github.com/iovisor/kubectl-trace/_output/bin/trace-runner /bin/trace-runner

ENTRYPOINT ["/bin/trace-runner"]

35 changes: 25 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ GIT_COMMIT := $(if $(shell git status --porcelain --untracked-files=no),${COMMIT
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
GIT_BRANCH_CLEAN := $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g")

IMAGE_TRACERUNNER_BRANCH := quay.io/fntlnz/kubectl-trace-bpftrace:$(GIT_BRANCH_CLEAN)
IMAGE_TRACERUNNER_COMMIT := quay.io/fntlnz/kubectl-trace-bpftrace:$(GIT_COMMIT)
IMAGE_TRACERUNNER_LATEST := quay.io/fntlnz/kubectl-trace-bpftrace:latest

IMAGE_BPFTRACE_BRANCH := quay.io/fntlnz/kubectl-trace-bpftrace:$(GIT_BRANCH_CLEAN)
IMAGE_BPFTRACE_COMMIT := quay.io/fntlnz/kubectl-trace-bpftrace:$(GIT_COMMIT)
IMAGE_BPFTRACE_LATEST := quay.io/fntlnz/kubectl-trace-bpftrace:latest
BPFTRACESHA ?= 2ae2a53f62622631a304def6c193680e603994e3
IMAGE_BPFTRACE_BASE := quay.io/fntlnz/kubectl-trace-bpftrace-base:$(BPFTRACESHA)

IMAGE_BUILD_FLAGS ?= "--no-cache"

LDFLAGS := -ldflags '-X github.com/iovisor/kubectl-trace/pkg/version.buildTime=$(shell date +%s) -X github.com/iovisor/kubectl-trace/pkg/version.gitCommit=${GIT_COMMIT}'
TESTPACKAGES := $(shell go list ./... | grep -v github.com/iovisor/kubectl-trace/integration)

kubectl_trace ?= _output/bin/kubectl-trace
trace_runner ?= _output/bin/trace-runner
Expand All @@ -35,19 +38,31 @@ clean:

.PHONY: image/build
image/build:
$(DOCKER) build $(IMAGE_BUILD_FLAGS) -t $(IMAGE_BPFTRACE_BRANCH) -f Dockerfile.bpftrace .
$(DOCKER) tag $(IMAGE_BPFTRACE_BRANCH) $(IMAGE_BPFTRACE_COMMIT)
$(DOCKER) build --build-arg bpftracesha=$(BPFTRACESHA) $(IMAGE_BUILD_FLAGS) -t $(IMAGE_TRACERUNNER_BRANCH) -f Dockerfile.tracerunner .
$(DOCKER) tag $(IMAGE_TRACERUNNER_BRANCH) $(IMAGE_TRACERUNNER_COMMIT)

.PHONY: image/push
image/push:
$(DOCKER) push $(IMAGE_BPFTRACE_BRANCH)
$(DOCKER) push $(IMAGE_BPFTRACE_COMMIT)
$(DOCKER) push $(IMAGE_TRACERUNNER_BRANCH)
$(DOCKER) push $(IMAGE_TRACERUNNER_COMMIT)

.PHONY: image/latest
image/latest:
$(DOCKER) tag $(IMAGE_BPFTRACE_COMMIT) $(IMAGE_BPFTRACE_LATEST)
$(DOCKER) push $(IMAGE_BPFTRACE_LATEST)
$(DOCKER) tag $(IMAGE_TRACERUNNER_COMMIT) $(IMAGE_TRACERUNNER_LATEST)
$(DOCKER) push $(IMAGE_TRACERUNNER_LATEST)

.PHONY: test
test:
$(GO) test -v -race ./...
$(GO) test -v -race $(TESTPACKAGES)

.PHONY: integration
integration:
TEST_KUBECTLTRACE_BINARY=$(shell pwd)/$(kubectl_trace) $(GO) test ${LDFLAGS} -v ./integration/...

.PHONY: bpftraceimage/build
bpftraceimage/build:
$(DOCKER) build --build-arg bpftracesha=$(BPFTRACESHA) $(IMAGE_BUILD_FLAGS) -t $(IMAGE_BPFTRACE_BASE) -f Dockerfile.bpftracebase .

.PHONY: bpftraceimage/push
bpftraceimage/push:
$(DOCKER) push $(IMAGE_BPFTRACE_BASE)
56 changes: 32 additions & 24 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
module github.com/iovisor/kubectl-trace

replace github.com/docker/docker v1.13.1 => github.com/docker/docker v0.7.3-0.20190105115016-2ee53a42db81

require (
cloud.google.com/go v0.34.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
github.com/docker/distribution v2.6.2+incompatible // indirect
github.com/docker/docker v0.7.3-0.20181124105010-0b7cb16dde4a // indirect
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96 // indirect
github.com/docker/distribution v2.7.0+incompatible // indirect
github.com/docker/docker v1.13.1 // indirect
github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c // indirect
github.com/elazarl/goproxy v0.0.0-20181111060418-2ce16c963a8a // indirect
github.com/emicklei/go-restful v2.8.0+incompatible // indirect
github.com/evanphx/json-patch v4.1.0+incompatible // indirect
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
github.com/fntlnz/mountinfo v0.0.0-20171106231217-40cb42681fad
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-openapi/spec v0.17.2 // indirect
github.com/gogo/protobuf v1.1.1 // indirect
github.com/go-check/check v0.0.0-20180628173108-788fd7840127
github.com/go-openapi/spec v0.18.0 // indirect
github.com/gogo/protobuf v1.2.0 // indirect
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c // indirect
github.com/google/go-cmp v0.2.0 // indirect
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect
github.com/googleapis/gnostic v0.2.0 // indirect
github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f // indirect
github.com/hashicorp/go-getter v0.0.0-20181213035916-be39683deade // indirect
github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c // indirect
github.com/imdario/mergo v0.3.6 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/json-iterator/go v1.1.5 // indirect
Expand All @@ -28,32 +34,34 @@ require (
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/onsi/ginkgo v1.7.0 // indirect
github.com/onsi/gomega v1.4.3 // indirect
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
github.com/pborman/uuid v1.2.0 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.8.0 // indirect
github.com/sirupsen/logrus v1.2.0 // indirect
github.com/pkg/errors v0.8.1 // indirect
github.com/sirupsen/logrus v1.3.0 // indirect
github.com/spf13/cobra v0.0.3
github.com/spf13/pflag v1.0.3
github.com/stevvooe/resumable v0.0.0-20180830230917-22b14a53ba50 // indirect
golang.org/x/crypto v0.0.0-20181112202954-3d3f9f413869 // indirect
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc // indirect
golang.org/x/oauth2 v0.0.0-20181120190819-8f65e3013eba // indirect
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f // indirect
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b // indirect
golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc // indirect
golang.org/x/net v0.0.0-20181220203305-927f97764cc3 // indirect
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890 // indirect
golang.org/x/sys v0.0.0-20190105165716-badf5585203e // indirect
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c // indirect
google.golang.org/appengine v1.3.0 // indirect
google.golang.org/appengine v1.4.0 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gotest.tools v2.2.0+incompatible // indirect
k8s.io/api v0.0.0-20181121071145-b7bd5f2d334c
k8s.io/apiextensions-apiserver v0.0.0-20181121072900-e8a638592964 // indirect
k8s.io/apimachinery v0.0.0-20180913025736-6dd46049f395
k8s.io/apiserver v0.0.0-20181121231732-e3c8fa95bba5 // indirect
k8s.io/cli-runtime v0.0.0-20181121073402-2f0d1d0a58f2
k8s.io/client-go v9.0.0+incompatible
gopkg.in/yaml.v2 v2.2.2 // indirect
gotest.tools v2.2.0+incompatible
k8s.io/api v0.0.0-20181221193117-173ce66c1e39
k8s.io/apiextensions-apiserver v0.0.0-20190103235604-e7617803aceb // indirect
k8s.io/apimachinery v0.0.0-20190104073114-849b284f3b75
k8s.io/apiserver v0.0.0-20190105074621-3b195c470123 // indirect
k8s.io/cli-runtime v0.0.0-20181221202950-8abb1aeb8307
k8s.io/client-go v10.0.0+incompatible
k8s.io/klog v0.1.0 // indirect
k8s.io/kube-openapi v0.0.0-20181114233023-0317810137be // indirect
k8s.io/kubernetes v1.12.3
k8s.io/utils v0.0.0-20181115163542-0d26856f57b3 // indirect
k8s.io/kube-openapi v0.0.0-20181025202442-3a9b63ab1e39 // indirect
k8s.io/kubernetes v1.12.4
k8s.io/utils v0.0.0-20181221173059-8a16e7dd8fb6 // indirect
sigs.k8s.io/kind v0.0.0-20190102225038-c03d6716c38b
sigs.k8s.io/kustomize v1.0.10-0.20181026181014-6a917c5f363c // indirect
sigs.k8s.io/yaml v1.1.0 // indirect
)
Loading

0 comments on commit 933a110

Please sign in to comment.