From 5a4f61591d7b5e3966c1f38f85c86a7ed6839fb2 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 8 Nov 2020 23:02:09 -0800 Subject: [PATCH] adjust for tests --- api/v1/seaweed_types.go | 2 ++ api/v1/zz_generated.deepcopy.go | 5 +++++ config/crd/bases/seaweed.seaweedfs.com_seaweeds.yaml | 3 +++ controllers/controller_master.go | 6 ++++-- controllers/seaweed_controller_test.go | 10 ++++++++-- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/api/v1/seaweed_types.go b/api/v1/seaweed_types.go index 9e8681f..4581623 100644 --- a/api/v1/seaweed_types.go +++ b/api/v1/seaweed_types.go @@ -126,6 +126,8 @@ type MasterSpec struct { GarbageThreshold *string `json:"garbageThreshold,omitempty"` PulseSeconds *int32 `json:"pulseSeconds,omitempty"` DefaultReplication *string `json:"defaultReplication,omitempty"` + // only for testing + ConcurrentStart *bool `json:"concurrentStart,omitempty"` } // VolumeSpec is the spec for volume servers diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index a212359..0428b28 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -185,6 +185,11 @@ func (in *MasterSpec) DeepCopyInto(out *MasterSpec) { *out = new(string) **out = **in } + if in.ConcurrentStart != nil { + in, out := &in.ConcurrentStart, &out.ConcurrentStart + *out = new(bool) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MasterSpec. diff --git a/config/crd/bases/seaweed.seaweedfs.com_seaweeds.yaml b/config/crd/bases/seaweed.seaweedfs.com_seaweeds.yaml index fcb9543..e40ac82 100644 --- a/config/crd/bases/seaweed.seaweedfs.com_seaweeds.yaml +++ b/config/crd/bases/seaweed.seaweedfs.com_seaweeds.yaml @@ -2123,6 +2123,9 @@ spec: description: Annotations of the component. Merged into the cluster-level annotations if non-empty type: object + concurrentStart: + description: only for testing + type: boolean config: description: Config in raw toml string type: string diff --git a/controllers/controller_master.go b/controllers/controller_master.go index b375fa0..2662985 100644 --- a/controllers/controller_master.go +++ b/controllers/controller_master.go @@ -35,8 +35,10 @@ func (r *SeaweedReconciler) ensureMaster(seaweedCR *seaweedv1.Seaweed) (done boo return } - if done, result, err = r.waitForMasterStatefulSet(seaweedCR); done { - return + if !*seaweedCR.Spec.Master.ConcurrentStart { + if done, result, err = r.waitForMasterStatefulSet(seaweedCR); done { + return + } } return diff --git a/controllers/seaweed_controller_test.go b/controllers/seaweed_controller_test.go index b13914b..ac33ae6 100644 --- a/controllers/seaweed_controller_test.go +++ b/controllers/seaweed_controller_test.go @@ -15,6 +15,11 @@ import ( seaweedv1 "github.com/seaweedfs/seaweedfs-operator/api/v1" ) +var ( + TrueValue = true + FalseVallue = false +) + var _ = Describe("Seaweed Controller", func() { Context("Basic Functionality", func() { It("Should create StatefulSets", func() { @@ -34,10 +39,11 @@ var _ = Describe("Seaweed Controller", func() { Name: name, }, Spec: seaweedv1.SeaweedSpec{ - Image: "chrislusf/seaweedfs:2.07", + Image: "chrislusf/seaweedfs:2.09", VolumeServerDiskCount: 1, Master: &seaweedv1.MasterSpec{ - Replicas: 3, + Replicas: 3, + ConcurrentStart: &TrueValue, }, Volume: &seaweedv1.VolumeSpec{ Replicas: 1,