forked from adobe-apiplatform/api-gateway-cachemanager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
94 lines (78 loc) · 3.94 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# NOTE: Every line in a recipe must begin with a tab character.
BUILD_DIR ?= target
REDIS_VERSION ?= 2.8.6
PREFIX ?= /usr/local
LUA_INCLUDE_DIR ?= $(PREFIX)/include
LUA_LIB_DIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION)
INSTALL ?= install
REDIS_SERVER ?= $(BUILD_DIR)/redis-$(REDIS_VERSION)/src/redis-server
.PHONY: all clean test install
all: ;
install: all
$(INSTALL) -d $(DESTDIR)/$(LUA_LIB_DIR)/api-gateway/cache/
$(INSTALL) -d $(DESTDIR)/$(LUA_LIB_DIR)/api-gateway/cache/request/
$(INSTALL) -d $(DESTDIR)/$(LUA_LIB_DIR)/api-gateway/cache/status/
$(INSTALL) -d $(DESTDIR)/$(LUA_LIB_DIR)/api-gateway/cache/store/
$(INSTALL) src/lua/api-gateway/cache/*.lua $(DESTDIR)/$(LUA_LIB_DIR)/api-gateway/cache/
$(INSTALL) src/lua/api-gateway/cache/request/*.lua $(DESTDIR)/$(LUA_LIB_DIR)/api-gateway/cache/request/
$(INSTALL) src/lua/api-gateway/cache/status/*.lua $(DESTDIR)/$(LUA_LIB_DIR)/api-gateway/cache/status/
$(INSTALL) src/lua/api-gateway/cache/store/*.lua $(DESTDIR)/$(LUA_LIB_DIR)/api-gateway/cache/store/
test: redis
echo "Starting redis server on default port"
# $(BUILD_DIR)/redis-$(REDIS_VERSION)/src/redis-server test/resources/redis/redis-test.conf
$(REDIS_SERVER) test/resources/redis/redis-test.conf
echo "updating git submodules ..."
if [ ! -d "test/resources/test-nginx/lib" ]; then git submodule update --init --recursive; fi
echo "running tests ..."
mkdir -p $(BUILD_DIR)
mkdir -p $(BUILD_DIR)/test-logs
cp -r test/resources/api-gateway $(BUILD_DIR)
rm -f $(BUILD_DIR)/test-logs/*
PATH=/usr/local/sbin:$$PATH TEST_NGINX_SERVROOT=`pwd`/$(BUILD_DIR)/servroot TEST_NGINX_PORT=1989 prove -I ./test/resources/test-nginx/lib -I ./test/resources/test-nginx/inc -r ./test/perl
cat $(BUILD_DIR)/redis-test.pid | xargs kill
redis: all
mkdir -p $(BUILD_DIR)
if [ "$(REDIS_SERVER)" = "$(BUILD_DIR)/redis-$(REDIS_VERSION)/src/redis-server" ]; then \
tar -xf test/resources/redis/redis-$(REDIS_VERSION).tar.gz -C $(BUILD_DIR)/;\
cd $(BUILD_DIR)/redis-$(REDIS_VERSION) && make; \
fi
echo " ... using REDIS_SERVER=$(REDIS_SERVER)"
.PHONY: pre-docker-test
pre-docker-test:
echo " pre-docker-test"
echo " cleaning up any test_redis docker image"
docker ps | grep test_redis | awk '{print $$1}' | xargs docker stop | xargs docker rm
rm -rf $(BUILD_DIR)/*
rm -rf ~/tmp/apiplatform/api-gateway-cachemanager/
mkdir -p $(BUILD_DIR)
mkdir -p $(BUILD_DIR)/test-logs
cp -r test/resources/api-gateway $(BUILD_DIR)
sed -i '' 's/127\.0\.0\.1/redis\.docker/g' $(BUILD_DIR)/api-gateway/redis-upstream.conf
rm -f $(BUILD_DIR)/test-logs/*
mkdir -p ~/tmp/apiplatform/api-gateway-cachemanager
cp -r ./src ~/tmp/apiplatform/api-gateway-cachemanager/
cp -r ./test ~/tmp/apiplatform/api-gateway-cachemanager/
cp -r ./target ~/tmp/apiplatform/api-gateway-cachemanager/
mkdir -p ~/tmp/apiplatform/api-gateway-cachemanager/target/test-logs
ln -s ~/tmp/apiplatform/api-gateway-cachemanager/target/test-logs ./target/test-logs
.PHONY: get-redis-docker-ip
get-redis-docker-ip:
$(eval $@_IP := $(shell docker run --entrypoint=ifconfig alpine eth0 | grep "inet addr" | cut -d: -f2 | awk '{ print $$1}'))
@echo "Assuming the next IP for the docker container is:" $($@_IP)
sed -i '' 's/127\.0\.0\.1\:6379/$($@_IP)\:6379/g' ~/tmp/apiplatform/api-gateway-cachemanager/test/perl/api-gateway/cache/status/remoteCacheStatus.t
post-docker-test:
echo " post-docker-test"
cp -r ~/tmp/apiplatform/api-gateway-cachemanager/target/ ./target
rm -rf ~/tmp/apiplatform/api-gateway-cachemanager
run-docker-test:
echo " run-docker-test"
- cd ./test && docker-compose up --force-recreate
test-docker: pre-docker-test get-redis-docker-ip run-docker-test post-docker-test
echo "running tests with docker ..."
test-docker-manual: pre-docker-test
echo "starting the docker images ..."
cd ./test/manual && docker-compose up --force-recreate
package:
git archive --format=tar --prefix=api-gateway-cachemanager-1.3.0/ -o api-gateway-cachemanager-1.3.0.tar.gz -v HEAD
clean: all
rm -rf $(BUILD_DIR)