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

Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function #286

Merged
merged 40 commits into from
Apr 7, 2023

Conversation

moomman
Copy link
Contributor

@moomman moomman commented Mar 27, 2023

  1. Add basic convert type: Selector,Pod Chaos,Network Chaos,WorkFlow.
  2. Add convert functions in Controller.Add convert and create chaos logic in Reconcile function.
  3. Add ChaoKind Enums

I have tested it usage in kubenetes environment.It works well As expected.

#272

@mlycore
Copy link
Contributor

mlycore commented Mar 28, 2023

Need add unit test with ginkgo.

@mlycore mlycore added type: enhancement New feature or request operator solutions of operator in: feature labels Mar 28, 2023
@mlycore mlycore added this to the 0.3.0 milestone Mar 28, 2023
…kup file, and fix backup mode ptrack did not work. (apache#288)
Copy link
Collaborator

@Xu-Wentao Xu-Wentao Apr 3, 2023

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.

Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks,bro

Copy link
Collaborator

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

@Xu-Wentao
Copy link
Collaborator

lgtm

mlycore and others added 11 commits April 5, 2023 23:14
…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
@mlycore mlycore merged commit cf4e840 into apache:feat-sschaos Apr 7, 2023
@mlycore
Copy link
Contributor

mlycore commented Apr 7, 2023

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: feature operator solutions of operator type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants