keploy / keploy

Test generation for Developers. Generate tests and stubs for your application that actually work!
https://keploy.io
Apache License 2.0
3.4k stars 375 forks source link

[docs]: Unable to run the go lang mux app in the documentation #1193

Closed priyankkumar218 closed 5 months ago

priyankkumar218 commented 5 months ago

What do you want to add to the docs? (please state reasons if any)

Screenshot 2023-12-12 204139

When I initially spin up my container , an error is thrown saying that the .sql file mentioned in the docker-compose.yml is not a file but instead a directory and hence the application exits without running

And again, when I try to run the keploy record -c "docker compose up" --containerName "muxSqlApp" the command waits for the muxSqlApp to scale up but it isn't able to do so.

System: Windows 11 WSL 2 (Ubuntu)

I have followed the exact steps as mentioned in the doc but not able to successfully reproduce the results.

Doc: https://keploy.io/docs/quickstart/samples-mux/

Awaiting a resolution on this.

Where is this stated?

Some issues might be there for the Windows WSL in the steps mentioned, and hence it needs a check

Repository

samples-go

github-actions[bot] commented 5 months ago

Thank you and congratulations 🎉 for opening your very first issue in keploy

Sonichigo commented 5 months ago

Thank @priyankkumar218 for reporting the issue! There is a piece of information missing in the docker-compose.yml. can you add the following to the docker compose yml at the line 3 before postgres and check once ?

  go-app:
    build:
      context: .
    container_name: muxSqlApp
    ports:
      - "8010:8010"
    depends_on:
      - postgres
    networks:
      - keploy-network 
Sonichigo commented 5 months ago

this issue will be fixed by #85

priyankkumar218 commented 5 months ago

While running this command: keploy record -c "docker compose up" --containerName "muxSqlApp"

I am getting the following error: { "error": "dial tcp: lookup mux-sql-postgres-1 on 127.0.0.11:53: no such host" }

on hitting this api: curl --location 'http://localhost:8010/products' \ --header 'content-type: application/json' \ --data '{ "name":"Bubbles", "price": 123 }' (Same case with GET)

Doc reference: https://keploy.io/docs/quickstart/samples-mux/

@Sonichigo What could be the possible reason here?

Logs:

latest: Pulling from keploy/keploy
Digest: sha256:b94b82424a6d7b951e704d4d4f261d9fc9a2f923f476f106e7b041fa0d945805
Status: Image is up to date for ghcr.io/keploy/keploy:latest

       ▓██▓▄
    ▓▓▓▓██▓█▓▄
     ████████▓▒
          ▀▓▓███▄      ▄▄   ▄               ▌
         ▄▌▌▓▓████▄    ██ ▓█▀  ▄▌▀▄  ▓▓▌▄   ▓█  ▄▌▓▓▌▄ ▌▌   ▓
       ▓█████████▌▓▓   ██▓█▄  ▓█▄▓▓ ▐█▌  ██ ▓█  █▌  ██  █▌ █▓
      ▓▓▓▓▀▀▀▀▓▓▓▓▓▓▌  ██  █▓  ▓▌▄▄ ▐█▓▄▓█▀ █▓█ ▀█▄▄█▀   █▓█
       ▓▌                           ▐█▌                   █▌
        ▓

version: 2.0.0-alpha49

🐰 Keploy: 2023-12-13T13:30:17Z         INFO    cmd/record.go:152       continuing without configuration file because file not found
Warning: buildDelay is set to 30s, incase your docker container takes more time to build use --buildDelay to set custom delay
Example usage:
 keploy record -c "docker-compose up --build" --buildDelay 35s\n
or
 keploy record -c "docker-compose up --build" --buildDelay 1m\n
🐰 Keploy: 2023-12-13T13:30:17Z         INFO    cmd/record.go:192               {"keploy test and mock path": "/files/keploy"}
🐰 Keploy: 2023-12-13T13:30:24Z         INFO    hooks/loader.go:781     keploy initialized and probes added to the kernel.
🐰 Keploy: 2023-12-13T13:30:24Z         INFO    proxy/proxy.go:451      Proxy started at port:16789
🐰 Keploy: 2023-12-13T13:30:24Z         INFO    hooks/launch.go:95      Created kdocker-compose.yml file and Replaced relative file paths in docker compose file.
🐰 Keploy: 2023-12-13T13:30:24Z         INFO    hooks/launch.go:557     trying to inject network:keploy-network to the keploy container
🐰 Keploy: 2023-12-13T13:30:25Z         INFO    hooks/launch.go:595     Successfully injected network to the keploy container   {"Keploy container": "keploy-v2", "appNetwork": "keploy-network"}
[+] Running 2/2
 ✔ Container files-postgres-1  Created                                                                             0.0s
 ✔ Container muxSqlApp         Created                                                                             0.1s
Attaching to files-postgres-1, muxSqlApp
files-postgres-1  | 2023-12-13 13:30:25.826 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
files-postgres-1  | 2023-12-13 13:30:25.826 UTC [1] LOG:  listening on IPv6 address "::", port 5432
files-postgres-1  | 2023-12-13 13:30:25.830 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
files-postgres-1  | 2023-12-13 13:30:25.848 UTC [23] LOG:  database system was shut down at 2023-12-13 13:29:37 UTC
files-postgres-1  | 2023-12-13 13:30:25.856 UTC [1] LOG:  database system is ready to accept connections
muxSqlApp         | 2023/12/13 13:30:26 😃 Connected to 8010 port !!
🐰 Keploy: 2023-12-13T13:30:26Z         INFO    hooks/launch.go:438     container & network found and processed successfully    {"time": 1702474226151381660}
🐰 Keploy: 2023-12-13T13:31:06Z         INFO    yaml/yaml.go:212        🟠 Keploy has captured test cases for the user's application.   {"path": "/files/keploy/test-set-2/tests", "testcase name": "test-1"}
priyankkumar218 commented 5 months ago

Also, when I am running it via docker-compose up the application works fine, but when I use it in conjunction with keploy record -c [args] command it simply doesn't works

@Sonichigo Fyi

Sonichigo commented 5 months ago

While running this command: keploy record -c "docker compose up" --containerName "muxSqlApp"

I am getting the following error: { "error": "dial tcp: lookup mux-sql-postgres-1 on 127.0.0.11:53: no such host" }

on hitting this api: curl --location 'http://localhost:8010/products' \ --header 'content-type: application/json' \ --data '{ "name":"Bubbles", "price": 123 }' (Same case with GET)

Doc reference: https://keploy.io/docs/quickstart/samples-mux/

@Sonichigo What could be the possible reason here?

Logs:

latest: Pulling from keploy/keploy
Digest: sha256:b94b82424a6d7b951e704d4d4f261d9fc9a2f923f476f106e7b041fa0d945805
Status: Image is up to date for ghcr.io/keploy/keploy:latest

       ▓██▓▄
    ▓▓▓▓██▓█▓▄
     ████████▓▒
          ▀▓▓███▄      ▄▄   ▄               ▌
         ▄▌▌▓▓████▄    ██ ▓█▀  ▄▌▀▄  ▓▓▌▄   ▓█  ▄▌▓▓▌▄ ▌▌   ▓
       ▓█████████▌▓▓   ██▓█▄  ▓█▄▓▓ ▐█▌  ██ ▓█  █▌  ██  █▌ █▓
      ▓▓▓▓▀▀▀▀▓▓▓▓▓▓▌  ██  █▓  ▓▌▄▄ ▐█▓▄▓█▀ █▓█ ▀█▄▄█▀   █▓█
       ▓▌                           ▐█▌                   █▌
        ▓

version: 2.0.0-alpha49

🐰 Keploy: 2023-12-13T13:30:17Z         INFO    cmd/record.go:152       continuing without configuration file because file not found
Warning: buildDelay is set to 30s, incase your docker container takes more time to build use --buildDelay to set custom delay
Example usage:
 keploy record -c "docker-compose up --build" --buildDelay 35s\n
or
 keploy record -c "docker-compose up --build" --buildDelay 1m\n
🐰 Keploy: 2023-12-13T13:30:17Z         INFO    cmd/record.go:192               {"keploy test and mock path": "/files/keploy"}
🐰 Keploy: 2023-12-13T13:30:24Z         INFO    hooks/loader.go:781     keploy initialized and probes added to the kernel.
🐰 Keploy: 2023-12-13T13:30:24Z         INFO    proxy/proxy.go:451      Proxy started at port:16789
🐰 Keploy: 2023-12-13T13:30:24Z         INFO    hooks/launch.go:95      Created kdocker-compose.yml file and Replaced relative file paths in docker compose file.
🐰 Keploy: 2023-12-13T13:30:24Z         INFO    hooks/launch.go:557     trying to inject network:keploy-network to the keploy container
🐰 Keploy: 2023-12-13T13:30:25Z         INFO    hooks/launch.go:595     Successfully injected network to the keploy container   {"Keploy container": "keploy-v2", "appNetwork": "keploy-network"}
[+] Running 2/2
 ✔ Container files-postgres-1  Created                                                                             0.0s
 ✔ Container muxSqlApp         Created                                                                             0.1s
Attaching to files-postgres-1, muxSqlApp
files-postgres-1  | 2023-12-13 13:30:25.826 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
files-postgres-1  | 2023-12-13 13:30:25.826 UTC [1] LOG:  listening on IPv6 address "::", port 5432
files-postgres-1  | 2023-12-13 13:30:25.830 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
files-postgres-1  | 2023-12-13 13:30:25.848 UTC [23] LOG:  database system was shut down at 2023-12-13 13:29:37 UTC
files-postgres-1  | 2023-12-13 13:30:25.856 UTC [1] LOG:  database system is ready to accept connections
muxSqlApp         | 2023/12/13 13:30:26 😃 Connected to 8010 port !!
🐰 Keploy: 2023-12-13T13:30:26Z         INFO    hooks/launch.go:438     container & network found and processed successfully    {"time": 1702474226151381660}
🐰 Keploy: 2023-12-13T13:31:06Z         INFO    yaml/yaml.go:212        🟠 Keploy has captured test cases for the user's application.   {"path": "/files/keploy/test-set-2/tests", "testcase name": "test-1"}

By default the container-name that is created is with name :- mux-sql-postgres-1, when using the docker-compose up

image

But from the logs i can see that the container name varies in your case the name is files-postgres-1. which results in 127.0.0.11:53: no such host because the container it is looking for doesn't exist.

priyankkumar218 commented 5 months ago

I haven't changed anything. And main.go has the same hostname for docker starting with mux as mentioned in the readme guide.

On Thu, 14 Dec, 2023, 10:55 am Animesh Pathak, @.***> wrote:

While running this command: keploy record -c "docker compose up" --containerName "muxSqlApp"

I am getting the following error: { "error": "dial tcp: lookup mux-sql-postgres-1 on 127.0.0.11:53: no such host" }

on hitting this api: curl --location 'http://localhost:8010/products' \ --header 'content-type: application/json' \ --data '{ "name":"Bubbles", "price": 123 }' (Same case with GET)

Doc reference: https://keploy.io/docs/quickstart/samples-mux/

@Sonichigo https://github.com/Sonichigo What could be the possible reason here?

Logs:

latest: Pulling from keploy/keploy Digest: sha256:b94b82424a6d7b951e704d4d4f261d9fc9a2f923f476f106e7b041fa0d945805 Status: Image is up to date for ghcr.io/keploy/keploy:latest

   ▓██▓▄
▓▓▓▓██▓█▓▄
 ████████▓▒
      ▀▓▓███▄      ▄▄   ▄               ▌
     ▄▌▌▓▓████▄    ██ ▓█▀  ▄▌▀▄  ▓▓▌▄   ▓█  ▄▌▓▓▌▄ ▌▌   ▓
   ▓█████████▌▓▓   ██▓█▄  ▓█▄▓▓ ▐█▌  ██ ▓█  █▌  ██  █▌ █▓
  ▓▓▓▓▀▀▀▀▓▓▓▓▓▓▌  ██  █▓  ▓▌▄▄ ▐█▓▄▓█▀ █▓█ ▀█▄▄█▀   █▓█
   ▓▌                           ▐█▌                   █▌
    ▓

