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

Volumes not removed from host system. #85

Open
pcarinhas opened this issue Aug 11, 2021 · 1 comment
Open

Volumes not removed from host system. #85

pcarinhas opened this issue Aug 11, 2021 · 1 comment

Comments

@pcarinhas
Copy link

Given docker compose file:

services:
  vault:
    image: vault
    container_name: vault
    env_file:
      - .env
    ports:
      - "8200:8200"
    restart: always
    volumes:
      - ./volumes/logs:/vault/logs
      - ./volumes/file:/vault/file
      - ./volumes/config:/vault/config
    cap_add:
      - IPC_LOCK
    entrypoint: vault server -config=/vault/config/vault.json```

And test environment: 

import hvac
import os
import pytest
from authcontext.auth import AuthContext, S3Auth

pytest_plugins = ["docker_compose"]

class TestAuthContext:
    @pytest.fixture(autouse=True, scope="class")
    def setup_class(self):
        print("\nTesting:", self.__class__.__name__)
        breakpoint()
        print(311)

    def test_setup_vault(self, class_scoped_container_getter):

        class_scoped_container_getter.get("vault").network_info[0]
        __import__("pdb").set_trace()  # FIXME
        client = hvac.Client(url="http://localhost:8200")
        shares = 5
        threshold = 3
        result = client.sys.initialize(shares, threshold)

        self.root_token = result["root_token"]
        self.keys = result["keys"]
        client.sys.is_initialized()```


Tests succeed first time but fail 2nd time due to lingering files on host system:

```pytest --docker-compose-remove-volumes .
=========================================================== test session starts ===========================================================
platform linux -- Python 3.9.6, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /home/joe/z-auth-context
plugins: docker-0.10.3, docker-compose-3.2.1
collected 0 items / 1 error                                                                                                               

================================================================= ERRORS ==================================================================
______________________________________________________ ERROR collecting test session ______________________________________________________
../../.asdf/installs/python/3.9.6/lib/python3.9/site-packages/_pytest/runner.py:311: in from_call
    result: Optional[TResult] = func()
../../.asdf/installs/python/3.9.6/lib/python3.9/site-packages/_pytest/runner.py:341: in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
../../.asdf/installs/python/3.9.6/lib/python3.9/site-packages/_pytest/main.py:690: in collect
    for direntry in visit(str(argpath), self._recurse):
../../.asdf/installs/python/3.9.6/lib/python3.9/site-packages/_pytest/pathlib.py:606: in visit
    yield from visit(entry.path, recurse)
../../.asdf/installs/python/3.9.6/lib/python3.9/site-packages/_pytest/pathlib.py:606: in visit
    yield from visit(entry.path, recurse)
../../.asdf/installs/python/3.9.6/lib/python3.9/site-packages/_pytest/pathlib.py:606: in visit
    yield from visit(entry.path, recurse)
../../.asdf/installs/python/3.9.6/lib/python3.9/site-packages/_pytest/pathlib.py:591: in visit
    for entry in os.scandir(path):
E   PermissionError: [Errno 13] Permission denied: '/home/joe/z-auth-context/tests/volumes/file/core'
========================================================= short test summary info =========================================================
ERROR .. - PermissionError: [Errno 13] Permission denied: '/home/joe/z-auth-context/tests/volumes/file/core'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================ 1 error in 0.13s ==========```
@pcarinhas
Copy link
Author

Vault config files tests]: cat volumes/config/vault.json

  "backend": {
    "file": {
      "path": "/vault/file"
    }
  },
  "listener": {
    "tcp":{
      "address": "0.0.0.0:8200",
      "tls_disable": 1
    }
  },
  "ui": true
}```

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

1 participant