Sign inSign up

xdevdavinci/user-service

By xdevdavinci

•Updated over 7 years ago

User service

Image
0

2.3K

xdevdavinci/user-service repository overview

⁠PySOA User Service

This service is responsible for serving requests for the following actions:

'status': returns health information regarding this service 'login': handles user login 'create_user': allows to create new users and store them into db

Request and responses are validated using the Conformity library: https://github.com/eventbrite/conformity⁠

This service was implemented using pysoa: https://github.com/eventbrite/pysoa⁠

⁠Using the User Service

This Service contains a Dockerfile and a docker_env executable that helps you start a fully-functional remote Service with Redis Gateway transport. To get started, build the environment, which takes a few minutes the first time, and a few seconds subsequent times, depending on your Internet speed::

$ ./docker_env build

You can then start the pysoa-redis and user_service containers and shell into the user_service container as follows::

$ ./docker_env shell

Once inside, you can run tests or run the service (the third command is a shortcut for the second command)::

# pytest
# python3 -m user_service.standalone -s user_service.settings.dev
# rs

With the service running, you can press Ctrl-C to tell it to shut down, and then type exit to leave the container. The pysoa-redis container will continue running in the background. ./docker_env stop will stop it.

You can also start/run user_service in the background and run an user_service_client container to test out the service communication::

$ ./docker_env client
# ./user_service_client/user_service_client.py status
# ./user_client.py square 42

You can also start/run user_service in the background, and link pysoa-redis to your own client container to test calling the service::

$ ./docker_env
$ docker run -it --name user_service_client --link pysoa-redis:redis --entrypoint=/bin/bash user_service_client

Developing for this service locally (Getting Started) +++++++++++++++++++++++++++++++++++++++++++++++++++++

#. Creating new actions

  • New actions should be stored in the /user_service/actions folder
  • The /user_service/server.py contains the actions mapping to classes, storing them in the action_class_map variable

#. Run the service tests :: # Go to xdevdavinci/devenv and run docker-compose up # docker-compose stop user-service # docker-compose run user-service /bin/bash # pytest

#. Run user_service locally :: # Go to xdevdavinci/devenv and run docker-compose up # docker-compose stop user-service # docker-compose run user-service /bin/bash # rs #. When making changes to the service, ensure all tests are passing before landing any changes. All changes should be accompanied by tests that prove those changes.

#. To tag a new release: :: $ pip install invoke-release $ invoke release

Maintainer ++++++++++

  • xDev Integrations

Dependencies ++++++++++++

  • MySQL
  • Redis

How to Run Tests for this Service +++++++++++++++++++++++++++++++++

There are two types of tests:

  • Integration tests ./docker_env client ./user_service_client.py (edited) Where action is the action name, and args is an ordered comma separated list of args

  • Unit tests ./docker_env shell pytest

Run Tests without shelling in the container +++++++++++++++++++++++++++++++++++++++++++

In /user-service directory run:: docker-compose -f user-service.test.yml up --exit-code-from sut

Automated Tests in Docker hub +++++++++++++++++++++++++++++

Everytime you push to master, create a new tag or create a pull requests a new build is triggered in Docker hub, that runs pytest with your source code:: https://cloud.docker.com/u/xdevdavinci/repository/docker/xdevdavinci/user-service/builds⁠

Pay attention to it, in the case you see that a build is failing in user service, verify the logs if you see: We have been waiting for MySQL too long already; failing. is because the MySQL databases take many time to start in DockerHub so you can add more sleep time or retries in docker-entrypoint.sh file in Verify MySQL section

Tag summary

Content type

Image

Digest

Size

302.3 MB

Last updated

over 7 years ago

docker pull xdevdavinci/user-service