-
Notifications
You must be signed in to change notification settings - Fork 98
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
enchancement: updated naming convention from clientSet to dynamicClient (#203) #476
Closed
Closed
Changes from all commits
Commits
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
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 |
---|---|---|
|
@@ -48,10 +48,10 @@ import ( | |
) | ||
|
||
var ( | ||
kubeconfig string | ||
config *restclient.Config | ||
client *kubernetes.Clientset | ||
clientSet *chaosClient.LitmuschaosV1alpha1Client | ||
kubeconfig string | ||
config *restclient.Config | ||
client *kubernetes.Clientset | ||
dynamicClient *chaosClient.LitmuschaosV1alpha1Client | ||
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. Can we change it to litmusClient as this is not a dynamic client? and change the rest of the places as well in this file |
||
) | ||
|
||
func TestChaos(t *testing.T) { | ||
|
@@ -70,8 +70,8 @@ var _ = BeforeSuite(func() { | |
client, err = kubernetes.NewForConfig(config) | ||
Expect(err).To(BeNil(), "failed to get client") | ||
|
||
clientSet, err = chaosClient.NewForConfig(config) | ||
Expect(err).To(BeNil(), "failed to get clientSet") | ||
dynamicClient, err = chaosClient.NewForConfig(config) | ||
Expect(err).To(BeNil(), "failed to get dynamicClient") | ||
|
||
err = v1alpha1.AddToScheme(scheme.Scheme) | ||
Expect(err).To(BeNil()) | ||
|
@@ -226,7 +226,7 @@ var _ = Describe("BDD on chaos-operator", func() { | |
}, | ||
} | ||
|
||
_, err = clientSet.ChaosExperiments("litmus").Create(context.Background(), ChaosExperiment, metav1.CreateOptions{}) | ||
_, err = dynamicClient.ChaosExperiments("litmus").Create(context.Background(), ChaosExperiment, metav1.CreateOptions{}) | ||
Expect(err).To(BeNil()) | ||
klog.Infoln("ChaosExperiment created successfully...") | ||
|
||
|
@@ -260,7 +260,7 @@ var _ = Describe("BDD on chaos-operator", func() { | |
}, | ||
} | ||
|
||
_, err = clientSet.ChaosEngines("litmus").Create(context.Background(), chaosEngine, metav1.CreateOptions{}) | ||
_, err = dynamicClient.ChaosEngines("litmus").Create(context.Background(), chaosEngine, metav1.CreateOptions{}) | ||
Expect(err).To(BeNil()) | ||
klog.Infoln("Chaosengine created successfully...") | ||
|
||
|
@@ -284,7 +284,7 @@ var _ = Describe("BDD on chaos-operator", func() { | |
klog.Infoln("runner pod created") | ||
|
||
// Check for EngineStatus | ||
engine, err := clientSet.ChaosEngines("litmus").Get(context.Background(), "engine-nginx", metav1.GetOptions{}) | ||
engine, err := dynamicClient.ChaosEngines("litmus").Get(context.Background(), "engine-nginx", metav1.GetOptions{}) | ||
Expect(err).To(BeNil()) | ||
|
||
isInit := engine.Status.EngineStatus == v1alpha1.EngineStatusInitialized | ||
|
@@ -296,21 +296,21 @@ var _ = Describe("BDD on chaos-operator", func() { | |
|
||
It("Should delete chaos-resources", func() { | ||
|
||
engine, err := clientSet.ChaosEngines("litmus").Get(context.Background(), "engine-nginx", metav1.GetOptions{}) | ||
engine, err := dynamicClient.ChaosEngines("litmus").Get(context.Background(), "engine-nginx", metav1.GetOptions{}) | ||
Expect(err).To(BeNil()) | ||
|
||
// setting the EngineState of chaosEngine to stop | ||
engine.Spec.EngineState = v1alpha1.EngineStateStop | ||
|
||
_, err = clientSet.ChaosEngines("litmus").Update(context.Background(), engine, metav1.UpdateOptions{}) | ||
_, err = dynamicClient.ChaosEngines("litmus").Update(context.Background(), engine, metav1.UpdateOptions{}) | ||
Expect(err).To(BeNil()) | ||
klog.Infoln("Chaosengine updated successfully...") | ||
|
||
err = retry. | ||
Times(uint(180 / 2)). | ||
Wait(time.Duration(2) * time.Second). | ||
Try(func(attempt uint) error { | ||
engine, err := clientSet.ChaosEngines("litmus").Get(context.Background(), "engine-nginx", metav1.GetOptions{}) | ||
engine, err := dynamicClient.ChaosEngines("litmus").Get(context.Background(), "engine-nginx", metav1.GetOptions{}) | ||
if err != nil { | ||
return fmt.Errorf("unable to get chaosengine, err: %v", err) | ||
} | ||
|
@@ -350,7 +350,7 @@ var _ = Describe("BDD on chaos-operator", func() { | |
Wait(time.Duration(2) * time.Second). | ||
Try(func(attempt uint) error { | ||
//Fetching engineStatus | ||
engine, err := clientSet.ChaosEngines("litmus").Get(context.Background(), "engine-nginx", metav1.GetOptions{}) | ||
engine, err := dynamicClient.ChaosEngines("litmus").Get(context.Background(), "engine-nginx", metav1.GetOptions{}) | ||
Expect(err).To(BeNil()) | ||
if engine.Status.EngineStatus != v1alpha1.EngineStatusStopped { | ||
fmt.Printf("engine is not in stopped state") | ||
|
@@ -364,13 +364,13 @@ var _ = Describe("BDD on chaos-operator", func() { | |
Context("Deletion of ChaosEngine", func() { | ||
It("Should delete chaos engine", func() { | ||
|
||
err := clientSet.ChaosEngines("litmus").Delete(context.Background(), "engine-nginx", metav1.DeleteOptions{}) | ||
err := dynamicClient.ChaosEngines("litmus").Delete(context.Background(), "engine-nginx", metav1.DeleteOptions{}) | ||
Expect(err).To(BeNil()) | ||
err = retry. | ||
Times(uint(180 / 2)). | ||
Wait(time.Duration(2) * time.Second). | ||
Try(func(attempt uint) error { | ||
_, err := clientSet.ChaosEngines("litmus").Get(context.Background(), "engine-nginx", metav1.GetOptions{}) | ||
_, err := dynamicClient.ChaosEngines("litmus").Get(context.Background(), "engine-nginx", metav1.GetOptions{}) | ||
if err != nil && !k8serrors.IsNotFound(err) { | ||
return fmt.Errorf("unable to get chaosengine, err: %v", err) | ||
} | ||
|
@@ -415,7 +415,7 @@ var _ = Describe("BDD on chaos-operator", func() { | |
}, | ||
} | ||
|
||
_, err := clientSet.ChaosEngines("litmus").Create(context.Background(), chaosEngine, metav1.CreateOptions{}) | ||
_, err := dynamicClient.ChaosEngines("litmus").Create(context.Background(), chaosEngine, metav1.CreateOptions{}) | ||
Expect(err).To(BeNil()) | ||
}) | ||
}) | ||
|
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.
Can we revert this change as this is not a dynamic client?