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

feat: allow more than 1000 state files #223

Merged
merged 3 commits into from Feb 3, 2022
Merged

Conversation

lorodoes
Copy link
Contributor

@lorodoes lorodoes commented Nov 5, 2021

Upgrade to the newest AWS API For ListObjectsV2 and then also add the ability to have more than 1000 state files

Upgrade to the newest AWS API For ListObjectsV2 and then also add the ability to have more than 1000 state files
Copy link
Contributor

@raphink raphink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@raphink
Copy link
Contributor

raphink commented Nov 11, 2021

The AWS tests are actually failing. @hbollon do you see why?

@hbollon
Copy link
Member

hbollon commented Nov 11, 2021

Hi guys!
In order to be able to mock AWS provider for testing purposes, I created a custom type s3Mock implementing the s3iface.S3API interface and defined needed methods for our use cases (ListObjects, ListObjectVersions, etc.).

from aws_test.go:

type s3Mock struct {
	s3iface.S3API
}

func (s *s3Mock) ListObjects(_ *s3.ListObjectsInput) (*s3.ListObjectsOutput, error) {
	return &s3.ListObjectsOutput{Contents: []*s3.Object{{Key: aws.String("test.tfstate")}}}, nil
}
func (s *s3Mock) ListObjectVersions(_ *s3.ListObjectVersionsInput) (*s3.ListObjectVersionsOutput, error) {
	return &s3.ListObjectVersionsOutput{
		Versions: []*s3.ObjectVersion{
			{Key: aws.String("testId"), VersionId: aws.String("test"), LastModified: aws.Time(time.Now())},
			{Key: aws.String("testId2"), VersionId: aws.String("test2"), LastModified: aws.Time(time.Now())},
		},
	}, nil
}
func (s *s3Mock) GetObjectWithContext(_ aws.Context, _ *s3.GetObjectInput, _ ...request.Option) (*s3.GetObjectOutput, error) {
	return &s3.GetObjectOutput{
		Body: ioutil.NopCloser(bytes.NewReader([]byte(`{"Version": 4, "Serial": 3, "TerraformVersion": "0.12.0"}`))),
	}, nil
}

So with the AWS API upgrade and the use of ListObjectsV2 instead of ListObjects the program panic since this function is not defined on a.svc which is of type s3Mock during unit tests (cf. line 150 of aws.go).
To solve this we must add mocked ListObjectsV2 method on s3Mock 👍

@lorodoes
Copy link
Contributor Author

@hbollon Sorry I didn't update the aws_test.go, I see how to do it, but it might be a bit before I can complete it.

Fixing the test case
@bmpandrade
Copy link

bmpandrade commented Jan 4, 2022

Is there any updates on this PR? Or is it possible for me to help on moving it further?

\cc @raphink @lorodoes

@lorodoes
Copy link
Contributor Author

lorodoes commented Jan 4, 2022

@bmpandrade I updated the PR with an updated version of aws_test.go. I think the workflow just needs to be rerun again to verify that everything is working as expected.

@bmpandrade
Copy link

@lorodoes , I took a look at the worfklows, but none allow for re-run, it requires explicit approval from maintainers to run them again.

@bmpandrade
Copy link

@raphink @hbollon Do you mind giving a peak here, please? 🙏

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 55.742% when pulling 73d38ac on lorodoes:master into 6d50bf5 on camptocamp:master.

@hbollon hbollon changed the title allow for more than 1000 state files feat: allow more than 1000 state files Feb 3, 2022
@hbollon
Copy link
Member

hbollon commented Feb 3, 2022

Hi guys,
Tests were always failing, I fixed the mocked function for ListObjectsV2 and it's all good now.
@raphink it's all good to you? Can we merge?

@raphink
Copy link
Contributor

raphink commented Feb 3, 2022

OK for me @hbollon

@hbollon hbollon merged commit 056ca94 into camptocamp:master Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants