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

Improve mocking capabilities #5257

Closed
Donnerbart opened this issue Jun 15, 2023 · 0 comments · Fixed by #5258
Closed

Improve mocking capabilities #5257

Donnerbart opened this issue Jun 15, 2023 · 0 comments · Fixed by #5258
Assignees
Milestone

Comments

@Donnerbart
Copy link
Contributor

Is your enhancement related to a problem? Please describe

It's hard to mock pods/exec calls for other stream IDs than stdout:

server.expect()
    .withPath("/api/v1/namespaces/test/pods/pod1/exec?command=ls&container=debug&stdout=true")
    .andUpgradeToWebSocket()
    .open(new OutputStreamMessage(expectedOutput))
    .done()
    .always();

Describe the solution you'd like

The client should provide ErrorStreamMessage and StatusStreamMessage to support mocking like:

server.expect()
  .withPath("/api/v1/namespaces/test/pods/pod1/exec?command=ls&container=default&stderr=true")
  .andUpgradeToWebSocket()
  .open(new ErrorStreamMessage(expectedError))
  .done()
  .always();
server.expect()
  .withPath("/api/v1/namespaces/test/pods/pod1/exec?command=ls&container=default&stdout=true")
  .andUpgradeToWebSocket()
  .open(new StatusStreamMessage(1))
  .done()
  .always();

Describe alternatives you've considered

I've written the classes for our project, but this needs some code duplication, because we cannot re-use the private method getBodyBytes() from OutputStreamMessage.

Additional context

No response

@manusa manusa added this to the 6.9.0 milestone Sep 6, 2023
manusa pushed a commit that referenced this issue Sep 6, 2023
…king of pods/exec requests (#5258)

* Add ErrorStreamMessage and StatusStreamMessage to ease mocking of pods/exec requests

* Fix warnings in PodTest
Ananya2001-an added a commit to Ananya2001-an/kubernetes-client that referenced this issue Sep 7, 2023
chore:  add create namespace kubectl equivalent example

docs: add link to example in README

chore: separated creation of namespace and logging

fix: sonarcloud issue with printStackTrace

remove io.fabric8.kubernetes.model.annotation.PrinterColumn

Fix fabric8io#5257: Add ErrorStreamMessage and StatusStreamMessage to ease mocking of pods/exec requests (fabric8io#5258)

* Add ErrorStreamMessage and StatusStreamMessage to ease mocking of pods/exec requests

* Fix warnings in PodTest

refactor: follow-up on fabric8io#5258

Signed-off-by: Marc Nuri <marc@marcnuri.com>

doc: invite users to report issues with a specific document

Signed-off-by: Marc Nuri <marc@marcnuri.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants