prest / prest

PostgreSQL ➕ REST, low-code, simplify and accelerate development, ⚡ instant, realtime, high-performance on any Postgres application, existing or new
https://www.prestd.com
MIT License
4.24k stars 283 forks source link

Unable to execute unit tests locally #870

Open mcharest-mcn opened 8 months ago

mcharest-mcn commented 8 months ago

Context

Using podman instead of docker on MacOS

Describe the bugs

To Reproduce

Multiple parameters to the healthcheck command

Podman is rootless

Unit test won't pass

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 commented 8 months ago

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

mcharest-mcn commented 8 months ago

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

mcharest-mcn commented 8 months ago

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 commented 8 months ago

Added them in PR https://github.com/prest/prest/pull/871