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

App sample spring-boot-redis application #82

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

slashexx
Copy link

@slashexx slashexx commented Oct 31, 2024

Pull Request Template

Description

This pull request introduces a sample Spring Boot application that utilizes Redis for managing products. The application includes a ProductController for handling CRUD operations and a Product model representing the product entity. Additionally, Keploy has been used to generate and run test cases, ensuring the reliability of the implemented functionalities.

Feat : #2333

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

I have generated test cases using Keploy, which cover all the CRUD operations defined in the ProductController. The tests were executed successfully, and the application ran without any errors. To reproduce the tests, run the following command in the project directory:

mvn test

Make sure you have the required dependencies and Redis service running.

Additional Context (Please include any Screenshots/gifs if relevant)

The application can be accessed via the /products endpoint for creating, retrieving, updating, and deleting products.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings
  • I have tagged the reviewers in a comment below in case my pull request is ready for review
  • I have signed the commit message to agree to the Developer Certificate of Origin (DCO) by adding "--signoff" to my git commit command.

Test passing :-
image
image
image
image

@slashexx
Copy link
Author

@Sonichigo I opened this PR a while back, is this still in review ?

@charankamarapu
Copy link
Member

Will review by EOD.

@charankamarapu
Copy link
Member

@slashexx Please run test mode, so that the Reports will also be added in the codebase along with tests and mocks.

@slashexx
Copy link
Author

slashexx commented Nov 29, 2024

@slashexx Please run test mode, so that the Reports will also be added in the codebase along with tests and mocks.

@charankamarapu sure, I'm on it.

I'm actually trying to run it on my system but there seems to be some issue with sending requests to the localhost, can you help me a lil to debug this ?

🐰 Keploy: 2024-11-29T12:56:30+05:30 INFO starting test for of {"test case": "[test-1]", "test set": "[test-set-0]"} 🐰 Keploy: 2024-11-29T12:56:30+05:30 ERROR failed to send testcase request to app {"error": "Post \"http://localhost:8080/products\": dial tcp: lookup localhost on 192.168.1.1:53: no such host"} 🐰 Keploy: 2024-11-29T12:56:30+05:30 ERROR failed to simulate request

I've only quoted one test case but it's showing this for all test cases. How do I make sure the request is sent to the correct localhost ?

PS: Turns out the reports earlier were automatically put in .gitignore so they couldn't be pushed. I have shifted to a new version of the code so I'll generate the tests and mocks again.

@charankamarapu
Copy link
Member

can you provide the command you are running for test..? along with that can you tell me what os are you using..?

@slashexx
Copy link
Author

slashexx commented Nov 29, 2024

can you provide the command you are running for test..? along with that can you tell me what os are you using..?

The one I ran was keploy test -c "java -jar target/spring-boot-redis-0.0.1-SNAPSHOT.jar" --delay 15

I tried to change the host and ran keploy test -c "java -jar target/spring-boot-redis-0.0.1-SNAPSHOT.jar" --host "localhost:8080" --delay 15 and got the same error

Keploy: 2024-11-29T13:06:46+05:30 ERROR failed to send testcase request to app {"error": "Post \"http://localhost:8080:8080/products\": dial tcp: lookup localhost:8080: no such host"}

Also, I'm on arch linux.

@charankamarapu
Copy link
Member

you don't need to add --host flag.

@slashexx
Copy link
Author

slashexx commented Nov 29, 2024

you don't need to add --host flag.

Sure, I just attempted with it once.

I keep getting this otherwise when I don't put any flags (other than the delay one, ofc):-
Keploy: 2024-11-29T13:12:01+05:30 INFO starting test for of {"test case": "[test-1]", "test set": "[test-set-0]"} 🐰 Keploy: 2024-11-29T13:12:01+05:30 ERROR failed to send testcase request to app {"error": "Post \"http://localhost:8080/products\": dial tcp: lookup localhost on 192.168.1.1:53: no such host"}

@charankamarapu
Copy link
Member

This might be a DNS problem in your laptop try connecting to other wifi and try restarting laptop and try again.

@slashexx
Copy link
Author

This might be a DNS problem in your laptop try connecting to other wifi and try restarting laptop and try again.

Okay it seems this was the issue. It's fixed now, thank you very much !

Just be clear now, I'm supposed to push the reports folder as well right ? Because the .gitignore file automatically excluded it.

samples-java/spring-boot-r/keploy > tree                                                                

├── reports
│   ├── test-run-0
│   │   └── test-set-0-report.yaml
│   ├── test-run-1
│   │   └── test-set-0-report.yaml
│   ├── test-run-2
│   │   └── test-set-0-report.yaml
│   ├── test-run-3
│   │   └── test-set-0-report.yaml
│   └── test-run-4
│       └── test-set-0-report.yaml
└── test-set-0
    ├── mocks.yaml
    └── tests
        ├── test-10.yaml
        ├── test-1.yaml
        ├── test-2.yaml
        ├── test-3.yaml
        ├── test-4.yaml
        ├── test-5.yaml
        ├── test-6.yaml
        ├── test-7.yaml
        ├── test-8.yaml
        └── test-9.yaml

9 directories, 16 files

Signed-off-by: slashexx <[email protected]>
@charankamarapu
Copy link
Member

No you can just add the screenshot of the tests getting passed in the cli

@slashexx
Copy link
Author

sure thing
image
image
image
image

@slashexx
Copy link
Author

slashexx commented Nov 30, 2024

@charankamarapu gentle ping, can you review if this is good to go ?

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

Successfully merging this pull request may close these issues.

2 participants