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

Failed tests on initilization and unreachable /w Docker-Compose #73

Closed
WP-LKL opened this issue Apr 16, 2022 · 5 comments
Closed

Failed tests on initilization and unreachable /w Docker-Compose #73

WP-LKL opened this issue Apr 16, 2022 · 5 comments

Comments

@WP-LKL
Copy link
Contributor

WP-LKL commented Apr 16, 2022

python3 -m fastapi_template                                                                                                                  ✔  ccdemo 3.9.10  
Project name: fatemplate
Project description: fatemplate
Removing resources for disabled feature Gitlab CI...
Removing resources for disabled feature Tortoise ORM...
Removing resources for disabled feature Ormar ORM...
Removing resources for disabled feature PsycoPG...
Removing resources for disabled feature MySQL DB...
Removing resources for disabled feature SQLite DB...
cleanup complete!
⭐ Placing resources nicely in your new project ⭐
Resources are happy to be where they are needed the most.
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint:   git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint:   git branch -m <name>
Git repository initialized.
Added files to index.
Updating dependencies
Resolving dependencies... (14.9s)

Writing lock file

No dependencies to install or update

Installing the current project: fatemplate (0.1.0)
pre-commit installed at .git/hooks/pre-commit
pre-commit installed.
Check python ast.........................................................Passed
Trim Trailing Whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing fatemplate/web/application.py
Fixing deploy/docker-compose.yml
Fixing fatemplate/settings.py
Fixing fatemplate/web/lifetime.py
Fixing deploy/kube/db.yml

Check Toml...............................................................Passed
Fix End of Files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing deploy/docker-compose.yml
Fixing fatemplate/tests/test_dummy.py
Fixing fatemplate/static/docs/swagger-ui-bundle.js
Fixing fatemplate/static/docs/redoc.standalone.js
Fixing fatemplate/tests/test_echo.py
Fixing fatemplate/static/docs/swagger-ui.css

Add trailing commas......................................................Failed
- hook id: add-trailing-comma
- exit code: 1
- files were modified by this hook

Rewriting fatemplate/tests/test_redis.py
Rewriting fatemplate/web/application.py
Rewriting fatemplate/conftest.py
Rewriting fatemplate/db/dao/dummy_dao.py
Rewriting fatemplate/db/utils.py
Rewriting fatemplate/tests/test_echo.py
Rewriting fatemplate/tests/test_dummy.py

Pretty format YAML.......................................................Failed
- hook id: pretty-format-yaml
- exit code: 1
- files were modified by this hook

File deploy/docker-compose.yml is not pretty-formatted
Fixing file deploy/docker-compose.yml
File .github/workflows/tests.yml is not pretty-formatted
Fixing file .github/workflows/tests.yml
File .pre-commit-config.yaml is not pretty-formatted
Fixing file .pre-commit-config.yaml
File deploy/kube/app.yml is not pretty-formatted
Fixing file deploy/kube/app.yml
File deploy/kube/db.yml is not pretty-formatted
Fixing file deploy/kube/db.yml
File deploy/kube/redis.yml is not pretty-formatted
Fixing file deploy/kube/redis.yml

Format with Black........................................................Failed
- hook id: black
- files were modified by this hook

reformatted fatemplate/web/api/dummy/__init__.py
reformatted fatemplate/web/lifetime.py

All done! ✨ 🍰 ✨
2 files reformatted, 2 files left unchanged.
reformatted fatemplate/settings.py

All done! ✨ 🍰 ✨
1 file reformatted, 3 files left unchanged.
reformatted fatemplate/db/migrations/env.py

All done! ✨ 🍰 ✨
1 file reformatted, 3 files left unchanged.
reformatted fatemplate/web/api/monitoring/views.py

All done! ✨ 🍰 ✨
1 file reformatted, 3 files left unchanged.
reformatted fatemplate/web/api/monitoring/__init__.py
reformatted fatemplate/tests/test_fatemplate.py

All done! ✨ 🍰 ✨
2 files reformatted, 2 files left unchanged.
reformatted fatemplate/web/api/docs/views.py
reformatted fatemplate/tests/test_redis.py

All done! ✨ 🍰 ✨
2 files reformatted, 2 files left unchanged.
reformatted fatemplate/web/application.py

All done! ✨ 🍰 ✨
1 file reformatted, 3 files left unchanged.
reformatted fatemplate/conftest.py

