Start to remove Celery code

This commit is contained in:
Thomas Sileo 2019-04-12 21:10:10 +02:00
parent d74660ab3d
commit a85575b652
6 changed files with 16 additions and 108 deletions

View file

@ -46,12 +46,13 @@ steps:
environment: environment:
DOCKER_HOST: tcp://docker:2375 DOCKER_HOST: tcp://docker:2375
MICROBLOGPUB_DEBUG: 1 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 MICROBLOGPUB_MONGODB_HOST: mongo:27017
POUSSETACHES_AUTH_KEY: lol POUSSETACHES_AUTH_KEY: lol
commands: commands:
- sleep 5 - 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 - name: microblogpub_instance2
image: docker:dind image: docker:dind
@ -59,11 +60,12 @@ steps:
environment: environment:
DOCKER_HOST: tcp://docker:2375 DOCKER_HOST: tcp://docker:2375
MICROBLOGPUB_DEBUG: 1 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 MICROBLOGPUB_MONGODB_HOST: mongo:27017
POUSSETACHES_AUTH_KEY: lol POUSSETACHES_AUTH_KEY: lol
commands: 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 - name: integration_test
@ -80,6 +82,6 @@ services:
privileged: true privileged: true
--- ---
kind: signature kind: signature
hmac: 0e02bf6fbcb514be8d3ee0f4a315c3f560f762ee474d27a009281b20cc8123ab hmac: e9e0af1e17c84ff087d83fbdd00ba132327cca9365b9805486d5a295443a5bd3
... ...

View file

@ -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

7
app.py
View file

@ -90,8 +90,11 @@ from utils.media import Kind
from poussetaches import PousseTaches from poussetaches import PousseTaches
phost = "http://" + os.getenv("COMPOSE_PROJECT_NAME", "") p = PousseTaches(
p = PousseTaches(f"{phost}_poussetaches_1:7991", f"{phost}_web_1:5005") os.getenv("MICROBLOGPUB_POUSSETACHES_HOST", "http://localhost:7991"),
os.getenv("MICROBLOGPUB_INTERNAL_HOST", "http://localhost:5000"),
)
# p = PousseTaches("http://localhost:7991", "http://localhost:5000") # p = PousseTaches("http://localhost:7991", "http://localhost:5000")
back = activitypub.MicroblogPubBackend() back = activitypub.MicroblogPubBackend()

View file

@ -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

View file

@ -4,41 +4,19 @@ services:
image: 'microblogpub:latest' image: 'microblogpub:latest'
ports: ports:
- "${WEB_PORT}:5005" - "${WEB_PORT}:5005"
links:
- mongo
- rmq
- poussetaches
volumes: volumes:
- "${CONFIG_DIR}:/app/config" - "${CONFIG_DIR}:/app/config"
- "./static:/app/static" - "./static:/app/static"
environment: environment:
- MICROBLOGPUB_AMQP_BROKER=pyamqp://guest@rmq//
- MICROBLOGPUB_MONGODB_HOST=mongo:27017 - 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} - POUSSETACHES_AUTH_KEY=${POUSSETACHES_AUTH_KEY}
- COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} - 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: mongo:
image: "mongo:latest" image: "mongo:latest"
volumes: volumes:
- "${DATA_DIR}/mongodb:/data/db" - "${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: poussetaches:
image: "poussetaches:latest" image: "poussetaches:latest"
volumes: volumes:

View file

@ -208,12 +208,12 @@ class Instance(object):
def _instances() -> Tuple[Instance, Instance]: def _instances() -> Tuple[Instance, Instance]:
"""Initializes the client for the two test instances.""" """Initializes the client for the two test instances."""
instance1 = Instance( instance1 = Instance(
"instance1", "http://localhost:5006", "http://instance1_web_1:5005" "instance1", "http://docker:5006", "http://instance1_web:5005"
) )
instance1.ping() instance1.ping()
instance2 = Instance( instance2 = Instance(
"instance2", "http://localhost:5007", "http://instance2_web_1:5005" "instance2", "http://docker:5007", "http://instance2_web:5005"
) )
instance2.ping() instance2.ping()