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

MockWebServer bump, refactor and enhancements #3562

Merged
merged 6 commits into from
Nov 8, 2021

Conversation

manusa
Copy link
Member

@manusa manusa commented Nov 3, 2021

Description

The new KubernetesMixedDispatcher allows the user to create expectations on top of the default CRUD KubernetesMockServer behavior. This way non-resource endpoints (such as /version), can be mocked while the rest of the CRUD features are preserved (/cc @metacosm)

With the current approach, a user still needs to create a manual expectation for the version endpoint:

    server.expect().get().withPath("/version")
      .andReturn(200, "{\"major\": \"13\", \"minor\": \"37\"}").always();

This can be further improved if we add a hardcoded expectation here:

expect().get().withPath("/").andReturn(200, new RootPathsBuilder().addToPaths(getRootPaths()).build()).always();

But I'm not sure if that would bother the rest of users.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change
  • Chore (non-breaking change which doesn't affect codebase;
    test, version modification, documentation, etc.)

Checklist

  • Code contributed by me aligns with current project license: Apache 2.0
  • I Added CHANGELOG entry regarding this change
  • I have implemented unit tests to cover my changes
  • I have added/updated the javadocs and other documentation accordingly
  • No new bugs, code smells, etc. in SonarCloud report
  • I tested my code in Kubernetes
  • I tested my code in OpenShift

@manusa manusa added the wip label Nov 3, 2021
@centos-ci
Copy link

Can one of the admins verify this patch?

@manusa manusa force-pushed the deps/mockwebserver branch 2 times, most recently from 4744758 to 15b88a0 Compare November 3, 2021 11:13
@manusa manusa added this to the 5.10.0 milestone Nov 3, 2021
@manusa manusa force-pushed the deps/mockwebserver branch 4 times, most recently from cddc112 to 53fab12 Compare November 3, 2021 15:11
@manusa manusa removed the wip label Nov 3, 2021
@manusa manusa marked this pull request as ready for review November 3, 2021 16:32
@manusa manusa requested a review from shawkins November 3, 2021 16:32
@manusa manusa changed the title deps: bump mockwebserver MockWebServer bump, refactor and enhancements Nov 4, 2021
@manusa manusa requested a review from metacosm November 4, 2021 13:37
@metacosm
Copy link
Collaborator

metacosm commented Nov 4, 2021

This seems to indeed fix the issue when you get direct access to the KubernetesMockServer. When using Quarkus, though, you don't always get direct access, in particular when using the QuarkusTestResource annotation, so it's a little annoying to have to create a specific extension of KubernetesServerTestResource just to be able to set up the version endpoint for example, so it'd indeed be nice if we could have some hardcoded expectations to make things easier.

@manusa
Copy link
Member Author

manusa commented Nov 5, 2021

so it'd indeed be nice if we could have some hardcoded expectations to make things easier.

It seems it shouldn't do any harm, so I finally added the hardcoded expectation for the version endpoint

@sonarcloud
Copy link

sonarcloud bot commented Nov 5, 2021

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

47.6% 47.6% Coverage
0.0% 0.0% Duplication

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.

KubernetesServerMock CRUD mode doesn't provide valid responses for client.getXxxxVersion
5 participants