All done! ✨ 🍰 ✨
1 file reformatted, 3 files left unchanged.
reformatted fatemplate/web/api/docs/__init__.py
reformatted fatemplate/web/api/echo/__init__.py
reformatted fatemplate/db/utils.py

All done! ✨ 🍰 ✨
3 files reformatted, 1 file left unchanged.
reformatted fatemplate/tests/test_echo.py
reformatted fatemplate/tests/test_dummy.py

All done! ✨ 🍰 ✨
2 files reformatted, 2 files left unchanged.
reformatted fatemplate/web/api/redis/__init__.py

All done! ✨ 🍰 ✨
1 file reformatted, 1 file left unchanged.

autoflake................................................................Failed
- hook id: autoflake
- files were modified by this hook
isort....................................................................Failed
- hook id: isort
- files were modified by this hook

Fixing /home/mano/Desktop/test/fatemplate/fatemplate/web/lifetime.py
Fixing /home/mano/Desktop/test/fatemplate/fatemplate/tests/test_fatemplate.py
Fixing /home/mano/Desktop/test/fatemplate/fatemplate/tests/test_redis.py
Fixing /home/mano/Desktop/test/fatemplate/fatemplate/web/api/docs/views.py
Fixing /home/mano/Desktop/test/fatemplate/fatemplate/web/application.py
Fixing /home/mano/Desktop/test/fatemplate/fatemplate/conftest.py
Fixing /home/mano/Desktop/test/fatemplate/fatemplate/db/dao/dummy_dao.py
Fixing /home/mano/Desktop/test/fatemplate/fatemplate/web/api/docs/__init__.py
Fixing /home/mano/Desktop/test/fatemplate/fatemplate/db/utils.py
Fixing /home/mano/Desktop/test/fatemplate/fatemplate/tests/test_echo.py
Fixing /home/mano/Desktop/test/fatemplate/fatemplate/tests/test_dummy.py
Fixing /home/mano/Desktop/test/fatemplate/fatemplate/web/api/router.py

Check with Flake8........................................................Passed
Validate types with MyPy.................................................Passed
Remove usless noqa.......................................................Failed
- hook id: yesqa
- exit code: 1
- files were modified by this hook

Rewriting fatemplate/conftest.py

Check python ast.........................................................Passed
Trim Trailing Whitespace.................................................Passed
Check Toml...............................................................Passed
Fix End of Files.........................................................Passed
Add trailing commas......................................................Passed
Pretty format YAML.......................................................Passed
Format with Black........................................................Passed
autoflake................................................................Passed
isort....................................................................Passed
Check with Flake8........................................................Passed
Validate types with MyPy.................................................Passed
Remove usless noqa.......................................................Passed
hint: The '.git/hooks/commit-msg' hook was ignored because it's not set as executable.
hint: You can disable this warning with `git config advice.ignoredHook false`.
Project successfully generated. You can read information about usage in README.md

Building and then running with docker-compose the server is unreachable on localhost:8000 or 0.0.0.0:8000:

Sending build context to Docker daemon  777.3kB
Step 1/9 : FROM python:3.9.6-slim-buster
 ---> e18d3088c48c
Step 2/9 : RUN pip install poetry==1.1.8
 ---> Using cache
 ---> 1c68c5835316
Step 3/9 : RUN poetry config virtualenvs.create false
 ---> Using cache
 ---> 738969c2c64f
Step 4/9 : COPY pyproject.toml poetry.lock /app/src/
 ---> Using cache
 ---> b6024b866e35
Step 5/9 : WORKDIR /app/src
 ---> Using cache
 ---> fb117ba5c837
Step 6/9 : RUN poetry install
 ---> Using cache
 ---> efe0dcf90249
Step 7/9 : COPY . /app/src/
 ---> Using cache
 ---> 298c2bf3d8d7
Step 8/9 : RUN poetry install
 ---> Using cache
 ---> 39f4a9b1f1ad
Step 9/9 : CMD ["/usr/local/bin/python", "-m", "fatemplate"]
 ---> Using cache
 ---> e0af20beef2a
Successfully built e0af20beef2a
Successfully tagged fatemplate:latest
[+] Running 6/6
 ⠿ Network fatemplate_default       Created                                                                                                                                           0.0s
 ⠿ Volume "fatemplate-db-data"      Created                                                                                                                                           0.0s
 ⠿ Container fatemplate-redis-1     Created                                                                                                                                           0.1s
 ⠿ Container fatemplate-db-1        Created                                                                                                                                           0.1s
 ⠿ Container fatemplate-migrator-1  Created                                                                                                                                           0.2s
 ⠿ Container fatemplate-api-1       Created                                                                                                                                           0.1s
