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

Unable to execute unit tests locally #870

Open
mcharest-mcn opened this issue Mar 11, 2024 · 4 comments
Open

Unable to execute unit tests locally #870

mcharest-mcn opened this issue Mar 11, 2024 · 4 comments

Comments

@mcharest-mcn
Copy link
Contributor

Context

Using podman instead of docker on MacOS

Describe the bugs

  • The unit tests can't run because of multiple parameters to the healthcheck command
  • Once the parameters is corrected, it can't run because podman is rootless
  • Once the volume is removed, the unit test won't pass.

To Reproduce

Multiple parameters to the healthcheck command

  • Pull https://github.com/prest/prest.git
  • Run the podman command : podman compose -f testdata/docker-compose.yml run --rm prest-test sh ./testdata/runtest.sh
  • See the error

Podman is rootless

  • Pull https://github.com/prest/prest.git
  • Modify the healthcheck command parameter in ./prest/testdata/docker-compose.yml to test: ["CMD-SHELL", "pg_isready -U prest"]
  • Run the podman command : podman compose -f testdata/docker-compose.yml up
  • See the error

Unit test won't pass

  • Pull https://github.com/prest/prest.git
  • Modify the healthcheck command parameter in ./prest/testdata/docker-compose.yml to test: ["CMD-SHELL", "pg_isready -U prest"]
  • Comment the creation of volume in ./prest/testdata/docker-compose.yml
    # volumes:
    #   - "./data/postgres:/var/lib/postgresql/data"
  • Run the podman command : podman compose -f testdata/docker-compose.yml run --rm prest-test sh ./testdata/runtest.sh
  • See the error

Expected behavior

For the unit tests to pass in the main branch

Error

Multiple parameters to the healthcheck command

$ podman compose -f testdata/docker-compose.yml run --rm prest-test sh ./testdata/runtest.sh         
>>>> Executing external compose provider "/opt/homebrew/bin/podman-compose". Please refer to the documentation for details. <<<<

podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.9.3
** excluding:  {'prest-test'}
['podman', 'ps', '--filter', 'label=io.podman.compose.project=testdata', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']
['podman', 'network', 'exists', 'testdata_default']
Traceback (most recent call last):
  File "/opt/homebrew/bin/podman-compose", line 33, in <module>
    sys.exit(load_entry_point('podman-compose==1.0.6', 'console_scripts', 'podman-compose')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/podman-compose/1.0.6/libexec/lib/python3.11/site-packages/podman_compose.py", line 2941, in main
    podman_compose.run()
  File "/opt/homebrew/Cellar/podman-compose/1.0.6/libexec/lib/python3.11/site-packages/podman_compose.py", line 1423, in run
    cmd(self, args)
  File "/opt/homebrew/Cellar/podman-compose/1.0.6/libexec/lib/python3.11/site-packages/podman_compose.py", line 1754, in wrapped
    return func(*args, **kw)
           ^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/podman-compose/1.0.6/libexec/lib/python3.11/site-packages/podman_compose.py", line 2255, in compose_run
    compose.commands["up"](compose, up_args)
  File "/opt/homebrew/Cellar/podman-compose/1.0.6/libexec/lib/python3.11/site-packages/podman_compose.py", line 1754, in wrapped
    return func(*args, **kw)
           ^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/podman-compose/1.0.6/libexec/lib/python3.11/site-packages/podman_compose.py", line 2067, in compose_up
    podman_args = container_to_args(compose, cnt, detached=args.detach)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/podman-compose/1.0.6/libexec/lib/python3.11/site-packages/podman_compose.py", line 999, in container_to_args
    raise ValueError("'CMD_SHELL' takes a single string after it")
ValueError: 'CMD_SHELL' takes a single string after it
Error: executing /opt/homebrew/bin/podman-compose -f testdata/docker-compose.yml run --rm prest-test sh ./testdata/runtest.sh: exit status 1

ValueError: 'CMD_SHELL' takes a single string after it

Podman is rootless

$ podman compose -f testdata/docker-compose.yml up                                          
>>>> Executing external compose provider "/opt/homebrew/bin/podman-compose". Please refer to the documentation for details. <<<<

podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.9.3
** excluding:  set()
['podman', 'inspect', '-t', 'image', '-f', '{{.Id}}', 'testdata_prest-test']
['podman', 'ps', '--filter', 'label=io.podman.compose.project=testdata', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']
recreating: ...
** excluding:  set()
podman stop -t 10 testdata_prest-test_1
Error: no container with name or ID "testdata_prest-test_1" found: no such container
exit code: 125
podman stop -t 10 testdata_postgres_1
testdata_postgres_1
exit code: 0
podman rm testdata_prest-test_1
Error: no container with ID or name "testdata_prest-test_1" found: no such container
exit code: 1
podman rm testdata_postgres_1
testdata_postgres_1
exit code: 0
recreating: done


['podman', 'network', 'exists', 'testdata_default']
podman create --name=testdata_postgres_1 --label io.podman.compose.config-hash=92f54021da675f02a817d2121328a211c8ab1fbb7eb4bd23b23b853db44c514a --label io.podman.compose.project=testdata --label io.podman.compose.version=1.0.6 --label PODMAN_SYSTEMD_UNIT=podman-compose@testdata.service --label com.docker.compose.project=testdata --label com.docker.compose.project.working_dir=/Users/mcharest/workspace/seao/temp/prest/testdata --label com.docker.compose.project.config_files=testdata/docker-compose.yml --label com.docker.compose.container-number=1 --label com.docker.compose.service=postgres -e POSTGRES_USER=postgres -e POSTGRES_DB=prest-test -e POSTGRES_PASSWORD=postgres -v /Users/mcharest/workspace/seao/temp/prest/testdata/data/postgres:/var/lib/postgresql/data --net testdata_default --network-alias postgres --log-driver=none -p 5432:5432 --healthcheck-command /bin/sh -c 'pg_isready -U prest' --healthcheck-interval 30s --healthcheck-retries 3 postgres:16
cb86067cfd1e237386934663178220243b6336d3382051c36adf55d676237d79
exit code: 0
['podman', 'network', 'exists', 'testdata_default']
podman create --name=testdata_prest-test_1 --requires=testdata_postgres_1 --label io.podman.compose.config-hash=92f54021da675f02a817d2121328a211c8ab1fbb7eb4bd23b23b853db44c514a --label io.podman.compose.project=testdata --label io.podman.compose.version=1.0.6 --label PODMAN_SYSTEMD_UNIT=podman-compose@testdata.service --label com.docker.compose.project=testdata --label com.docker.compose.project.working_dir=/Users/mcharest/workspace/seao/temp/prest/testdata --label com.docker.compose.project.config_files=testdata/docker-compose.yml --label com.docker.compose.container-number=1 --label com.docker.compose.service=prest-test -e PREST_PG_HOST=postgres -e PREST_PG_USER=postgres -e PREST_PG_PASS=postgres -e PGPASSWORD=postgres -e PREST_PG_DATABASE=prest-test -e PREST_PG_PORT=5432 -e PREST_SSL_MODE=disable -e PREST_CONF=/workspace/testdata/prest.toml -e PREST_MIGRATIONS=/workspace/testdata/migrations -e PREST_QUERIES_LOCATION=/workspace/testdata/queries -e BE_CRASHER=1 -v /Users/mcharest/workspace/seao/temp/prest:/workspace --net testdata_default --network-alias prest-test testdata_prest-test
39a483de324324b7618a9a6c603d78de521088211f9b71118c561226b19aa992
exit code: 0
podman start -a testdata_postgres_1
chown: changing ownership of '/var/lib/postgresql/data': Operation not permitted
exit code: 1
podman start -a testdata_prest-test_1
Error: unable to start container 39a483de324324b7618a9a6c603d78de521088211f9b71118c561226b19aa992: preparing container 39a483de324324b7618a9a6c603d78de521088211f9b71118c561226b19aa992 for attach: some dependencies of container 39a483de324324b7618a9a6c603d78de521088211f9b71118c561226b19aa992 are not started: cb86067cfd1e237386934663178220243b6336d3382051c36adf55d676237d79: container state improper
exit code: 125

chown: changing ownership of '/var/lib/postgresql/data': Operation not permitted

Unit test won't pass

$ podman compose -f testdata/docker-compose.yml run --rm prest-test sh ./testdata/runtest.sh
>>>> Executing external compose provider "/opt/homebrew/bin/podman-compose". Please refer to the documentation for details. <<<<

podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.9.3
** excluding:  {'prest-test'}
['podman', 'ps', '--filter', 'label=io.podman.compose.project=testdata', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']
['podman', 'network', 'exists', 'testdata_default']
podman run --name=testdata_postgres_1 -d --label io.podman.compose.config-hash=62d4347ee45f2da84cb91a09a019393659e220bf37004c2c9c3893e904907b61 --label io.podman.compose.project=testdata --label io.podman.compose.version=1.0.6 --label PODMAN_SYSTEMD_UNIT=podman-compose@testdata.service --label com.docker.compose.project=testdata --label com.docker.compose.project.working_dir=/Users/mcharest/workspace/seao/temp/prest/testdata --label com.docker.compose.project.config_files=testdata/docker-compose.yml --label com.docker.compose.container-number=1 --label com.docker.compose.service=postgres -e POSTGRES_USER=postgres -e POSTGRES_DB=prest-test -e POSTGRES_PASSWORD=postgres --net testdata_default --network-alias postgres --log-driver=none -p 5432:5432 --healthcheck-command /bin/sh -c 'pg_isready -U prest' --healthcheck-interval 30s --healthcheck-retries 3 postgres:16
885cc99a0b9b12fd2787f2e5668b33891644c104c7c3d614814b3a8db2909998
exit code: 0
** skipping:  testdata_prest-test_1
['podman', 'network', 'exists', 'testdata_default']
podman run --name=testdata_prest-test_tmp13788 --rm -i --requires=testdata_postgres_1 --label io.podman.compose.config-hash=62d4347ee45f2da84cb91a09a019393659e220bf37004c2c9c3893e904907b61 --label io.podman.compose.project=testdata --label io.podman.compose.version=1.0.6 --label PODMAN_SYSTEMD_UNIT=podman-compose@testdata.service --label com.docker.compose.project=testdata --label com.docker.compose.project.working_dir=/Users/mcharest/workspace/seao/temp/prest/testdata --label com.docker.compose.project.config_files=testdata/docker-compose.yml --label com.docker.compose.container-number=1 --label com.docker.compose.service=prest-test -e PREST_PG_HOST=postgres -e PREST_PG_USER=postgres -e PREST_PG_PASS=postgres -e PGPASSWORD=postgres -e PREST_PG_DATABASE=prest-test -e PREST_PG_PORT=5432 -e PREST_SSL_MODE=disable -e PREST_CONF=/workspace/testdata/prest.toml -e PREST_MIGRATIONS=/workspace/testdata/migrations -e PREST_QUERIES_LOCATION=/workspace/testdata/queries -e BE_CRASHER=1 -v /Users/mcharest/workspace/seao/temp/prest:/workspace --net testdata_default --network-alias prest-test --tty testdata_prest-test sh ./testdata/runtest.sh


.:: POSTGRES: DROP/CREATE DATABASE
DROP DATABASE
CREATE DATABASE


.:: POSTGRES: LOAD DATA SCHEMA
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
CREATE TABLE
INSERT 0 1
CREATE VIEW


.:: GOLANG: DOWNLOAD MODULES


.:: PRESTD: PLUGIN BUILD


.:: PRESTD: MIGRATE UP
# golang.org/x/exp/slog
/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/level.go:159:13: undefined: atomic.Int64
/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/attr.go:20:19: undefined: StringValue
/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/attr.go:68:19: undefined: GroupValue
/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/handler.go:446:15: undefined: StringValue
/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/json_handler.go:109:20: v.str undefined (type Value has no field or method str)
/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/record.go:192:9: undefined: GroupValue
/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/text_handler.go:99:20: v.str undefined (type Value has no field or method str)
/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/value.go:87:7: undefined: stringptr
/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/value.go:91:7: undefined: groupptr
/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/value.go:173:10: undefined: StringValue
/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/value.go:173:10: too many errors
note: module requires Go 1.20


.:: PRESTD: TESTING STARTING...
package github.com/prest/prest/adapters/postgres: case-insensitive file name collision: "connection.go" and "connection.go"


.:: POSTGRES: DROP DATABASES
DROP DATABASE
exit code: 0

Additional context

The real problem is that the unit tests won't pass. But I had to expose the podman limitations to explain my context since there is always a possibility that it could be at the root of the problem.

@avelino
Copy link
Member

avelino commented Mar 11, 2024

@mcharest-mcn can you suggest how to solve it and send a pull request?

@mcharest-mcn
Copy link
Contributor Author

mcharest-mcn commented Mar 11, 2024

Ok, i'll look into it. But do the unit tests work for new submissions in the project?

@mcharest-mcn
Copy link
Contributor Author

It ended up being written right in my face...

/go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/slog/value.go:173:10: too many errors
note: module requires Go 1.20

Updated the Go version in the unit test Dockerfile to 1.20 and the test came back to life.

I'm preparing a few modifications to the docker-compose files to be able to run them in both Podman and Docker.

@mcharest-mcn
Copy link
Contributor Author

Added them in PR #871

@arxdsilva arxdsilva self-assigned this Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants