-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(application): define schema for storage flag in application reso…
…urce This commit extends the application schema to support the storage flag in the Terraform provider for Juju. The schema now includes varios attributes for configuring the storage constraints of a Juju application. feat(application) update CRUD function for application resource This commit includes several updates to the resource CRUD functions in the Juju provider. The changes include: - Added error handling for application not found in `handleApplicationNotFoundError` function. - Added storage conintes to Create and Read functions - Modifier retry process to read application changes, to be able to wait for storage creation test(application): add acceptance test for resource application storage feat: introduce storage_directives map instead storage set docs: modify placement example for resource_application to include storage
- Loading branch information
Showing
9 changed files
with
664 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -298,6 +298,72 @@ func (s *ApplicationSuite) TestReadApplicationRetrySubordinate() { | |
s.Assert().Equal("[email protected]", resp.Base) | ||
} | ||
|
||
// TestReadApplicationRetryNotFoundStorageNotFoundError tests the case where the first response is a storage not found error. | ||
// The second response is a real application. | ||
func (s *ApplicationSuite) TestReadApplicationRetryNotFoundStorageNotFoundError() { | ||
defer s.setupMocks(s.T()).Finish() | ||
s.mockSharedClient.EXPECT().ModelType(gomock.Any()).Return(model.IAAS, nil).AnyTimes() | ||
|
||
appName := "testapplication" | ||
aExp := s.mockApplicationClient.EXPECT() | ||
|
||
// First response is a storage not found error. | ||
aExp.ApplicationsInfo(gomock.Any()).Return([]params.ApplicationInfoResult{{ | ||
Error: ¶ms.Error{Message: `storage "testapplication" not found`, Code: "not found"}, | ||
}}, nil) | ||
|
||
// Retry - expect ApplicationsInfo and Status to be called. | ||
// The second time return a real application. | ||
amdConst := constraints.MustParse("arch=amd64") | ||
infoResult := params.ApplicationInfoResult{ | ||
Result: ¶ms.ApplicationResult{ | ||
Tag: names.NewApplicationTag(appName).String(), | ||
Charm: "ch:amd64/jammy/testcharm-5", | ||
Base: params.Base{Name: "ubuntu", Channel: "22.04"}, | ||
Channel: "stable", | ||
Constraints: amdConst, | ||
Principal: true, | ||
}, | ||
Error: nil, | ||
} | ||
|
||
aExp.ApplicationsInfo(gomock.Any()).Return([]params.ApplicationInfoResult{infoResult}, nil) | ||
getResult := ¶ms.ApplicationGetResults{ | ||
Application: appName, | ||
CharmConfig: nil, | ||
ApplicationConfig: nil, | ||
Charm: "ch:amd64/jammy/testcharm-5", | ||
Base: params.Base{Name: "ubuntu", Channel: "22.04"}, | ||
Channel: "stable", | ||
Constraints: amdConst, | ||
EndpointBindings: nil, | ||
} | ||
aExp.Get("master", appName).Return(getResult, nil) | ||
statusResult := ¶ms.FullStatus{ | ||
Applications: map[string]params.ApplicationStatus{appName: { | ||
Charm: "ch:amd64/jammy/testcharm-5", | ||
Units: map[string]params.UnitStatus{"testapplication/0": { | ||
Machine: "0", | ||
}}, | ||
}}, | ||
} | ||
s.mockClient.EXPECT().Status(gomock.Any()).Return(statusResult, nil) | ||
|
||
client := s.getApplicationsClient() | ||
resp, err := client.ReadApplicationWithRetryOnNotFound(context.Background(), | ||
&ReadApplicationInput{ | ||
ModelName: s.testModelName, | ||
AppName: appName, | ||
}) | ||
s.Require().NoError(err, "error from ReadApplicationWithRetryOnNotFound") | ||
s.Require().NotNil(resp, "ReadApplicationWithRetryOnNotFound response") | ||
|
||
s.Assert().Equal("testcharm", resp.Name) | ||
s.Assert().Equal("stable", resp.Channel) | ||
s.Assert().Equal(5, resp.Revision) | ||
s.Assert().Equal("[email protected]", resp.Base) | ||
} | ||
|
||
// In order for 'go test' to run this suite, we need to create | ||
// a normal test function and pass our suite to suite.Run | ||
func TestApplicationSuite(t *testing.T) { | ||
|
Oops, something went wrong.