version: 2.0.0-alpha49

🐰 Keploy: 2023-12-13T13:30:17Z INFO cmd/record.go:152 continuing without configuration file because file not found Warning: buildDelay is set to 30s, incase your docker container takes more time to build use --buildDelay to set custom delay Example usage: keploy record -c "docker-compose up --build" --buildDelay 35s\n or keploy record -c "docker-compose up --build" --buildDelay 1m\n 🐰 Keploy: 2023-12-13T13:30:17Z INFO cmd/record.go:192 {"keploy test and mock path": "/files/keploy"} 🐰 Keploy: 2023-12-13T13:30:24Z INFO hooks/loader.go:781 keploy initialized and probes added to the kernel. 🐰 Keploy: 2023-12-13T13:30:24Z INFO proxy/proxy.go:451 Proxy started at port:16789 🐰 Keploy: 2023-12-13T13:30:24Z INFO hooks/launch.go:95 Created kdocker-compose.yml file and Replaced relative file paths in docker compose file. 🐰 Keploy: 2023-12-13T13:30:24Z INFO hooks/launch.go:557 trying to inject network:keploy-network to the keploy container 🐰 Keploy: 2023-12-13T13:30:25Z INFO hooks/launch.go:595 Successfully injected network to the keploy container {"Keploy container": "keploy-v2", "appNetwork": "keploy-network"} [+] Running 2/2 ✔ Container files-postgres-1 Created 0.0s ✔ Container muxSqlApp Created 0.1s Attaching to files-postgres-1, muxSqlApp files-postgres-1 | 2023-12-13 13:30:25.826 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 files-postgres-1 | 2023-12-13 13:30:25.826 UTC [1] LOG: listening on IPv6 address "::", port 5432 files-postgres-1 | 2023-12-13 13:30:25.830 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" files-postgres-1 | 2023-12-13 13:30:25.848 UTC [23] LOG: database system was shut down at 2023-12-13 13:29:37 UTC files-postgres-1 | 2023-12-13 13:30:25.856 UTC [1] LOG: database system is ready to accept connections muxSqlApp | 2023/12/13 13:30:26 😃 Connected to 8010 port !! 🐰 Keploy: 2023-12-13T13:30:26Z INFO hooks/launch.go:438 container & network found and processed successfully {"time": 1702474226151381660} 🐰 Keploy: 2023-12-13T13:31:06Z INFO yaml/yaml.go:212 🟠 Keploy has captured test cases for the user's application. {"path": "/files/keploy/test-set-2/tests", "testcase name": "test-1"}

By default the container-name that is created is with name :- mux-sql-postgres-1, when using the docker-compose up image.png (view on web) https://github.com/keploy/keploy/assets/53110238/a89e7cdf-7920-466d-8b07-b245350d4f96

But from the logs i can see that the container name varies in your case the name is files-postgres-1. which results in 127.0.0.11:53: no such host because the container it is looking for doesn't exist.

— Reply to this email directly, view it on GitHub https://github.com/keploy/keploy/issues/1193#issuecomment-1855155906, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC6LH4TYL272P6LR4B222CTYJKETXAVCNFSM6AAAAABARUZFYKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJVGE2TKOJQGY . You are receiving this because you were mentioned.Message ID: @.***>

Sonichigo commented 5 months ago

Just had the discussion with the team, this is known bug, we are actively working towards fix it and releasing new release. For now can add container name directly to docker-compose.yml container_name: mux-sql-postgres-1 . This is just a temporary work around till the next release.

Thanks for reporting bringing this bug to our notice @priyankkumar218 !!!

priyankkumar218 commented 5 months ago

@Sonichigo This workaround is working fine on wsl 2. Hope it gets fixed soon.

Sonichigo commented 5 months ago

Closing this issue since it's been resolved!

priyankkumar218 commented 5 months ago

@Sonichigo Hey, Also Please fix the same for samples-java repo as well

Sonichigo commented 5 months ago

@Sonichigo Hey, Also Please fix the same for samples-java repo as well

Can you describe the issue you are facing ?