Skip to content
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

Polish fake-aws stuff #305

Merged
merged 3 commits into from May 8, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions Makefile
Expand Up @@ -71,3 +71,9 @@ docker-exe-%:
.PHONY: docker-service-%
docker-service-%:
$(MAKE) -C services/"$*" docker

#################################
## dependencies

libzauth:
$(MAKE) -C libs/libzauth install
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -124,7 +124,7 @@ Integration tests require all of the haskell services (brig,galley,cannon,gundec
Setting up these real, but in-memory internal and "fake" external dependencies is done easiest using [`docker-compose`](https://docs.docker.com/compose/install/). Run the following in a separate terminal (it will block that terminal, C-c to shut all these docker images down again):

```
cd deploy/docker-ephemeral && docker-compose up
deploy/docker-ephemeral/run.sh
```

Then, to run all integration tests:
Expand Down
16 changes: 16 additions & 0 deletions deploy/docker-ephemeral/run.sh
@@ -0,0 +1,16 @@
#!/usr/bin/env sh

# run.sh should work no matter what is the current directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DOCKER_FILE="$SCRIPT_DIR/docker-compose.yaml"

# If there are schema changes and you don't force pull the docker
# migrations, you may run out of sync and you would get this error
# message (or a similar one):
#
# brig: Schema Version too old! Expecting at least: 49, but got: 48
#
# So we always pull wireserver/migrations first.
docker pull wireserver/migrations

docker-compose --file "$DOCKER_FILE" up
12 changes: 2 additions & 10 deletions deploy/services-demo/README.md
Expand Up @@ -6,12 +6,12 @@ Use 2 different terminals and run:

```
# On terminal 1, start the dependencies
(cd ./deploy/docker-ephemeral; docker-compose up)
deploy/docker-ephemeral/run.sh
```

```
# On terminal 2, start the services
./deploy/services-demo/demo.sh
deploy/services-demo/demo.sh
```

### Structure of the services-demo folder
Expand Down Expand Up @@ -43,14 +43,6 @@ It is however very straightforward to setup all the necessary dependencies to ru

### Common problems

> Schema Version too old! Expecting at least: <...>, but got: <...> when running `./demo.sh`.

If there are schema changes and you don't force pull the docker migrations, you may run out of sync. We recommend that you run the following:

`docker-compose pull && docker-compose up`

Which will ensure that your DB schema is up to date.

> nginx: [alert] could not open error log file: open() "/var/log/nginz/error.log" failed (2: No such file or directory)

This is not really an issue and `nginz` is fine. `nginz` has a `LOG_PATH`[check the Makefile](../../services/nginz/Makefile) defined which it always tries to write to during startup, even if you have defined a different path on your `nginx.conf`. You can safely ignore this warning or recompile `nginz` with a `LOG_PATH` which is writable on your system.
Expand Down
5 changes: 3 additions & 2 deletions deploy/services-demo/demo.sh
Expand Up @@ -58,7 +58,7 @@ function check_prerequisites() {
nc -z 127.0.0.1 9042 \
&& nc -z 127.0.0.1 9200 \
&& nc -z 127.0.0.1 6379 \
|| { echo "Databases not up. Maybe run 'cd deploy/docker-ephemeral && docker-compose up' in a separate terminal first?"; exit 1; }
|| { echo "Databases not up. Maybe run 'deploy/docker-ephemeral/run.sh' in a separate terminal first?"; exit 1; }
test -f ${DIR}/../dist/brig \
&& test -f ${DIR}/../dist/galley \
&& test -f ${DIR}/../dist/cannon \
Expand Down Expand Up @@ -88,7 +88,8 @@ function run_haskell_service() {

function run_nginz() {
colour=$1
(cd ${SCRIPT_DIR} && ${DIR}/../dist/nginx -p ${SCRIPT_DIR} -c ${SCRIPT_DIR}/conf/nginz/nginx.conf -g 'daemon off;' || kill_all) \
prefix=$([ -w /usr/local ] && echo /usr/local || echo "${HOME}/.wire-dev")
(cd ${SCRIPT_DIR} && LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${prefix}/lib/ ${DIR}/../dist/nginx -p ${SCRIPT_DIR} -c ${SCRIPT_DIR}/conf/nginz/nginx.conf -g 'daemon off;' || kill_all) \
| sed -e "s/^/$(tput setaf ${colour})[nginz] /" -e "s/$/$(tput sgr0)/" &
}

Expand Down
5 changes: 4 additions & 1 deletion libs/libzauth/libzauth-c/Makefile
Expand Up @@ -3,7 +3,9 @@ VERSION := "3.0.0"
ARCH := amd64
BUILD ?= 1
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
PREFIX ?= /usr/local
# If we can install libzauth globally, we'll install it there, otherwise
# it'll go into ~/.wire-dev
PREFIX := $(shell [ -w /usr/local ] && echo /usr/local || echo "$(HOME)/.wire-dev")

ifeq ($(OS), darwin)
LIB_TYPE := dylib
Expand All @@ -25,6 +27,7 @@ build-release:
cargo build --release

install: build-release
mkdir -p $(PREFIX)/include
mkdir -p $(PREFIX)/lib/pkgconfig
cp src/zauth.h $(PREFIX)/include/
sed -e "s~<<VERSION>>~$(VERSION)~" \
Expand Down
2 changes: 1 addition & 1 deletion services/brig/brig.integration.yaml
Expand Up @@ -24,7 +24,7 @@ gundeck:
host: 127.0.0.1
port: 8086

# You can set up local SQS/Dynamo running e.g. `docker-compose -f ../../deploy/docker-ephemeral/docker-compose.yaml up`
# You can set up local SQS/Dynamo running e.g. `../../deploy/docker-ephemeral/run.sh`
aws:
sesQueue: integration-brig-events
internalQueue: integration-brig-events-internal
Expand Down
2 changes: 1 addition & 1 deletion services/galley/galley.integration.yaml
Expand Up @@ -26,7 +26,7 @@ settings:
#
# If you want to use journaling but journal to a fake sqs service
# such as "fake-sqs" or "localstack",
# run e.g. `docker-compose -f ../../deploy/docker-ephemeral/docker-compose.yaml up`
# run e.g. `../../deploy/docker-ephemeral/run.sh`
# and use a localhost endpoint
#
#journal: # if set, journals; if not set, disables journaling
Expand Down
2 changes: 1 addition & 1 deletion services/integration.sh
Expand Up @@ -36,7 +36,7 @@ function check_prerequisites() {
nc -z 127.0.0.1 9042 \
&& nc -z 127.0.0.1 9200 \
&& nc -z 127.0.0.1 6379 \
|| { echo "Databases not up. Maybe run 'cd deploy/docker-ephemeral && docker-compose up' in a separate terminal first?"; exit 1; }
|| { echo "Databases not up. Maybe run 'deploy/docker-ephemeral/run.sh' in a separate terminal first?"; exit 1; }
test -f ${DIR}/../dist/brig \
&& test -f ${DIR}/../dist/galley \
&& test -f ${DIR}/../dist/cannon \
Expand Down
15 changes: 13 additions & 2 deletions services/nginz/Makefile
Expand Up @@ -22,6 +22,9 @@ PID_PATH ?= /var/run
EXTRA_CC_INC ?=
EXTRA_CC_LIB ?=

# Where should we look for packages, locally or globally?
EXTRA_PKG_PATH := $(shell [ -w /usr/local ] && echo /usr/local || echo "$(HOME)/.wire-dev")/lib/pkgconfig

CONFIG_OPTIONS = \
--prefix=$(DEST_PATH) \
$(WITH_DEBUG) \
Expand Down Expand Up @@ -53,15 +56,19 @@ default: compile
clean:
-rm -rf src $(DIST) .metadata zwagger-ui/swagger-ui

.PHONY: check-deps
check-deps:
PKG_CONFIG_PATH=$(EXTRA_PKG_PATH) pkg-config --exists libzauth || { echo -e "\n\033[0;31m The 'libzauth' library was not found\033[0m\n pkg-config path = $(EXTRA_PKG_PATH)\n\n Attempting to install it...\n" && $(MAKE) libzauth; }

compile: $(BIN)
mkdir -p dist ../../dist
cp src/objs/nginx ../../dist/

dist: guard-NGINZ_VERSION $(DIST)/$(DEB)

$(BIN): src zwagger-ui/swagger-ui
$(BIN): check-deps src zwagger-ui/swagger-ui
git submodule update --init
(cd src; ./configure $(CONFIG_OPTIONS) $(ADDITIONAL_MODULES))
(cd src; PKG_CONFIG_PATH=$(EXTRA_PKG_PATH) ./configure $(CONFIG_OPTIONS) $(ADDITIONAL_MODULES))
make -C src

%.deb: $(BIN) $(DIST)
Expand Down Expand Up @@ -104,3 +111,7 @@ $(TMPDIR)/$(NGINX_BUNDLE):
docker:
git submodule update --init
docker build -f Dockerfile -t nginz ../..

.PHONY: libzauth
libzauth:
$(MAKE) -C ../../libs/libzauth install