forked from juju/juju
-
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.
Add API calls and expose state settings functions.
Expose the ability to update and delete storage pools on the api.
- Loading branch information
Showing
10 changed files
with
249 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2019 Canonical Ltd. | ||
// Licensed under the AGPLv3, see LICENCE file for details. | ||
|
||
package storage_test | ||
|
||
import ( | ||
"fmt" | ||
|
||
jc "github.com/juju/testing/checkers" | ||
gc "gopkg.in/check.v1" | ||
|
||
storage "github.com/juju/juju/storage" | ||
"github.com/juju/juju/storage/provider" | ||
) | ||
|
||
type poolDeleteSuite struct { | ||
baseStorageSuite | ||
} | ||
|
||
var _ = gc.Suite(&poolDeleteSuite{}) | ||
|
||
func (s *poolDeleteSuite) createPools(c *gc.C, num int) { | ||
var err error | ||
for i := 0; i < num; i++ { | ||
poolName := fmt.Sprintf("%v%v", tstName, i) | ||
s.baseStorageSuite.pools[poolName], err = | ||
storage.NewConfig(poolName, provider.LoopProviderType, map[string]interface{}{"zip": "zap"}) | ||
c.Assert(err, jc.ErrorIsNil) | ||
} | ||
} | ||
|
||
func (s *poolDeleteSuite) TestDeletePool(c *gc.C) { | ||
s.createPools(c, 1) | ||
poolName := fmt.Sprintf("%v%v", tstName, 0) | ||
|
||
err := s.api.DeletePool(poolName) | ||
c.Assert(err, jc.ErrorIsNil) | ||
|
||
pools, err := s.poolManager.List() | ||
c.Assert(err, jc.ErrorIsNil) | ||
c.Assert(pools, gc.HasLen, 0) | ||
} | ||
|
||
func (s *poolDeleteSuite) TestDeleteErrorNotExists(c *gc.C) { | ||
poolName := fmt.Sprintf("%v%v", tstName, 0) | ||
|
||
err := s.api.DeletePool(poolName) | ||
c.Assert(err, jc.ErrorIsNil) | ||
|
||
pools, err := s.poolManager.List() | ||
c.Assert(err, jc.ErrorIsNil) | ||
c.Assert(pools, gc.HasLen, 0) | ||
} |
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,63 @@ | ||
// Copyright 2019 Canonical Ltd. | ||
// Licensed under the AGPLv3, see LICENCE file for details. | ||
|
||
package storage_test | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/juju/errors" | ||
jc "github.com/juju/testing/checkers" | ||
gc "gopkg.in/check.v1" | ||
|
||
"github.com/juju/juju/apiserver/params" | ||
storage "github.com/juju/juju/storage" | ||
"github.com/juju/juju/storage/provider" | ||
) | ||
|
||
type poolUpdateSuite struct { | ||
baseStorageSuite | ||
} | ||
|
||
var _ = gc.Suite(&poolUpdateSuite{}) | ||
|
||
func (s *poolUpdateSuite) createPools(c *gc.C, num int) { | ||
var err error | ||
for i := 0; i < num; i++ { | ||
poolName := fmt.Sprintf("%v%v", tstName, i) | ||
s.baseStorageSuite.pools[poolName], err = | ||
storage.NewConfig(poolName, provider.LoopProviderType, map[string]interface{}{"zip": "zap"}) | ||
c.Assert(err, jc.ErrorIsNil) | ||
} | ||
} | ||
|
||
func (s *poolUpdateSuite) TestUpdatePool(c *gc.C) { | ||
s.createPools(c, 1) | ||
poolName := fmt.Sprintf("%v%v", tstName, 0) | ||
newAttrs := map[string]interface{}{ | ||
"foo1": "bar1", | ||
"zip": "zoom", | ||
} | ||
|
||
err := s.api.UpdatePool(params.StoragePool{ | ||
Name: poolName, | ||
Attrs: newAttrs, | ||
}) | ||
c.Assert(err, jc.ErrorIsNil) | ||
|
||
expected, err := storage.NewConfig(poolName, provider.LoopProviderType, newAttrs) | ||
c.Assert(err, jc.ErrorIsNil) | ||
|
||
pools, err := s.poolManager.List() | ||
c.Assert(err, jc.ErrorIsNil) | ||
c.Assert(pools, gc.HasLen, 1) | ||
c.Assert(pools[0], gc.DeepEquals, expected) | ||
} | ||
|
||
func (s *poolUpdateSuite) TestUpdatePoolError(c *gc.C) { | ||
poolName := fmt.Sprintf("%v%v", tstName, 0) | ||
err := s.api.UpdatePool(params.StoragePool{ | ||
Name: poolName, | ||
}) | ||
c.Assert(err, jc.Satisfies, errors.IsNotFound) | ||
} |
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