Skip to content

Feature/issues/2334/create elastic spring app #80

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

Conversation

Yordaniss
Copy link

@Yordaniss Yordaniss commented Oct 12, 2024

Pull Request Template

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes (Create a Springboot-Elastic sample app)

Type of change

Please delete options that are not relevant.

  • 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?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Create book: POST /book/create
  • Search books by name: GET /book/find_by_name

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

...

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 incase my pull request is ready for a review
  • I have signed the commit message to agree to Developer Certificate of Origin (DCO) (to certify that you wrote or otherwise have the right to submit your contribution to the project.) by adding "--signoff" to my git commit command.

@Yordaniss Yordaniss force-pushed the feature/issues/2334/create-elastic-spring-app branch from e7331a1 to 1482c87 Compare October 13, 2024 06:03
@Sonichigo Sonichigo requested a review from Sarthak160 October 14, 2024 08:00
@Yordaniss Yordaniss force-pushed the feature/issues/2334/create-elastic-spring-app branch from cd0e40b to 2ec8fbd Compare October 14, 2024 19:47
@Sarthak160
Copy link
Member

@Yordaniss, Hey seems there is no mocks in this PR can you check if they were recorded or not locally ? Since ElasticSearch internally use HTTP, there should be outgoing http mocks.

@Yordaniss
Copy link
Author

Yordaniss commented Oct 14, 2024

You mean this mocks.yaml with thousands lines?

@Yordaniss Yordaniss force-pushed the feature/issues/2334/create-elastic-spring-app branch from a3b08f4 to 860025e Compare October 16, 2024 19:55
@Yordaniss
Copy link
Author

Hey @Sarthak160 Thanks for advice. I also added mocks.yaml and have run all test cases. Everything looks fine now

@Sarthak160
Copy link
Member

Hey @Yordaniss Seems your application is making some external calls to fetch some spring assets -

version: api.keploy.io/v1beta1
kind: Http
name: mock-0
spec:
    metadata:
        name: Http
        operation: GET
        type: HTTP_CLIENT
    req:
        method: GET
        proto_major: 1
        proto_minor: 1
        url: /maven2/org/springframework/boot/spring-boot-buildpack-platform/3.3.4/spring-boot-buildpack-platform-3.3.4.pom
        header:
            Accept-Encoding: gzip,deflate
            Cache-Control: no-cache
            Connection: Keep-Alive
            Pragma: no-cache
            User-Agent: Apache-Maven/3.8.7 (Java 21.0.4; Linux 5.15.153.1-microsoft-standard-WSL2)
        body: ""
        timestamp: 0001-01-01T00:00:00Z
    resp:
        status_code: 200
        header:
            Accept-Ranges: bytes
            Age: "1775105"
            Connection: keep-alive
            Content-Length: "3213"
            Content-Type: text/xml
            Date: Mon, 14 Oct 2024 19:36:45 GMT
            Etag: '"e5e655cd1dacac6c926a9d18d7307644"'
            Last-Modified: Thu, 19 Sep 2024 10:52:18 GMT
            Via: 1.1 varnish, 1.1 varnish
            X-Cache: HIT, HIT
            X-Cache-Hits: 8, 3
            X-Checksum-Md5: e5e655cd1dacac6c926a9d18d7307644
            X-Checksum-Sha1: 7d8300f8d20ee7a43339a92224a502f36d715e8a
            X-Served-By: cache-iad-kcgs7200125-IAD, cache-fra-eddf8230029-FRA
            X-Timer: S1728934605.320665,VS0,VE0

You can use passthrough via keploy config and add these particular enpoints to avoid getting recorded as mocks.
Please refer this for more details - https://keploy.io/docs/running-keploy/keploy-passthrough/#heading

* init new app
* added controller, service, model and client
* added dependencies

Signed-off-by: Snoopy009 <wernerdmytro@gmail.com>
* clean up
* improvements

Signed-off-by: Snoopy009 <wernerdmytro@gmail.com>
* added readme file

