Skip to content

Commit

Permalink
fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
xuxiaoahang2018 committed Nov 3, 2020
1 parent 7226866 commit 353a857
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 23 deletions.
24 changes: 12 additions & 12 deletions client_etl_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import (
"time"
)

type ETLJobV2 struct {
type ETL struct {
Configuration ETLConfiguration `json:"configuration"`
Description string `json:"description"`
DisplayName string `json:"displayName"`
Name string `json:"name"`
Schedule ETLSchedule `json:"schedule"`
Type string `json:"type"`
Status string `json:"status"`
CreateTime int32 `json:"createTime"`
LastModifiedTime int32 `json:"lastModifiedTime"`
CreateTime int32 `json:"createTime,omitempty"`
LastModifiedTime int32 `json:"lastModifiedTime,omitempty"`
}

type ETLConfiguration struct {
Expand All @@ -25,7 +25,7 @@ type ETLConfiguration struct {
FromTime int64 `json:"fromTime"`
Logstore string `json:"logstore"`
Parameters map[string]string `json:"parameters"`
RoleArn string `json:"roleArn"`
RoleArn string `json:"roleArn,omitempty"`
Script string `json:"script"`
ToTime int32 `json:"toTime"`
Version int8 `json:"version"`
Expand All @@ -43,17 +43,17 @@ type ETLSink struct {
Logstore string `json:"logstore"`
Name string `json:"name"`
Project string `json:"project"`
RoleArn string `json:"roleArn"`
RoleArn string `json:"roleArn,omitempty"`
}

type ListETLResponse struct {
Total int `json:"total"`
Count int `json:"count"`
Results []*ETLJobV2 `json:"results"`
Results []*ETL `json:"results"`
}


func NewLogETLJobV2(endpoint, accessKeyId, accessKeySecret, logstore, name, project string) ETLJobV2 {
func NewETL(endpoint, accessKeyId, accessKeySecret, logstore, name, project string) ETL {
sink := ETLSink{
AccessKeyId:accessKeyId,
AccessKeySecret:accessKeySecret,
Expand All @@ -76,7 +76,7 @@ func NewLogETLJobV2(endpoint, accessKeyId, accessKeySecret, logstore, name, proj
schedule := ETLSchedule{
Type:"Resident",
}
etljob := ETLJobV2 {
etljob := ETL {
Configuration:config,
DisplayName:"displayname",
Description:"go sdk case",
Expand All @@ -90,7 +90,7 @@ func NewLogETLJobV2(endpoint, accessKeyId, accessKeySecret, logstore, name, proj



func (c *Client) CreateETL(project string, etljob ETLJobV2) error {
func (c *Client) CreateETL(project string, etljob ETL) error {
body, err := json.Marshal(etljob)
if err != nil {
return NewClientError(err)
Expand All @@ -109,7 +109,7 @@ func (c *Client) CreateETL(project string, etljob ETLJobV2) error {
return nil
}

func (c *Client) GetETL(project string, etlName string) (ETLJob *ETLJobV2, err error) {
func (c *Client) GetETL(project string, etlName string) (ETLJob *ETL, err error) {
h := map[string]string{
"x-log-bodyrawsize": "0",
"Content-Type": "application/json",
Expand All @@ -121,14 +121,14 @@ func (c *Client) GetETL(project string, etlName string) (ETLJob *ETLJobV2, err e
}
defer r.Body.Close()
buf, _ := ioutil.ReadAll(r.Body)
etlJob := &ETLJobV2{}
etlJob := &ETL{}
if err = json.Unmarshal(buf, etlJob); err != nil {
err = NewClientError(err)
}
return etlJob, nil
}

func (c *Client) UpdateETL(project string, etljob ETLJobV2) error {
func (c *Client) UpdateETL(project string, etljob ETL) error {
body, err := json.Marshal(etljob)
if err != nil {
return NewClientError(err)
Expand Down
38 changes: 27 additions & 11 deletions client_etl_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (s *ETLJobTestV2Suite) createETLJobV2() error {
schedule := ETLSchedule{
Type: "Resident",
}
etljob := ETLJobV2{
etljob := ETL{
Configuration: config,
DisplayName: "displayName",
Description: "go sdk case",
Expand Down Expand Up @@ -116,17 +116,33 @@ func (s *ETLJobTestV2Suite) TestClient_ListETLJobV2() {
func (s *ETLJobTestV2Suite) TestClient_StartStopETLJobV2() {
err := s.createETLJobV2()
s.Require().Nil(err)
etljob, err := s.client.GetETL(s.projectName, s.etlName)
s.Require().Equal("RUNNING", etljob.Status)
for {
etljob, err := s.client.GetETL(s.projectName, s.etlName)
s.Require().Nil(err)
time.Sleep(10 * time.Second)
if etljob.Status == "RUNNING" {
break
}
}

err = s.client.StopETL(s.projectName, s.etlName)
time.Sleep(time.Second * 120)
etljob, err = s.client.GetETL(s.projectName, s.etlName)
s.Require().Equal("STOPPED", etljob.Status)
err = s.client.StopETL(s.projectName, s.etlName)
for {
etljob, err := s.client.GetETL(s.projectName, s.etlName)
s.Require().Nil(err)
time.Sleep(10 * time.Second)
if etljob.Status == "STOPPED" {
break
}
}
err = s.client.StartETL(s.projectName, s.etlName)
for {
etljob, err := s.client.GetETL(s.projectName, s.etlName)
s.Require().Nil(err)
time.Sleep(10 * time.Second)
if etljob.Status == "RUNNING" {
break
}
}

err = s.client.StartETL(s.projectName, s.etlName)
time.Sleep(time.Second * 120)
etljob, err = s.client.GetETL(s.projectName, s.etlName)
s.Require().Equal("RUNNING", etljob.Status)

}

0 comments on commit 353a857

Please sign in to comment.