Skip to content

Commit

Permalink
collapse metrics ingress and egress into one
Browse files Browse the repository at this point in the history
  • Loading branch information
jancajthaml authored Nov 21, 2021
1 parent 0641708 commit c2646a9
Show file tree
Hide file tree
Showing 19 changed files with 57 additions and 205 deletions.
89 changes: 3 additions & 86 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ workflows:
ignore: /.*/
tags:
only: /^v[0-9]+(\.[0-9]+)*$/
- compile-armhf:
requires:
- deps
filters:
branches:
ignore: /.*/
tags:
only: /^v[0-9]+(\.[0-9]+)*$/
- compile-arm64:
requires:
- deps
Expand All @@ -69,15 +61,6 @@ workflows:
ignore: /.*/
tags:
only: /^v[0-9]+(\.[0-9]+)*$/
- package-debian-armhf:
requires:
- compile-armhf
- versions
filters:
branches:
ignore: /.*/
tags:
only: /^v[0-9]+(\.[0-9]+)*$/
- package-debian-arm64:
requires:
- compile-arm64
Expand All @@ -91,7 +74,6 @@ workflows:
requires:
- unit-test
- package-debian-amd64
- package-debian-armhf
- package-debian-arm64
filters:
branches:
Expand Down Expand Up @@ -128,20 +110,13 @@ workflows:
- compile-amd64:
requires:
- deps
- compile-armhf:
requires:
- deps
- compile-arm64:
requires:
- deps
- package-debian-amd64:
requires:
- compile-amd64
- versions
- package-debian-armhf:
requires:
- compile-armhf
- versions
- package-debian-arm64:
requires:
- compile-arm64
Expand All @@ -150,7 +125,6 @@ workflows:
requires:
- unit-test
- package-debian-amd64
- package-debian-armhf
- package-debian-arm64
- blackbox-test-amd64:
requires:
Expand Down Expand Up @@ -230,7 +204,7 @@ jobs:
echo -e "${META}" > /mnt/ramdisk/META
else
echo -e "${CIRCLE_TAG#v}" > /mnt/ramdisk/VERSION
echo -e "main" > /mnt/ramdisk/META
echo -e "-main" > /mnt/ramdisk/META
fi
- save_cache:
key: versions-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
Expand Down Expand Up @@ -301,29 +275,6 @@ jobs:

# -------------------------------------------------------------------------- #

compile-armhf:
executor: go
working_directory: /mnt/ramdisk
steps:
- restore_cache:
key: code-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: dependencies-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Compile lake binary
command: |
/mnt/ramdisk/dev/lifecycle/package \
--arch linux/armhf \
--source /mnt/ramdisk/services/lake \
--output /mnt/ramdisk/packaging/bin
no_output_timeout: 5m
- save_cache:
key: binaries-armhf-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
paths:
- /mnt/ramdisk/packaging/bin

# -------------------------------------------------------------------------- #

compile-arm64:
executor: go
working_directory: /home/circleci/project
Expand Down Expand Up @@ -374,33 +325,6 @@ jobs:

# -------------------------------------------------------------------------- #

package-debian-armhf:
executor: debian
working_directory: /mnt/ramdisk
steps:
- restore_cache:
key: code-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: binaries-armhf-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: versions-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Package for debian
command: |
VERSION=$(cat /mnt/ramdisk/VERSION)
/mnt/ramdisk/dev/lifecycle/debian \
--arch armhf \
--pkg lake \
--version ${VERSION} \
--source /mnt/ramdisk/packaging
no_output_timeout: 5m
- save_cache:
key: debian-armhf-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
paths:
- /mnt/ramdisk/packaging/bin

# -------------------------------------------------------------------------- #

package-debian-arm64:
executor: debian
working_directory: /mnt/ramdisk
Expand Down Expand Up @@ -437,14 +361,10 @@ jobs:
key: code-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: binaries-amd64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: binaries-armhf-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: binaries-arm64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: debian-amd64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: debian-armhf-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: debian-arm64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
Expand Down Expand Up @@ -508,13 +428,14 @@ jobs:
echo -e "${META}" > /home/circleci/project/META
else
echo -e "${CIRCLE_TAG#v}" > /home/circleci/project/VERSION
echo -e "main" > /home/circleci/project/META
echo -e "-main" > /home/circleci/project/META
fi
- run:
name: Run blackbox tests
command: |
export VERSION=v$(cat /home/circleci/project/VERSION)
export META=$(cat /home/circleci/project/META)
export ARCH=amd64
docker-compose up -d bbtest
docker exec -t $(docker-compose ps -q bbtest) python3 /opt/app/bbtest/main.py
Expand All @@ -536,14 +457,10 @@ jobs:
key: code-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: binaries-amd64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: binaries-armhf-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: binaries-arm64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: debian-amd64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: debian-armhf-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: debian-arm64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- deploy:
Expand Down
1 change: 0 additions & 1 deletion .jenkins/commit.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ pipeline {
options = """
|-e IMAGE_VERSION=${env.VERSION}
|-e UNIT_VERSION=${env.VERSION}
|-e UNIT_ARCH=${env.ARCH}
|--volumes-from=${cid}
|-v /var/run/docker.sock:/var/run/docker.sock:rw
|-v /var/lib/docker/containers:/var/lib/docker/containers:rw
Expand Down
1 change: 0 additions & 1 deletion .jenkins/perf.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ pipeline {
options = """
|-e IMAGE_VERSION=${params.VERSION}
|-e UNIT_VERSION=${params.VERSION}
|-e UNIT_ARCH=amd64
|-e MESSAGES_PUSHED=${params.MESSAGES_RELAYED}
|--volumes-from=${cid}
|--cpus=1
Expand Down
30 changes: 15 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

META := $(shell git rev-parse --abbrev-ref HEAD 2> /dev/null | sed 's:.*/::')
VERSION := $(shell git fetch --tags --force 2> /dev/null; tags=($$(git tag --sort=-v:refname)) && ([ $${\#tags[@]} -eq 0 ] && echo v0.0.0 || echo $${tags[0]}))
ARCH := $(shell uname -m | sed 's/x86_64/amd64/')

export COMPOSE_DOCKER_CLI_BUILD = 1
export DOCKER_BUILDKIT = 1
Expand All @@ -9,14 +10,13 @@ export COMPOSE_PROJECT_NAME = lake
.ONESHELL:
.PHONY: arm64
.PHONY: amd64
.PHONY: armhf

.PHONY: all
all: bootstrap sync test package bbtest perf

.PHONY: package
package:
@$(MAKE) package-amd64
@$(MAKE) package-$(ARCH)
@$(MAKE) bundle-docker

.PHONY: package-%
Expand All @@ -26,7 +26,7 @@ package-%: %

.PHONY: bundle-binaries-%
bundle-binaries-%: %
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm package \
--arch linux/$^ \
Expand All @@ -35,7 +35,7 @@ bundle-binaries-%: %

.PHONY: bundle-debian-%
bundle-debian-%: %
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm debian-package \
--version $(VERSION) \
Expand All @@ -52,7 +52,7 @@ bundle-docker:

.PHONY: bootstrap
bootstrap:
@docker-compose build --force-rm go
@ARCH=$(ARCH) docker-compose build --force-rm go

.PHONY: lint
lint:
Expand All @@ -64,15 +64,15 @@ lint:

.PHONY: sec
sec:
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm sec \
--source /go/src/github.com/jancajthaml-openbank/lake \
|| :

.PHONY: sync
sync:
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm sync \
--source /go/src/github.com/jancajthaml-openbank/lake
Expand All @@ -86,28 +86,28 @@ scan:

.PHONY: test
test:
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm test \
--source /go/src/github.com/jancajthaml-openbank/lake \
--output /project/reports/unit-tests

.PHONY: release
release:
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm release \
--version $(VERSION) \
--token ${GITHUB_RELEASE_TOKEN}

.PHONY: bbtest
bbtest:
@META=$(META) VERSION=$(VERSION) docker-compose up -d bbtest
@docker exec -t $$(docker-compose ps -q bbtest) python3 /opt/app/bbtest/main.py
@docker-compose down -v
@ARCH=$(ARCH) META=$(META) VERSION=$(VERSION) docker-compose up -d bbtest
@docker exec -t $$(ARCH=$(ARCH) docker-compose ps -q bbtest) python3 /opt/app/bbtest/main.py
@ARCH=$(ARCH) docker-compose down -v

.PHONY: perf
perf:
@META=$(META) VERSION=$(VERSION) docker-compose up -d perf
@docker exec -t $$(docker-compose ps -q perf) python3 /opt/app/perf/main.py
@docker-compose down -v
@ARCH=$(ARCH) META=$(META) VERSION=$(VERSION) docker-compose up -d perf
@docker exec -t $$(ARCH=$(ARCH) docker-compose ps -q perf) python3 /opt/app/perf/main.py
@ARCH=$(ARCH) docker-compose down -v
3 changes: 1 addition & 2 deletions bbtest/features/metrics.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ Feature: Metrics test
Then lake responds with "A B"
And metrics reports:
| key | type | value |
| openbank.lake.message.ingress | count | 1 |
| openbank.lake.message.egress | count | 1 |
| openbank.lake.message.relayed | count | 1 |
| openbank.lake.memory.bytes | gauce | |
4 changes: 2 additions & 2 deletions bbtest/helpers/unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def default_config():
def get_arch(self):
return {
'x86_64': 'amd64',
'armv7l': 'armhf',
'armv8': 'arm64'
'armv8': 'arm64',
'aarch64': 'arm64',
}.get(platform.uname().machine, 'amd64')

def __init__(self, context):
Expand Down
1 change: 0 additions & 1 deletion dev/lifecycle/debian
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ lifecycle::debian::package() {

local CC=gcc
case ${TARGET_ARCHITECTURE} in
armhf) CC=arm-linux-gnueabihf-gcc ;;
arm64) CC=aarch64-linux-gnu-gcc ;;
*) CC=gcc ;;
esac
Expand Down
20 changes: 0 additions & 20 deletions dev/lifecycle/package
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,6 @@ lifecycle::go::build() {

case ${ARCH} in

armhf)
cd ${source} && \
\
GOOS=${PLATFORM} \
GOARM=7 \
GOARCH=arm \
CGO_ENABLED=1 \
GOFLAGS=-buildmode=pie \
CC=arm-linux-gnueabihf-gcc \
\
go build -a -o ${output} || {
(>&2 echo "[error] ${output} unable to build")
exit 1
}
;;

arm64)
cd ${source} && \
\
Expand Down Expand Up @@ -133,10 +117,6 @@ lifecycle::go::strip() {

case ${ARCH} in

armhf)
arm-linux-gnueabihf-objcopy --strip-unneeded ${output}
;;

arm64)
aarch64-linux-gnu-objcopy --strip-unneeded ${output}
;;
Expand Down
Loading

0 comments on commit c2646a9

Please sign in to comment.