-
Notifications
You must be signed in to change notification settings - Fork 28
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 ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function #286
Conversation
Need add unit test with |
…kup file, and fix backup mode ptrack did not work. (apache#288)
shardingsphere-operator/api/v1alpha1/shardingsphere_chaos_types.go
Outdated
Show resolved
Hide resolved
shardingsphere-operator/pkg/kubernetes/chaos/chaos_mesh_impl.go
Outdated
Show resolved
Hide resolved
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.
you can use fakeClient
to mock client.Client. below is a simple example.
import (
// import other needed packages...
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)
var fakeClient client.Client
// your new reconciler or controller
var reconciler *YourReconciler
// register some CRD or resources for your need.
scheme := runtime.NewScheme()
Expect(corev1.AddToScheme(scheme)).To(Succeed())
Expect(appsv1.AddToScheme(scheme)).To(Succeed())
fakeClient = fake.NewClientBuilder().WithScheme(scheme).Build()
reconciler = &controllers.YourController{}
req := reconcile.Request{
NamespacedName: client.ObjectKey{
Namespace: "test-namespace",
Name: "test-resource",
},
}
// create some resource if needed by fakeClient.Create()
// Expect(fakeClient.Create(context.Background(), &appsv1.Deployment{})).To(Succeed())
// ...
res, err := reconciler.Reconcile(context.Background(), req)
Expect(err).NotTo(HaveOccurred())
// handle res if needed.
// ...
you can move some common code to ginkgo's BeforeEach
and AfterEach
. Please help yourself.
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.
here's a doc may help u :)
k8s-unittest-guide
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.
thanks,bro
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.
add an example of test with envtest:
testing-kubernetes-operator-envtest
shardingsphere-operator/api/v1alpha1/shardingsphere_chaos_types.go
Outdated
Show resolved
Hide resolved
shardingsphere-operator/api/v1alpha1/shardingsphere_chaos_types.go
Outdated
Show resolved
Hide resolved
shardingsphere-operator/api/v1alpha1/shardingsphere_chaos_types.go
Outdated
Show resolved
Hide resolved
lgtm |
…ache#294) * chore: add golangci-lint check config and update Makefile for check * fix: fix according to golangci-lint * fix: rename Api to API * fix: fix sharedVolumeAndMountBuild SetVolumeMountSize non-zero slice * fix: remove overlapped Build method from shardingSphereProxyContainerBuilder * chore: add license header
* chore(ci): add golangci-lint to github action Signed-off-by: mlycore <maxwell92@126.com> * chore(ci): seperate unit tests Signed-off-by: mlycore <maxwell92@126.com> * chore(ci): add golangci-lint for pitr Signed-off-by: mlycore <maxwell92@126.com> * chore(ci): fix license header Signed-off-by: mlycore <maxwell92@126.com> --------- Signed-off-by: mlycore <maxwell92@126.com>
* chore: seperate golangci-lint to base and advanced lints Signed-off-by: mlycore <maxwell92@126.com> * fix: introduce CondSucceed to Proxy and ComputeNode status Signed-off-by: mlycore <maxwell92@126.com> * chore: fix according to golangci-lint Signed-off-by: mlycore <maxwell92@126.com> * chore: refactor according to golangci-lint Signed-off-by: mlycore <maxwell92@126.com> * chore: update golangci-lint Signed-off-by: mlycore <maxwell92@126.com> * chore: remove loggercheck Signed-off-by: mlycore <maxwell92@126.com> * fix: fix unit test Signed-off-by: mlycore <maxwell92@126.com> * chore(ci): seperate golint to operator and pitr Signed-off-by: mlycore <maxwell92@126.com> * chore: add lint for commit message Signed-off-by: mlycore <maxwell92@126.com> --------- Signed-off-by: mlycore <maxwell92@126.com>
* chore: update golangci-lint Signed-off-by: mlycore <maxwell92@126.com> * chore: fix according to golangci-lint Signed-off-by: mlycore <maxwell92@126.com> * refactor: refactor update service with computenode Signed-off-by: mlycore <maxwell92@126.com> * fix: update service Signed-off-by: mlycore <maxwell92@126.com> * refactor: refactor proxy controller reconcile hpa, deployment and configmap according to golangci-lint Signed-off-by: mlycore <maxwell92@126.com> * chore: update commit-msg action Signed-off-by: mlycore <maxwell92@126.com> --------- Signed-off-by: mlycore <maxwell92@126.com>
Signed-off-by: mlycore <maxwell92@126.com>
Signed-off-by: mlycore <maxwell92@126.com>
Signed-off-by: mlycore <maxwell92@126.com>
Signed-off-by: mlycore <maxwell92@126.com>
Signed-off-by: mlycore <maxwell92@126.com>
Signed-off-by: mlycore <maxwell92@126.com>
refactor: refactor computenode and proxy controller deployment according to golangci-lint
LGTM |
I have tested it usage in kubenetes environment.It works well As expected.
#272