-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add helpers #72
Merged
Merged
Add helpers #72
Changes from 19 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
a226afe
Refactor API for reusing resource operations
pablochacin bd739d8
Implement helpers structure
pablochacin 556444c
Add helpers for handling unstructured objects
pablochacin 6750b3d
Add update function
pablochacin bf67984
Add helpers for handling structured objects
pablochacin 286481c
Improve resource pkg tests
pablochacin 6a14c49
Implement namespace helper
pablochacin 5e769ca
Add pods helpers
pablochacin 30a6f54
Implement service helper
pablochacin d917713
Use int instead of duration in helpers' api
pablochacin ef935a8
Handle special case of namespace creation
pablochacin 0f6904d
Do not return error on timeout retrying
pablochacin a04adca
Use retry in waitPodWaiting
pablochacin 3527874
Remove watch function
pablochacin 84bd4f7
Fix race conditions in tests
pablochacin 7b8c611
Implement test for helpers scriptability
pablochacin bc214e8
Add GetExternalIP helper function
pablochacin d7c9b59
Document helpers
pablochacin 6e99cfa
Simplify namespace handling in helpers
pablochacin 0e11b19
Adapt examples to changes in helpers
pablochacin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Kubernetes } from 'k6/x/kubernetes'; | ||
|
||
let pod = { | ||
apiVersion: "v1", | ||
kind: "Pod", | ||
metadata: { | ||
name: "busybox", | ||
namespace: "default" | ||
}, | ||
spec: { | ||
containers: [ | ||
{ | ||
name: "busybox", | ||
image: "busybox", | ||
command: ["sh", "-c", "sleep 30"] | ||
} | ||
] | ||
} | ||
} | ||
|
||
export default function () { | ||
const kubernetes = new Kubernetes(); | ||
|
||
// create namespace with random name with prefix 'test-' | ||
const ns = kubernetes.helpers().createRandomNamespace("test-") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Script needs to be updated for latest changes. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. Fixed |
||
//const ns = "default" | ||
|
||
// create pod in test namespace | ||
pod.metadata.namespace = ns | ||
kubernetes.create(pod) | ||
|
||
// get helpers for test namespace | ||
const helpers = kubernetes.namespacedHelpers(ns) | ||
|
||
// wait for pod to be running | ||
const timeout = 10 | ||
if (!helpers.waitPodRunning(pod.metadata.name, timeout)) { | ||
console.log(`"pod ${pod.metadata.name} not ready after ${timeout} seconds`) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should
apply
simply perform either a create or update depending upon existence? Have explicit calls tocreate
fail if a resource is already there.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apply recieves a yaml. Update receives an object. These are two different operations.