-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request juju#8780 from ExternalReality/bug#1771980
juju#8780 ## Description of change Restoring a backup from file twice in success fails. Juju should be able to restore a given backup from file more than once. Why is this change needed? This change fixes the referenced bug. How do we verify that the change works? 1. Create a backup to file. 2. Restore the backup. 3. Restore the backup. ## Documentation changes N/A ## Bug reference https://bugs.launchpad.net/juju/+bug/1771980
- Loading branch information
Showing
7 changed files
with
219 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2018 Canonical Ltd. | ||
// Licensed under the AGPLv3, see LICENCE file for details. | ||
|
||
package backups_test | ||
|
||
import ( | ||
gc "gopkg.in/check.v1" | ||
|
||
"github.com/golang/mock/gomock" | ||
"github.com/juju/juju/api/backups" | ||
|
||
"github.com/juju/juju/api/base/mocks" | ||
"github.com/juju/juju/apiserver/params" | ||
) | ||
|
||
type restoreSuite struct { | ||
} | ||
|
||
var _ = gc.Suite(&restoreSuite{}) | ||
|
||
func (s *restoreSuite) TestRestoreFromFileBackupExistsOnController(c *gc.C) { | ||
mockController := gomock.NewController(c) | ||
mockBackupFacadeCaller := mocks.NewMockFacadeCaller(mockController) | ||
mockBackupClientFacade := mocks.NewMockClientFacade(mockController) | ||
mockBackupClientFacade.EXPECT().Close().AnyTimes() | ||
|
||
// testBackupResults represents the parameters passed in by the client. | ||
testBackupResults := params.BackupsMetadataResult{ | ||
Checksum: "testCheckSum", | ||
} | ||
|
||
// This listBackupResults represents what is passed back from server. | ||
testBackupsListResults := params.BackupsListResult{ | ||
List: []params.BackupsMetadataResult{testBackupResults}, | ||
} | ||
|
||
// resultBackupList is an out param | ||
resultBackupList := ¶ms.BackupsListResult{} | ||
args := params.BackupsListArgs{} | ||
|
||
// Upload should never be called. If it is the test will fail. | ||
gomock.InOrder( | ||
mockBackupFacadeCaller.EXPECT().FacadeCall("PrepareRestore", nil, gomock.Any()), | ||
mockBackupFacadeCaller.EXPECT().FacadeCall("List", args, resultBackupList).SetArg(2, testBackupsListResults), | ||
mockBackupFacadeCaller.EXPECT().FacadeCall("Restore", gomock.Any(), gomock.Any()).Times(1), | ||
mockBackupFacadeCaller.EXPECT().FacadeCall("FinishRestore", gomock.Any(), gomock.Any()).Times(1), | ||
) | ||
|
||
connFunc := func() (*backups.Client, error) { | ||
return backups.MakeClient(mockBackupClientFacade, mockBackupFacadeCaller, nil), nil | ||
} | ||
mockBackupsClient, _ := connFunc() | ||
mockBackupsClient.RestoreReader(nil, &testBackupResults, connFunc) | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.