Attaching to fatemplate-api-1, fatemplate-db-1, fatemplate-migrator-1, fatemplate-redis-1
fatemplate-db-1        | The files belonging to this database system will be owned by user "postgres".
fatemplate-db-1        | This user must also own the server process.
fatemplate-db-1        | 
fatemplate-db-1        | The database cluster will be initialized with locale "en_US.utf8".
fatemplate-db-1        | The default database encoding has accordingly been set to "UTF8".
fatemplate-db-1        | The default text search configuration will be set to "english".
fatemplate-db-1        | 
fatemplate-db-1        | Data page checksums are disabled.
fatemplate-db-1        | 
fatemplate-db-1        | fixing permissions on existing directory /var/lib/postgresql/data ... ok
fatemplate-db-1        | creating subdirectories ... ok
fatemplate-db-1        | selecting dynamic shared memory implementation ... posix
fatemplate-db-1        | selecting default max_connections ... 100
fatemplate-db-1        | selecting default shared_buffers ... 128MB
fatemplate-db-1        | selecting default time zone ... Etc/UTC
fatemplate-db-1        | creating configuration files ... ok
fatemplate-redis-1     | redis 16:46:16.54 
fatemplate-redis-1     | redis 16:46:16.54 Welcome to the Bitnami redis container
fatemplate-redis-1     | redis 16:46:16.54 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-redis
fatemplate-redis-1     | redis 16:46:16.54 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-redis/issues
fatemplate-redis-1     | redis 16:46:16.54 
fatemplate-redis-1     | redis 16:46:16.54 INFO  ==> ** Starting Redis setup **
fatemplate-redis-1     | redis 16:46:16.55 WARN  ==> You set the environment variable ALLOW_EMPTY_PASSWORD=yes. For safety reasons, do not use this flag in a production environment.
fatemplate-redis-1     | redis 16:46:16.55 INFO  ==> Initializing Redis
fatemplate-redis-1     | redis 16:46:16.55 INFO  ==> Setting Redis config file
fatemplate-redis-1     | redis 16:46:16.56 INFO  ==> ** Redis setup finished! **
fatemplate-redis-1     | 
fatemplate-redis-1     | redis 16:46:16.57 INFO  ==> ** Starting Redis **
fatemplate-redis-1     | 1:C 16 Apr 2022 16:46:16.579 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
fatemplate-redis-1     | 1:C 16 Apr 2022 16:46:16.579 # Redis version=6.2.5, bits=64, commit=00000000, modified=0, pid=1, just started
fatemplate-redis-1     | 1:C 16 Apr 2022 16:46:16.579 # Configuration loaded
fatemplate-redis-1     | 1:M 16 Apr 2022 16:46:16.579 * monotonic clock: POSIX clock_gettime
fatemplate-redis-1     | 1:M 16 Apr 2022 16:46:16.580 * Running mode=standalone, port=6379.
fatemplate-redis-1     | 1:M 16 Apr 2022 16:46:16.580 # Server initialized
fatemplate-redis-1     | 1:M 16 Apr 2022 16:46:16.580 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
fatemplate-redis-1     | 1:M 16 Apr 2022 16:46:16.580 * Ready to accept connections
fatemplate-db-1        | running bootstrap script ... ok
fatemplate-db-1        | performing post-bootstrap initialization ... ok
fatemplate-db-1        | syncing data to disk ... ok
fatemplate-db-1        | 
fatemplate-db-1        | 
fatemplate-db-1        | Success. You can now start the database server using:
fatemplate-db-1        | 
fatemplate-db-1        |     pg_ctl -D /var/lib/postgresql/data -l logfile start
fatemplate-db-1        | 
fatemplate-db-1        | initdb: warning: enabling "trust" authentication for local connections
fatemplate-db-1        | You can change this by editing pg_hba.conf or using the option -A, or
fatemplate-db-1        | --auth-local and --auth-host, the next time you run initdb.
fatemplate-db-1        | waiting for server to start....2022-04-16 16:46:17.100 UTC [47] LOG:  starting PostgreSQL 13.4 (Debian 13.4-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
fatemplate-db-1        | 2022-04-16 16:46:17.102 UTC [47] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
fatemplate-db-1        | 2022-04-16 16:46:17.112 UTC [48] LOG:  database system was shut down at 2022-04-16 16:46:16 UTC
fatemplate-db-1        | 2022-04-16 16:46:17.118 UTC [47] LOG:  database system is ready to accept connections
fatemplate-db-1        |  done
fatemplate-db-1        | server started
fatemplate-db-1        | CREATE DATABASE
fatemplate-db-1        | 
fatemplate-db-1        | 
fatemplate-db-1        | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
fatemplate-db-1        | 
fatemplate-db-1        | 2022-04-16 16:46:17.322 UTC [47] LOG:  received fast shutdown request
fatemplate-db-1        | waiting for server to shut down....2022-04-16 16:46:17.324 UTC [47] LOG:  aborting any active transactions
fatemplate-db-1        | 2022-04-16 16:46:17.325 UTC [47] LOG:  background worker "logical replication launcher" (PID 54) exited with exit code 1
fatemplate-db-1        | 2022-04-16 16:46:17.325 UTC [49] LOG:  shutting down
fatemplate-db-1        | 2022-04-16 16:46:17.339 UTC [47] LOG:  database system is shut down
fatemplate-db-1        |  done
fatemplate-db-1        | server stopped
fatemplate-db-1        | 
fatemplate-db-1        | PostgreSQL init process complete; ready for start up.
fatemplate-db-1        | 
fatemplate-db-1        | 2022-04-16 16:46:17.439 UTC [1] LOG:  starting PostgreSQL 13.4 (Debian 13.4-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
fatemplate-db-1        | 2022-04-16 16:46:17.439 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
fatemplate-db-1        | 2022-04-16 16:46:17.439 UTC [1] LOG:  listening on IPv6 address "::", port 5432
fatemplate-db-1        | 2022-04-16 16:46:17.442 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
fatemplate-db-1        | 2022-04-16 16:46:17.449 UTC [75] LOG:  database system was shut down at 2022-04-16 16:46:17 UTC
fatemplate-db-1        | 2022-04-16 16:46:17.454 UTC [1] LOG:  database system is ready to accept connections
fatemplate-api-1       | INFO:     Will watch for changes in these directories: ['/app/src']
fatemplate-api-1       | INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
fatemplate-api-1       | INFO:     Started reloader process [1] using statreload
fatemplate-migrator-1  | INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
fatemplate-migrator-1  | INFO  [alembic.runtime.migration] Will assume transactional DDL.
fatemplate-migrator-1  | INFO  [alembic.runtime.migration] Running upgrade  -> 819cbf6e030b, Initial migration.
fatemplate-migrator-1  | INFO  [alembic.runtime.migration] Running upgrade 819cbf6e030b -> 2b7380507a71, Created Dummy Model.
fatemplate-api-1       | INFO:     Started server process [8]
fatemplate-api-1       | INFO:     Waiting for application startup.
fatemplate-migrator-1 exited with code 0
fatemplate-api-1       | INFO:     Application startup complete.

What default configuration are you testing with @s3rius that I could try, or more likely -- I am performing an error at some point?

@WP-LKL WP-LKL changed the title Failed tests on initilization Failed tests on initilization and unreachable /w Docker-Compose Apr 16, 2022
@s3rius
Copy link
Owner

s3rius commented Apr 17, 2022

Hi, thanks for reporting.
I don't see any error. Application startup process completed successfully.
If you want to reach an application from host, please check docker-compose configuration and add missing ports directive like this:

services:
   api:
      ...
      ports:
         - "8000:8000"

After this modification you can reach your app on port 8000.

This template doesn't expose application ports by default.

@s3rius
Copy link
Owner

s3rius commented Apr 17, 2022

If your first question was about failed pre-commit tests, then it's totally okay.
Template runs pre-commit twice to check if all problems were fixed by the firs run of pre-commit.

@s3rius
Copy link
Owner

s3rius commented Apr 17, 2022

I've created an issue (#74) to fix application availability for local development.

@WP-LKL
Copy link
Contributor Author

WP-LKL commented Apr 17, 2022

Wonderful @s3rius!

I do not wish to bloat the documentation. Although I. noting the /api/ prefix for the endpoints and II. informing during the initialization script that some tests are expected to fail during the first pass of the pre-commit is something we might consider.

Thanks again, this is a truly great project!

@WP-LKL WP-LKL closed this as completed Apr 17, 2022
@s3rius
Copy link
Owner

s3rius commented Apr 17, 2022

Thanks. I'll add a note about it in docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants