From c09a80a518dcb539ad9fcdd1f7f14814c8590c08 Mon Sep 17 00:00:00 2001 From: olivia_chen Date: Sat, 24 Jun 2023 21:05:01 -0700 Subject: [PATCH] unit test --- pkg/manager/member/startscript/v1/render_script.go | 6 +++--- pkg/manager/member/startscript/v1/template.go | 4 ++-- pkg/manager/member/startscript/v1/template_test.go | 4 +++- pkg/manager/member/startscript/v2/pd_start_script.go | 2 +- pkg/manager/member/startscript/v2/pd_start_script_test.go | 4 +++- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/pkg/manager/member/startscript/v1/render_script.go b/pkg/manager/member/startscript/v1/render_script.go index 98eded23d9..fdb2844df0 100644 --- a/pkg/manager/member/startscript/v1/render_script.go +++ b/pkg/manager/member/startscript/v1/render_script.go @@ -63,9 +63,9 @@ func RenderPDStartScript(tc *v1alpha1.TidbCluster) (string, error) { AcrossK8s: tc.AcrossK8s(), ClusterDomain: tc.Spec.ClusterDomain, }, - Scheme: tc.Scheme(), - DataDir: filepath.Join(constants.PDDataVolumeMountPath, tc.Spec.PD.DataSubDir), - StartTimeout: tc.Spec.PD.StartTimeout, + Scheme: tc.Scheme(), + DataDir: filepath.Join(constants.PDDataVolumeMountPath, tc.Spec.PD.DataSubDir), + PDStartTimeout: tc.Spec.PD.StartTimeout, } if tc.Spec.PD.StartUpScriptVersion == "v1" { model.CheckDomainScript = checkDNSV1 diff --git a/pkg/manager/member/startscript/v1/template.go b/pkg/manager/member/startscript/v1/template.go index 2961357a92..634120409d 100644 --- a/pkg/manager/member/startscript/v1/template.go +++ b/pkg/manager/member/startscript/v1/template.go @@ -155,7 +155,7 @@ encoded_domain_url=` + "`" + `echo ${domain}:2380 | base64 | tr "\n" " " | sed " ` elapseTime=0 period=1 -threshold={{ .PDStartTimeout }} +threshold={{ .PDStartTimeout }} while true; do sleep ${period} elapseTime=$(( elapseTime+period )) @@ -245,7 +245,7 @@ type PDStartScriptModel struct { Scheme string DataDir string CheckDomainScript string - StartTimeout int + PDStartTimeout int } var tikvStartScriptTplText = `#!/bin/sh diff --git a/pkg/manager/member/startscript/v1/template_test.go b/pkg/manager/member/startscript/v1/template_test.go index 6fb0edce73..8a7281070e 100644 --- a/pkg/manager/member/startscript/v1/template_test.go +++ b/pkg/manager/member/startscript/v1/template_test.go @@ -1227,7 +1227,9 @@ exec /pd-server ${ARGS} tc := &v1alpha1.TidbCluster{ Spec: v1alpha1.TidbClusterSpec{ - PD: &v1alpha1.PDSpec{}, + PD: &v1alpha1.PDSpec{ + StartTimeout: 30, + }, }, } tc.Name = "test-pd" diff --git a/pkg/manager/member/startscript/v2/pd_start_script.go b/pkg/manager/member/startscript/v2/pd_start_script.go index 234d48ee3c..7fdbb9c865 100644 --- a/pkg/manager/member/startscript/v2/pd_start_script.go +++ b/pkg/manager/member/startscript/v2/pd_start_script.go @@ -83,7 +83,7 @@ PD_DOMAIN={{ .PDDomain }} elapseTime=0 period=1 -threshold={{ .PDStartTimeout }} +threshold={{ .PDStartTimeout }} while true; do sleep ${period} elapseTime=$(( elapseTime+period )) diff --git a/pkg/manager/member/startscript/v2/pd_start_script_test.go b/pkg/manager/member/startscript/v2/pd_start_script_test.go index fc0b838348..f9666b47de 100644 --- a/pkg/manager/member/startscript/v2/pd_start_script_test.go +++ b/pkg/manager/member/startscript/v2/pd_start_script_test.go @@ -543,7 +543,9 @@ exec /pd-server ${ARGS} tc := &v1alpha1.TidbCluster{ Spec: v1alpha1.TidbClusterSpec{ - PD: &v1alpha1.PDSpec{}, + PD: &v1alpha1.PDSpec{ + StartTimeout: 30, + }, }, } tc.Name = "start-script-test"