From a85575b6522b0adcd8755158efdffc748d86b37b Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Fri, 12 Apr 2019 21:10:10 +0200 Subject: [PATCH] Start to remove Celery code --- .drone.yml | 12 +++++++----- .travis.yml | 35 ----------------------------------- app.py | 7 +++++-- docker-compose-tests.yml | 40 ---------------------------------------- docker-compose.yml | 26 ++------------------------ tests/federation_test.py | 4 ++-- 6 files changed, 16 insertions(+), 108 deletions(-) delete mode 100644 .travis.yml delete mode 100644 docker-compose-tests.yml diff --git a/.drone.yml b/.drone.yml index 2c0b67f..450b7b3 100644 --- a/.drone.yml +++ b/.drone.yml @@ -46,12 +46,13 @@ steps: environment: DOCKER_HOST: tcp://docker:2375 MICROBLOGPUB_DEBUG: 1 - MICROBLOGPUB_HOSTNAME: instance1_web + MICROBLOGPUB_POUSSETACHES_HOST: http://poussetaches:7991 + MICROBLOGPUB_INTERNAL_HOST: http://instance1_web:5005 MICROBLOGPUB_MONGODB_HOST: mongo:27017 POUSSETACHES_AUTH_KEY: lol commands: - sleep 5 - - 'docker run -p 5006:5005 --net fede -v "`pwd`/tests/fixtures/instance1/config:/app/config" -e MICROBLOGPUB_DEBUG -e MICROBLOGPUB_HOSTNAME -e MICROBLOGPUB_MONGODB_HOST -e POUSSETACHES_AUTH_KEY --name instance1_web microblogpub' + - 'docker run -p 5006:5005 --net fede -v "`pwd`/tests/fixtures/instance1/config:/app/config" -e MICROBLOGPUB_DEBUG -e MICROBLOGPUB_INTERNAL_HOST -e MICROBLOGPUB_MONGODB_HOST -e POUSSETACHES_AUTH_KEY --name instance1_web microblogpub' - name: microblogpub_instance2 image: docker:dind @@ -59,11 +60,12 @@ steps: environment: DOCKER_HOST: tcp://docker:2375 MICROBLOGPUB_DEBUG: 1 - MICROBLOGPUB_HOSTNAME: instance2_web + MICROBLOGPUB_POUSSETACHES_HOST: http://poussetaches:7991 + MICROBLOGPUB_INTERNAL_HOST: http://instance2_web:5005 MICROBLOGPUB_MONGODB_HOST: mongo:27017 POUSSETACHES_AUTH_KEY: lol commands: - - 'docker run -p 5007:5005 --net fede -v "`pwd`/tests/fixtures/instance2/config:/app/config" -e MICROBLOGPUB_DEBUG -e MICROBLOGPUB_HOSTNAME -e MICROBLOGPUB_MONGODB_HOST -e POUSSETACHES_AUTH_KEY --name instance2_web microblogpub' + - 'docker run -p 5007:5005 --net fede -v "`pwd`/tests/fixtures/instance2/config:/app/config" -e MICROBLOGPUB_DEBUG -e MICROBLOGPUB_INTERNAL_HOST -e MICROBLOGPUB_MONGODB_HOST -e POUSSETACHES_AUTH_KEY --name instance2_web microblogpub' - name: integration_test @@ -80,6 +82,6 @@ services: privileged: true --- kind: signature -hmac: 0e02bf6fbcb514be8d3ee0f4a315c3f560f762ee474d27a009281b20cc8123ab +hmac: e9e0af1e17c84ff087d83fbdd00ba132327cca9365b9805486d5a295443a5bd3 ... diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f9fc688..0000000 --- a/.travis.yml +++ /dev/null @@ -1,35 +0,0 @@ -language: python -sudo: required -python: - - '3.7' -matrix: - include: - - python: 3.7 - dist: xenial - sudo: true -services: - - docker -install: - - sudo apt-get install -y curl python-tk - - sudo pip install -U pip - - sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose - - sudo chmod +x /usr/local/bin/docker-compose - - docker-compose --version - - pip install -r dev-requirements.txt - - git clone https://github.com/tsileo/poussetaches.git && cd poussetaches && docker build . -t poussetaches:latest && cd - -script: - - mypy --ignore-missing-imports . - - flake8 activitypub.py - - cp -r tests/fixtures/me.yml config/me.yml - - docker build . -t microblogpub:latest - - docker-compose up -d - - docker-compose ps - - WEB_PORT=5006 COMPOSE_PROJECT_NAME=instance1 CONFIG_DIR=./tests/fixtures/instance1/config docker-compose -p instance1 -f docker-compose-tests.yml up -d - - docker-compose -p instance1 -f docker-compose-tests.yml ps - - WEB_PORT=5007 COMPOSE_PROJECT_NAME=instance2 CONFIG_DIR=./tests/fixtures/instance2/config docker-compose -p instance2 -f docker-compose-tests.yml up -d - - docker-compose -p instance2 -f docker-compose-tests.yml ps - - sleep 5 - # Integration tests first - - python -m pytest -v --ignore data -k integration - # Federation tests (with two local instances) - - python -m pytest -v -s --ignore data -k federation diff --git a/app.py b/app.py index 577f9b0..a04a687 100644 --- a/app.py +++ b/app.py @@ -90,8 +90,11 @@ from utils.media import Kind from poussetaches import PousseTaches -phost = "http://" + os.getenv("COMPOSE_PROJECT_NAME", "") -p = PousseTaches(f"{phost}_poussetaches_1:7991", f"{phost}_web_1:5005") +p = PousseTaches( + os.getenv("MICROBLOGPUB_POUSSETACHES_HOST", "http://localhost:7991"), + os.getenv("MICROBLOGPUB_INTERNAL_HOST", "http://localhost:5000"), +) + # p = PousseTaches("http://localhost:7991", "http://localhost:5000") back = activitypub.MicroblogPubBackend() diff --git a/docker-compose-tests.yml b/docker-compose-tests.yml deleted file mode 100644 index 4d9443d..0000000 --- a/docker-compose-tests.yml +++ /dev/null @@ -1,40 +0,0 @@ -version: '3.5' -services: - web: - image: 'microblogpub:latest' - ports: - - "${WEB_PORT}:5005" - volumes: - - "${CONFIG_DIR}:/app/config" - - "./static:/app/static" - environment: - - MICROBLOGPUB_AMQP_BROKER=pyamqp://guest@rmq// - - MICROBLOGPUB_MONGODB_HOST=${COMPOSE_PROJECT_NAME}_mongo_1:27017 - - MICROBLOGPUB_DEBUG=1 - - COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} - - POUSSETACHES_AUTH_KEY=123 - celery: -# image: "instance1_web" - image: 'microblogpub:latest' - command: 'celery worker -l info -A tasks' - volumes: - - "${CONFIG_DIR}:/app/config" - environment: - - MICROBLOGPUB_AMQP_BROKER=pyamqp://guest@rmq// - - MICROBLOGPUB_MONGODB_HOST=mongo:27017 - - MICROBLOGPUB_DEBUG=1 - mongo: - image: "mongo:latest" - rmq: - image: "rabbitmq:latest" - hostname: "my-rabbit" - environment: - - RABBITMQ_ERLANG_COOKIE=secretrabbit - - RABBITMQ_NODENAME=rabbit@my-rabbit - poussetaches: - image: "poussetaches:latest" - environment: - - POUSSETACHES_AUTH_KEY=123 -networks: - default: - name: microblogpubfede diff --git a/docker-compose.yml b/docker-compose.yml index 634987e..2be0c57 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,41 +4,19 @@ services: image: 'microblogpub:latest' ports: - "${WEB_PORT}:5005" - links: - - mongo - - rmq - - poussetaches volumes: - "${CONFIG_DIR}:/app/config" - "./static:/app/static" environment: - - MICROBLOGPUB_AMQP_BROKER=pyamqp://guest@rmq// - MICROBLOGPUB_MONGODB_HOST=mongo:27017 + - MICROBLOGPUB_INTERNAL_HOST=http://${COMPOSE_PROJECT_NAME}_web_1:5005 + - MICROBLOGPUB_POUSSETACHES_HOST=http://${COMPOSE_PROJECT_NAME}_poussetaches_1:7991 - POUSSETACHES_AUTH_KEY=${POUSSETACHES_AUTH_KEY} - COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} - celery: - image: 'microblogpub:latest' - links: - - mongo - - rmq - command: 'celery worker -l info -A tasks' - volumes: - - "${CONFIG_DIR}:/app/config" - environment: - - MICROBLOGPUB_AMQP_BROKER=pyamqp://guest@rmq// - - MICROBLOGPUB_MONGODB_HOST=mongo:27017 mongo: image: "mongo:latest" volumes: - "${DATA_DIR}/mongodb:/data/db" - rmq: - image: "rabbitmq:latest" - hostname: "my-rabbit" - environment: - - RABBITMQ_ERLANG_COOKIE=secretrabbit - - RABBITMQ_NODENAME=rabbit@my-rabbit - volumes: - - "${DATA_DIR}/rabbitmq:/var/lib/rabbitmq" poussetaches: image: "poussetaches:latest" volumes: diff --git a/tests/federation_test.py b/tests/federation_test.py index 959280f..2a698dd 100644 --- a/tests/federation_test.py +++ b/tests/federation_test.py @@ -208,12 +208,12 @@ class Instance(object): def _instances() -> Tuple[Instance, Instance]: """Initializes the client for the two test instances.""" instance1 = Instance( - "instance1", "http://localhost:5006", "http://instance1_web_1:5005" + "instance1", "http://docker:5006", "http://instance1_web:5005" ) instance1.ping() instance2 = Instance( - "instance2", "http://localhost:5007", "http://instance2_web_1:5005" + "instance2", "http://docker:5007", "http://instance2_web:5005" ) instance2.ping()