mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-27 16:17:34 +00:00
Feat(delay suspend): delayDuration in suspend step properties (#3644)
* Feat(delay suspend): add delayDuration in suspend step properties to support delay by certain time.Duration Signed-off-by: suxiang <suxiang@asiainfo.com> Signed-off-by: ArenaSu <704427617@qq.com> * Feat(delay suspend): add delayDuration parameter to suspend cue Signed-off-by: ArenaSu <704427617@qq.com> * Feat(wait suspend): optimize wait suspend Signed-off-by: ArenaSu <704427617@qq.com> * Feat(wait suspend): change e2e test to local cluster env Signed-off-by: ArenaSu <704427617@qq.com> * Feat(wait suspend): fix WaitSuspend status modify bug Signed-off-by: ArenaSu <704427617@qq.com> * Feat(wait suspend): suspend cue parameter type error Signed-off-by: ArenaSu <704427617@qq.com> * Feat(wait suspend): set waitDuration optional param in suspend workflow step Signed-off-by: ArenaSu <704427617@qq.com> * Feat(wait suspend): add lost suspend.yaml Signed-off-by: ArenaSu <704427617@qq.com> * Feat(wait suspend): change solution to add suspendState Signed-off-by: ArenaSu <704427617@qq.com> * Feat(wait suspend): change durationWaiting to duration and add isPatch to gcResourceTrackers Signed-off-by: ArenaSu <704427617@qq.com>
This commit is contained in:
@@ -135,6 +135,59 @@ var _ = Describe("Application Normal tests", func() {
|
||||
}, 120*time.Second, time.Second).Should(BeNil())
|
||||
}
|
||||
|
||||
verifyApplicationDelaySuspendExpected := func(ns, appName, suspendStep, nextStep, duration string) {
|
||||
var testApp v1beta1.Application
|
||||
Eventually(func() error {
|
||||
waitDuration, err := time.ParseDuration(duration)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = k8sClient.Get(ctx, client.ObjectKey{Namespace: ns, Name: appName}, &testApp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if testApp.Status.Workflow == nil {
|
||||
return fmt.Errorf("application wait to start workflow")
|
||||
}
|
||||
|
||||
if testApp.Status.Workflow.Finished {
|
||||
var suspendStartTime, nextStepStartTime metav1.Time
|
||||
var sFlag, nFlag bool
|
||||
|
||||
for _, wfStatus := range testApp.Status.Workflow.Steps {
|
||||
if wfStatus.Name == suspendStep {
|
||||
suspendStartTime = wfStatus.FirstExecuteTime
|
||||
sFlag = true
|
||||
continue
|
||||
}
|
||||
|
||||
if wfStatus.Name == nextStep {
|
||||
nextStepStartTime = wfStatus.FirstExecuteTime
|
||||
nFlag = true
|
||||
}
|
||||
}
|
||||
|
||||
if !sFlag {
|
||||
return fmt.Errorf("application can not find suspend step: %s", suspendStep)
|
||||
}
|
||||
|
||||
if !nFlag {
|
||||
return fmt.Errorf("application can not find next step: %s", nextStep)
|
||||
}
|
||||
|
||||
dd := nextStepStartTime.Sub(suspendStartTime.Time)
|
||||
if waitDuration > dd {
|
||||
return fmt.Errorf("application suspend wait duration wants more than %s, actually %s", duration, dd.String())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("application status workflow finished wants true, actually false")
|
||||
}, 120*time.Second, time.Second).Should(BeNil())
|
||||
}
|
||||
|
||||
verifyWorkloadRunningExpected := func(workloadName string, replicas int32, image string) {
|
||||
var workload v1.Deployment
|
||||
By("Verify Workload running as expected")
|
||||
@@ -284,6 +337,17 @@ var _ = Describe("Application Normal tests", func() {
|
||||
verifyApplicationWorkflowSuspending(newApp.Namespace, newApp.Name)
|
||||
})
|
||||
|
||||
It("Test wait suspend", func() {
|
||||
By("Apply wait suspend application")
|
||||
var newApp v1beta1.Application
|
||||
Expect(common.ReadYamlToObject("testdata/app/app_wait_suspend.yaml", &newApp)).Should(BeNil())
|
||||
newApp.Namespace = namespaceName
|
||||
Expect(k8sClient.Create(ctx, &newApp)).Should(BeNil())
|
||||
|
||||
By("check application suspend duration")
|
||||
verifyApplicationDelaySuspendExpected(newApp.Namespace, newApp.Name, "suspend-test", "apply-wait-suspend-comp", "30s")
|
||||
})
|
||||
|
||||
It("Test app with ServiceAccount", func() {
|
||||
By("Creating a ServiceAccount")
|
||||
const saName = "app-service-account"
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: wait-suspend-test
|
||||
spec:
|
||||
components:
|
||||
- name: wait-suspend-comp
|
||||
type: webservice
|
||||
properties:
|
||||
image: nginx
|
||||
port: 80
|
||||
workflow:
|
||||
steps:
|
||||
- name: suspend-test
|
||||
type: suspend
|
||||
properties:
|
||||
duration: 30s
|
||||
- name: apply-wait-suspend-comp
|
||||
type: apply-component
|
||||
properties:
|
||||
component: wait-suspend-comp
|
||||
Reference in New Issue
Block a user