Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestRequestUserAgent fails on EC2 #2366

Closed
jamie-digital opened this issue Dec 20, 2018 · 2 comments
Closed

TestRequestUserAgent fails on EC2 #2366

jamie-digital opened this issue Dec 20, 2018 · 2 comments
Labels
bug This issue is a bug.

Comments

@jamie-digital
Copy link

Please fill out the sections below to help us address your issue.

Version of AWS SDK for Go?

Latest (1.16.9)

Version of Go (go version)?

go version go1.11.4 darwin/amd64

What issue did you see?

--- FAIL: TestRequestUserAgent (0.00s)
 request_test.go:319: expect "foo/bar aws-sdk-go/1.15.27 (go1.11.4; linux; amd64)" user agent, got "foo/bar aws-sdk-go/1.15.27 (go1.11.4; linux; amd64) exec_env/AWS_ECS_EC2"
FAIL
FAIL github.com/aws/aws-sdk-go/aws/request 8.232s

The problem is that the test assumes that no environment data will be added, so the test fails on EC2 where that fact is added to the User-Agent string.

func TestRequestUserAgent(t *testing.T) {
	s := awstesting.NewClient(&aws.Config{Region: aws.String("us-east-1")})
	//	s.Handlers.Validate.Clear()

	req := s.NewRequest(&request.Operation{Name: "Operation"}, nil, &testData{})
	req.HTTPRequest.Header.Set("User-Agent", "foo/bar")
	if err := req.Build(); err != nil {
		t.Fatalf("expect no error, got %v", err)
	}

	expectUA := fmt.Sprintf("foo/bar %s/%s (%s; %s; %s)",
		aws.SDKName, aws.SDKVersion, runtime.Version(), runtime.GOOS, runtime.GOARCH)
	if e, a := expectUA, req.HTTPRequest.Header.Get("User-Agent"); e != a {
		t.Errorf("expect %q user agent, got %q", e, a)
	}
}

Steps to reproduce

Test the package on an EC2 environment, such as CodeBuild.

@jasdel
Copy link
Contributor

jasdel commented Dec 20, 2018

Thanks for reporting this issue @jamie-digital. The test case needs to be updated to work consistently. If you're looking to create a PR we're glad to review it, otherwise we'll schedule some time to fix this issue.

@jasdel jasdel added bug This issue is a bug. compatibility labels Dec 20, 2018
@jamie-digital
Copy link
Author

Hi @jasdel. I'm afraid I don't have the resources to submit a PR, but while I was triaging the issue I found that the extra environment variable data is added here, so it might just be a case of copying that functionality into the test for the expected value.

jasdel added a commit to jasdel/aws-sdk-go that referenced this issue Feb 18, 2019
Fixes the request User-Agent unit tests to be stable across all
platforms and environments.

Fix aws#2366
jasdel added a commit that referenced this issue Feb 26, 2019
Fixes the request User-Agent unit tests to be stable across all
platforms and environments.

Fix #2366
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants