Skip to content

Commit

Permalink
test: use oversea region in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonTian committed Sep 28, 2023
1 parent 440837d commit bbcc995
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 2 additions & 0 deletions integration/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ var (
rolearn = fmt.Sprintf("acs:ram::%s:role/%s", os.Getenv("USER_ID"), rolename)
)

var ecsEndpoint = "ecs." + os.Getenv("REGION_ID") + ".aliyuncs.com"

func createRole(userid string) (name string, arn string, err error) {
listRequest := ram.CreateListRolesRequest()
listRequest.Scheme = "HTTPS"
Expand Down
14 changes: 7 additions & 7 deletions integration/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func Test_DescribeRegionsWithCommonRequestWithRPC(t *testing.T) {
request.Version = "2014-05-26"
request.Product = "Ecs"
request.ApiName = "DescribeRegions"
request.SetDomain("ecs.aliyuncs.com")
request.SetDomain(ecsEndpoint)
request.TransToAcsRequest()
client, err := sdk.NewClientWithAccessKey(os.Getenv("REGION_ID"), os.Getenv("ACCESS_KEY_ID"), os.Getenv("ACCESS_KEY_SECRET"))
assert.Nil(t, err)
Expand All @@ -43,7 +43,7 @@ func Test_DescribeRegionsWithCommonRequestWithSTStoken(t *testing.T) {
request.Version = "2014-05-26"
request.Product = "Ecs"
request.ApiName = "DescribeRegions"
request.SetDomain("ecs.aliyuncs.com")
request.SetDomain(ecsEndpoint)
request.TransToAcsRequest()
client, err := sdk.NewClientWithStsToken(os.Getenv("REGION_ID"), credential.AccessKeyId, credential.AccessKeySecret, credential.SecurityToken)
assert.Nil(t, err)
Expand All @@ -57,7 +57,7 @@ func Test_DescribeRegionsWithCommonRequestWithHTTPS(t *testing.T) {
request.Version = "2014-05-26"
request.Product = "Ecs"
request.ApiName = "DescribeRegions"
request.SetDomain("ecs.aliyuncs.com")
request.SetDomain(ecsEndpoint)
request.TransToAcsRequest()
request.SetScheme("HTTPS")
client, err := sdk.NewClientWithAccessKey(os.Getenv("REGION_ID"), os.Getenv("ACCESS_KEY_ID"), os.Getenv("ACCESS_KEY_SECRET"))
Expand All @@ -72,7 +72,7 @@ func Test_DescribeRegionsWithCommonRequestWithUnicodeSpecificParams(t *testing.T
request.Version = "2014-05-26"
request.Product = "Ecs"
request.ApiName = "DescribeRegions"
request.SetDomain("ecs.aliyuncs.com")
request.SetDomain(ecsEndpoint)
request.TransToAcsRequest()
request.SetContent([]byte("sdk&-杭&&&州-test"))
client, err := sdk.NewClientWithAccessKey(os.Getenv("REGION_ID"), os.Getenv("ACCESS_KEY_ID"), os.Getenv("ACCESS_KEY_SECRET"))
Expand All @@ -87,7 +87,7 @@ func Test_AddTagsWithCommonRequestWithError(t *testing.T) {
request.Version = "2014-05-26"
request.Product = "Ecs"
request.ApiName = "AddTags"
request.SetDomain("ecs.aliyuncs.com")
request.SetDomain(ecsEndpoint)
request.TransToAcsRequest()
client, err := sdk.NewClientWithAccessKey(os.Getenv("REGION_ID"), os.Getenv("ACCESS_KEY_ID"), os.Getenv("ACCESS_KEY_SECRET"))
assert.Nil(t, err)
Expand All @@ -104,7 +104,7 @@ func SkipTest_DescribeRegionsWithCommonRequestWithIncompleteSignature(t *testing
request.SetScheme("https")
request.Method = "POST"
request.ApiName = "DescribeRegions"
request.SetDomain("ecs.aliyuncs.com")
request.SetDomain(ecsEndpoint)
request.TransToAcsRequest()
client, err := sdk.NewClientWithAccessKey(os.Getenv("REGION_ID"), os.Getenv("ACCESS_KEY_ID"), strings.ToUpper(os.Getenv("ACCESS_KEY_SECRET")))
assert.Nil(t, err)
Expand Down Expand Up @@ -226,7 +226,7 @@ func Test_CreateInstanceWithCommonRequestWithPolicy(t *testing.T) {
request := requests.NewCommonRequest()
request.Method = "POST"
request.Product = "Ecs"
request.Domain = "ecs.aliyuncs.com"
request.Domain = "ecs." + os.Getenv("REGION_ID") + ".aliyuncs.com"
request.Version = "2014-05-26"
request.SetScheme("HTTPS")
request.ApiName = "CreateInstance"
Expand Down
4 changes: 2 additions & 2 deletions integration/credential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func Test_DescribeRegionsWithRPCrequestWithArn(t *testing.T) {

request := ecs.CreateDescribeRegionsRequest()
request.Scheme = "https"
request.Domain = "ecs.aliyuncs.com"
request.Domain = ecsEndpoint
response, err := client.DescribeRegions(request)
assert.Nil(t, err)
assert.Equal(t, 36, len(response.RequestId))
Expand All @@ -67,7 +67,7 @@ func TestDescribeRegionsWithProviderAndAk(t *testing.T) {
request.Version = "2014-05-26"
request.Product = "Ecs"
request.ApiName = "DescribeRegions"
request.SetDomain("ecs.aliyuncs.com")
request.SetDomain(ecsEndpoint)
request.TransToAcsRequest()
client, err := sdk.NewClientWithProvider(os.Getenv("REGION_ID"))
assert.Nil(t, err)
Expand Down
6 changes: 3 additions & 3 deletions integration/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func Test_AddTagsWithParameterError(t *testing.T) {
request.Version = "2014-05-26"
request.Product = "Ecs"
request.ApiName = "AddTags"
request.SetDomain("ecs.aliyuncs.com")
request.SetDomain(ecsEndpoint)
request.TransToAcsRequest()
client, err := sdk.NewClientWithAccessKey(os.Getenv("REGION_ID"), os.Getenv("ACCESS_KEY_ID"), os.Getenv("ACCESS_KEY_SECRET"))
assert.Nil(t, err)
Expand Down Expand Up @@ -49,12 +49,12 @@ func Test_DescribeRegionsWithTimeout(t *testing.T) {
}
request := ecs.CreateDescribeRegionsRequest()
request.Scheme = "https"
request.SetDomain("ecs.aliyuncs.com")
request.SetDomain(ecsEndpoint)
client, err := ecs.NewClientWithOptions(os.Getenv("REGION_ID"), config, credentail)
assert.Nil(t, err)
response, err := client.DescribeRegions(request)
assert.Equal(t, 0, response.GetHttpStatus())
assert.Contains(t, err.Error(), "https://ecs.aliyuncs.com")
assert.Contains(t, err.Error(), "https://"+ecsEndpoint)
assert.Contains(t, err.Error(), "Client.Timeout exceeded while awaiting headers")
}

Expand Down

0 comments on commit bbcc995

Please sign in to comment.