Skip to content

Commit

Permalink
Merge pull request #5300 from caseydavenport/casey-add-more-tests
Browse files Browse the repository at this point in the history
Run tests for calicoctl, pod2daemon, and app-policy
  • Loading branch information
caseydavenport authored Dec 18, 2021
2 parents 206bbda + f056833 commit a9be80e
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 37 deletions.
78 changes: 57 additions & 21 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ global_job_config:
- name: docker-hub
prologue:
commands:
- checkout
# Semaphore is doing shallow clone on a commit without tags.
# unshallow it for GIT_VERSION:=$(shell git describe --tags --dirty --always)
- git fetch --unshallow
# Semaphore mounts a copy-on-write FS as /var/lib/docker in order to provide a pre-loaded cache of
# some images. However, the cache is not useful to us and the copy-on-write FS is a big problem given
# how much we churn docker containers during the build. Disable it.
Expand All @@ -78,7 +82,6 @@ blocks:
task:
prologue:
commands:
- checkout
- cd api
jobs:
- name: "make build"
Expand All @@ -99,7 +102,6 @@ blocks:
jobs:
- name: "libcalico-go: tests"
commands:
- checkout
- cd libcalico-go
- make ci

Expand All @@ -115,12 +117,10 @@ blocks:
jobs:
- name: "Typha: UT and FV tests"
commands:
- checkout
- cd typha
- make ci EXCEPT=k8sfv-test
- name: "Typha: felix k8s-st tests with updated typha image"
commands:
- checkout
- cd typha
- make calico/typha
- cd ../felix
Expand All @@ -140,7 +140,6 @@ blocks:
execution_time_limit:
minutes: 60
commands:
- checkout
- cd felix
- cache restore go-pkg-cache
- cache restore go-mod-cache
Expand All @@ -164,7 +163,6 @@ blocks:
jobs:
- name: "build Windows binaries"
commands:
- checkout
- cd felix
- make bin/calico-felix.exe fv/win-fv.exe

Expand All @@ -190,8 +188,7 @@ blocks:
- export KEYPAIR_NAME=${CLUSTER_NAME}
- echo CLUSTER_NAME=${CLUSTER_NAME}
- sudo apt-get install putty-tools
- git clone [email protected]:tigera/process.git
- checkout
- git clone [email protected]:tigera/process.git ~/process
- cd felix
- make bin/calico-felix.exe fv/win-fv.exe
epilogue:
Expand Down Expand Up @@ -235,7 +232,6 @@ blocks:
task:
prologue:
commands:
- checkout
- cd felix
- cache restore go-pkg-cache
- cache restore go-mod-cache
Expand Down Expand Up @@ -268,7 +264,6 @@ blocks:
task:
prologue:
commands:
- checkout
- cd felix
- export GOOGLE_APPLICATION_CREDENTIALS=$HOME/secrets/secret.google-service-account-key.json
- export SHORT_WORKFLOW_ID=$(echo ${SEMAPHORE_WORKFLOW_ID} | sha256sum | cut -c -8)
Expand Down Expand Up @@ -306,7 +301,6 @@ blocks:
os_image: ubuntu1804
prologue:
commands:
- checkout
- cd felix
- cache restore go-pkg-cache
- cache restore go-mod-cache
Expand All @@ -324,7 +318,6 @@ blocks:
task:
prologue:
commands:
- checkout
- cd confd
jobs:
- name: "confd: CI"
Expand All @@ -344,10 +337,6 @@ blocks:
os_image: ubuntu1804
prologue:
commands:
- checkout
# Semaphore is doing shallow clone on a commit without tags.
# unshallow it for GIT_VERSION:=$(shell git describe --tags --dirty --always)
- git fetch --unshallow
- cd node
jobs:
- name: "Node: CI"
Expand All @@ -364,24 +353,71 @@ blocks:
task:
prologue:
commands:
- checkout
# Semaphore is doing shallow clone on a commit without tags.
# unshallow it for GIT_VERSION:=$(shell git describe --tags --dirty --always)
- git fetch --unshallow
- cd kube-controllers
jobs:
- name: "kube-controllers: tests"
commands:
- make ci

- name: "pod2daemon"
run:
when: "change_in(['/*', '/pod2daemon/'], {exclude: ['/**/.gitignore', '/**/README.md', '/**/LICENSE']})"
dependencies: []
task:
prologue:
commands:
- cd pod2daemon
jobs:
- name: "pod2daemon tests"
commands:
- make ci

- name: "app-policy"
run:
when: "change_in(['/*', '/app-policy/', '/felix/'], {exclude: ['/**/.gitignore', '/**/README.md', '/**/LICENSE']})"
dependencies: []
task:
prologue:
commands:
- cd app-policy
jobs:
- name: "app-policy tests"
commands:
- make ci

- name: "calicoctl"
run:
when: "change_in(['/*', '/calicoctl/', '/libcalico-go/', '/api/'], {exclude: ['/**/.gitignore', '/**/README.md', '/**/LICENSE']})"
dependencies: []
task:
prologue:
commands:
- cd calicoctl
jobs:
- name: "calicoctl tests"
commands:
- make ci

- name: "cni-plugin"
run:
when: "change_in(['/*', '/cni-plugin/', '/libcalico-go/'], {exclude: ['/**/.gitignore', '/**/README.md', '/**/LICENSE']})"
dependencies: []
task:
prologue:
commands:
- cd cni-plugin
jobs:
- name: "cni-plugin tests"
commands:
- make ci

- name: "Documentation"
run:
when: "change_in(['/*', '/calico/'], {exclude: ['/**/.gitignore', '/**/README.md', '/**/LICENSE']})"
dependencies: []
task:
prologue:
commands:
- checkout
- cd calico
jobs:
- name: "htmlproofer, kubeval, and helm tests"
Expand Down
2 changes: 1 addition & 1 deletion calicoctl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ run-kubernetes-master: stop-kubernetes-master
docker run --net=host --detach \
--name st-apiserver-${KUBE_APISERVER_PORT} \
-v $(CURDIR):/code \
-v `pwd`/tests/certs:/home/user/certs \
-v $(CURDIR)/tests/certs:/home/user/certs \
-e KUBECONFIG=/home/user/certs/kubeconfig \
${CALICO_BUILD} kube-apiserver \
--secure-port=${KUBE_APISERVER_PORT} \
Expand Down
12 changes: 6 additions & 6 deletions calicoctl/tests/fv/multi_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func TestMultiCluster(t *testing.T) {
RegisterTestingT(t)

os.Setenv("KUBECONFIG", strings.Join([]string{
"/go/src/github.com/projectcalico/calicoctl/test-data/kubectl-config.yaml",
"/go/src/github.com/projectcalico/calicoctl/test-data/kubectl-config-second.yaml",
"/go/src/github.com/projectcalico/calico/calicoctl/test-data/kubectl-config.yaml",
"/go/src/github.com/projectcalico/calico/calicoctl/test-data/kubectl-config-second.yaml",
}, ":"))

// Set Calico version in ClusterInformation for both contexts
Expand Down Expand Up @@ -65,16 +65,16 @@ func TestMultiCluster(t *testing.T) {
out = Calicoctl(true, "--context", "main", "get", "node")
Expect(out).To(ContainSubstring("node4"))

out = Calicoctl(true, "create", "-f", "/go/src/github.com/projectcalico/calicoctl/test-data/v3/bgppeer-global.yaml", "--context", "main")
out = Calicoctl(true, "create", "-f", "/go/src/github.com/projectcalico/calico/calicoctl/test-data/v3/bgppeer-global.yaml", "--context", "main")
Expect(out).To(ContainSubstring("Successfully"))

out = Calicoctl(true, "patch", "bgppeer", "globalpeer.name5", "-p", "{\"spec\":{\"asNumber\": \"63445\"}}", "--context", "main")
Expect(out).To(ContainSubstring("Successfully"))

out = Calicoctl(true, "apply", "-f", "/go/src/github.com/projectcalico/calicoctl/test-data/v3/bgppeer-global.yaml", "--context", "main")
out = Calicoctl(true, "apply", "-f", "/go/src/github.com/projectcalico/calico/calicoctl/test-data/v3/bgppeer-global.yaml", "--context", "main")
Expect(out).To(ContainSubstring("Successfully"))

out = Calicoctl(true, "replace", "-f", "/go/src/github.com/projectcalico/calicoctl/test-data/v3/bgppeer-global.yaml", "--context", "main")
out = Calicoctl(true, "replace", "-f", "/go/src/github.com/projectcalico/calico/calicoctl/test-data/v3/bgppeer-global.yaml", "--context", "main")
Expect(out).To(ContainSubstring("Successfully"))

out = Calicoctl(true, "label", "nodes", "node4", "cluster=backend", "--context", "main")
Expand All @@ -87,7 +87,7 @@ func TestMultiCluster(t *testing.T) {
out = Calicoctl(true, "--context", "main", "ipam", "show")
Expect(out).To(ContainSubstring("CIDR"))

out = Calicoctl(true, "delete", "-f", "/go/src/github.com/projectcalico/calicoctl/test-data/v3/bgppeer-global.yaml", "--context", "main")
out = Calicoctl(true, "delete", "-f", "/go/src/github.com/projectcalico/calico/calicoctl/test-data/v3/bgppeer-global.yaml", "--context", "main")
Expect(out).To(ContainSubstring("Successfully"))

}
4 changes: 2 additions & 2 deletions calicoctl/tests/fv/utils/calicoctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
log "github.com/sirupsen/logrus"
)

var calicoctl = "/go/src/github.com/projectcalico/calicoctl/bin/calicoctl-linux-amd64"
var version_helper = "/go/src/github.com/projectcalico/calicoctl/tests/fv/helper/bin/calico_version_helper"
var calicoctl = "/go/src/github.com/projectcalico/calico/calicoctl/bin/calicoctl-linux-amd64"
var version_helper = "/go/src/github.com/projectcalico/calico/calicoctl/tests/fv/helper/bin/calico_version_helper"

func getEnv(kdd bool) []string {
env := []string{"ETCD_ENDPOINTS=http://127.0.0.1:2379"}
Expand Down
7 changes: 1 addition & 6 deletions cni-plugin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,7 @@ stop-etcd:
# We pre-build the test binary so that we can run it outside a container and allow it
# to interact with docker.
pkg/install/install.test: pkg/install/*.go
-mkdir -p .go-pkg-cache
docker run --rm \
-e LOCAL_USER_ID=$(LOCAL_USER_ID) \
-v $(CURDIR):/go/src/$(PACKAGE_NAME):rw \
-v $(CURDIR)/.go-pkg-cache:/go/pkg/:rw \
$(CALICO_BUILD) sh -c '$(GIT_CONFIG_SSH) \
$(DOCKER_RUN) $(CALICO_BUILD) sh -c '$(GIT_CONFIG_SSH) \
cd /go/src/$(PACKAGE_NAME) && \
go test ./pkg/install -c --tags install_test -o ./pkg/install/install.test'

Expand Down
3 changes: 2 additions & 1 deletion cni-plugin/pkg/dataplane/grpc/proto/cnibackend.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a9be80e

Please sign in to comment.