Signed-off-by: Snoopy009 <wernerdmytro@gmail.com>
* added test cases

Signed-off-by: Snoopy009 <wernerdmytro@gmail.com>
* run the tests
* added mocks file

Signed-off-by: Snoopy009 <wernerdmytro@gmail.com>
* rerun tests with keploy passthrough

Signed-off-by: Snoopy009 <wernerdmytro@gmail.com>
@Yordaniss Yordaniss force-pushed the feature/issues/2334/create-elastic-spring-app branch from a0b3480 to c61ef04 Compare October 24, 2024 19:34
@Yordaniss
Copy link
Author

Hey @Yordaniss Seems your application is making some external calls to fetch some spring assets -

version: api.keploy.io/v1beta1
kind: Http
name: mock-0
spec:
    metadata:
        name: Http
        operation: GET
        type: HTTP_CLIENT
    req:
        method: GET
        proto_major: 1
        proto_minor: 1
        url: /maven2/org/springframework/boot/spring-boot-buildpack-platform/3.3.4/spring-boot-buildpack-platform-3.3.4.pom
        header:
            Accept-Encoding: gzip,deflate
            Cache-Control: no-cache
            Connection: Keep-Alive
            Pragma: no-cache
            User-Agent: Apache-Maven/3.8.7 (Java 21.0.4; Linux 5.15.153.1-microsoft-standard-WSL2)
        body: ""
        timestamp: 0001-01-01T00:00:00Z
    resp:
        status_code: 200
        header:
            Accept-Ranges: bytes
            Age: "1775105"
            Connection: keep-alive
            Content-Length: "3213"
            Content-Type: text/xml
            Date: Mon, 14 Oct 2024 19:36:45 GMT
            Etag: '"e5e655cd1dacac6c926a9d18d7307644"'
            Last-Modified: Thu, 19 Sep 2024 10:52:18 GMT
            Via: 1.1 varnish, 1.1 varnish
            X-Cache: HIT, HIT
            X-Cache-Hits: 8, 3
            X-Checksum-Md5: e5e655cd1dacac6c926a9d18d7307644
            X-Checksum-Sha1: 7d8300f8d20ee7a43339a92224a502f36d715e8a
            X-Served-By: cache-iad-kcgs7200125-IAD, cache-fra-eddf8230029-FRA
            X-Timer: S1728934605.320665,VS0,VE0

You can use passthrough via keploy config and add these particular enpoints to avoid getting recorded as mocks. Please refer this for more details - https://keploy.io/docs/running-keploy/keploy-passthrough/#heading

@Sarthak160 Thanks for advice. I recorded test with keploy passthrough and run test cases. Everything looks fine now. I hope ^^

version: api.keploy.io/v1beta1
name: test-set-1-report
status: PASSED
success: 2
failure: 0
ignored: 0
total: 2

@Sarthak160
Copy link
Member

Hey @Yordaniss I was trying to run your application with java 1.8 on my system it gave me error -

➜  spring-elastic git:(feature/issues/2334/create-elastic-spring-app) ✗ java -jar target/spring-elastic-0.0.1-SNAPSHOT.jar
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/example/spring_elastic/SpringElasticApplication has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 61.0
        at java.base/java.lang.ClassLoader.defineClass1(Native Method)
        at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
        at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
        at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:524)
        at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:427)
        at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:421)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:420)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:592)
        at org.springframework.boot.loader.net.protocol.jar.JarUrlClassLoader.loadClass(JarUrlClassLoader.java:107)
        at org.springframework.boot.loader.launch.LaunchedClassLoader.loadClass(LaunchedClassLoader.java:91)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:467)
        at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:99)
        at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:64)
        at org.springframework.boot.loader.launch.JarLauncher.main(JarLauncher.java:40)

Could you also make it compatible for this java version as well.

@Hermione2408
Copy link
Member

Closing this PR as it has been inactive for a long time. Feel free to reopen if needed.

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.

Create a Springboot-Elastic sample app
3 participants