-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(block_storage): add integration test_volume_create_get_delete_si…
…mple Signed-off-by: Sandro-Alessio Gierens <[email protected]>
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2024 Sandro-Alessio Gierens <[email protected]> | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use std::sync::Once; | ||
|
||
static INIT: Once = Once::new(); | ||
|
||
async fn set_up() -> openstack::Cloud { | ||
INIT.call_once(|| { | ||
env_logger::init(); | ||
}); | ||
|
||
openstack::Cloud::from_env() | ||
.await | ||
.expect("Failed to create an identity provider from the environment") | ||
} | ||
|
||
#[tokio::test] | ||
async fn test_volume_create_get_delete_simple() { | ||
let os = set_up().await; | ||
|
||
let volume = os | ||
.new_volume(1 as u64) | ||
.create() | ||
.await | ||
.expect("Could not create volume"); | ||
let id = volume.id().clone(); | ||
assert_eq!(volume.name(), ""); | ||
assert_eq!(*volume.size(), 1 as u64); | ||
|
||
let volume2 = os | ||
.get_volume(&id) | ||
.await | ||
.expect("Could not get volume"); | ||
assert_eq!(volume2.id(), volume.id()); | ||
|
||
volume.delete().await.expect("Could not delete volume"); | ||
|
||
let volume3 = os.get_volume(id).await; | ||
assert!(volume3.is_err()); | ||
} |