Skip to content

Commit 932c994

Browse files
authored
tests(instance): replace remaining b_ssd volumes by l_ssd (scaleway#4910)
1 parent b5d094b commit 932c994

12 files changed

+7416
-1780
lines changed

internal/namespaces/instance/v1/custom_image_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func Test_ImageUpdate(t *testing.T) {
244244

245245
t.Run("Add extra volume", core.Test(&core.TestConfig{
246246
BeforeFunc: core.BeforeFuncCombine(
247-
createVolume("Volume", 20, instanceSDK.VolumeVolumeTypeBSSD),
247+
createNonEmptyLocalVolume("Volume", 10),
248248
core.ExecStoreBeforeCmd(
249249
"SnapshotVol",
250250
`scw instance snapshot create -w name=snapVol volume-id={{ .Volume.ID }}`,

internal/namespaces/instance/v1/custom_snapshot_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func Test_UpdateSnapshot(t *testing.T) {
1414
t.Run("Change tags", core.Test(&core.TestConfig{
1515
Commands: instance.GetCommands(),
1616
BeforeFunc: core.BeforeFuncCombine(
17-
createVolume("Volume", 10, instanceSDK.VolumeVolumeTypeBSSD),
17+
createNonEmptyLocalVolume("Volume", 10),
1818
core.ExecStoreBeforeCmd(
1919
"CreateSnapshot",
2020
"scw instance snapshot create volume-id={{ .Volume.ID }} name=cli-test-snapshot-update-tags tags.0=foo tags.1=bar",
@@ -42,7 +42,7 @@ func Test_UpdateSnapshot(t *testing.T) {
4242
t.Run("Change name", core.Test(&core.TestConfig{
4343
Commands: instance.GetCommands(),
4444
BeforeFunc: core.BeforeFuncCombine(
45-
createVolume("Volume", 10, instanceSDK.VolumeVolumeTypeBSSD),
45+
createNonEmptyLocalVolume("Volume", 10),
4646
core.ExecStoreBeforeCmd(
4747
"CreateSnapshot",
4848
"scw instance snapshot create volume-id={{ .Volume.ID }} name=cli-test-snapshot-update-name tags.0=foo tags.1=bar",

internal/namespaces/instance/v1/helpers_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,31 @@ func createSbsVolume(metaKey string, sizeInGb int) core.BeforeFunc {
133133
}
134134
}
135135

136+
// createNonEmptyLocalVolume creates a server with a local root volume of the given size and registers the volume in
137+
// the context Meta at metaKey. The volume is then detached, and the server deleted, leaving a non-empty volume
138+
// ready to be snapshot, or any other use case that requires a non-empty local volume.
139+
func createNonEmptyLocalVolume(metaKey string, sizeInGB int) core.BeforeFunc {
140+
return func(ctx *core.BeforeFuncCtx) error {
141+
cmd := fmt.Sprintf(
142+
"scw instance server create type=DEV1-S root-volume=local:%dGB stopped=true",
143+
sizeInGB,
144+
)
145+
server := ctx.ExecuteCmd(strings.Split(cmd, " "))
146+
createServerResponse := server.(*instance.ServerWithWarningsResponse)
147+
serverID := createServerResponse.Server.ID
148+
volume := createServerResponse.Server.Volumes["0"]
149+
ctx.Meta[metaKey] = volume
150+
151+
cmd = "scw instance server detach-volume volume-id=" + volume.ID
152+
_ = ctx.ExecuteCmd(strings.Split(cmd, " "))
153+
154+
cmd = "scw instance server delete " + serverID
155+
_ = ctx.ExecuteCmd(strings.Split(cmd, " "))
156+
157+
return nil
158+
}
159+
}
160+
136161
//
137162
// IP
138163
//

internal/namespaces/instance/v1/instance_cli_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func Test_GetServer(t *testing.T) {
4040
func Test_CreateVolume(t *testing.T) {
4141
t.Run("Simple", core.Test(&core.TestConfig{
4242
Commands: instance.GetCommands(),
43-
Cmd: "scw instance volume create name=test volume-type=b_ssd size=20G",
43+
Cmd: "scw instance volume create name=test volume-type=l_ssd size=20G",
4444
Check: core.TestCheckCombine(
4545
core.TestCheckExitCode(0),
4646
func(t *testing.T, ctx *core.CheckFuncCtx) {
@@ -54,7 +54,7 @@ func Test_CreateVolume(t *testing.T) {
5454

5555
t.Run("Bad size unit", core.Test(&core.TestConfig{
5656
Commands: instance.GetCommands(),
57-
Cmd: "scw instance volume create name=test volume-type=b_ssd size=20",
57+
Cmd: "scw instance volume create name=test volume-type=l_ssd size=20",
5858
Check: core.TestCheckCombine(
5959
core.TestCheckGolden(),
6060
core.TestCheckExitCode(1),
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
version: 2
3+
interactions: []

internal/namespaces/instance/v1/testdata/test-create-volume-simple.cassette.yaml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22
version: 1
33
interactions:
44
- request:
5-
body: '{"volume": {"id": "6edefc20-4cc5-462e-a8b0-80dded76c78c", "name": "test",
6-
"volume_type": "b_ssd", "export_uri": null, "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b",
7-
"project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "server": null, "size": 20000000000,
8-
"state": "available", "creation_date": "2024-10-23T12:02:48.930043+00:00", "modification_date":
9-
"2024-10-23T12:02:48.930043+00:00", "tags": [], "zone": "fr-par-1"}}'
5+
body: '{"volume": {"id": "dc156514-8ba0-477b-8b27-dc3233870ef8", "name": "test",
6+
"volume_type": "l_ssd", "export_uri": null, "organization": "fa1e3217-dc80-42ac-85c3-3f034b78b552",
7+
"project": "fa1e3217-dc80-42ac-85c3-3f034b78b552", "server": null, "size": 20000000000,
8+
"state": "available", "creation_date": "2025-07-22T15:32:46.200346+00:00", "modification_date":
9+
"2025-07-22T15:32:46.200346+00:00", "tags": [], "zone": "fr-par-1"}}'
1010
form: {}
1111
headers:
1212
Content-Type:
1313
- application/json
1414
User-Agent:
15-
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.0; darwin; arm64) cli-e2e-test
15+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.24.1; linux; amd64) cli-e2e-test
1616
url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes
1717
method: POST
1818
response:
19-
body: '{"volume": {"id": "6edefc20-4cc5-462e-a8b0-80dded76c78c", "name": "test",
20-
"volume_type": "b_ssd", "export_uri": null, "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b",
21-
"project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "server": null, "size": 20000000000,
22-
"state": "available", "creation_date": "2024-10-23T12:02:48.930043+00:00", "modification_date":
23-
"2024-10-23T12:02:48.930043+00:00", "tags": [], "zone": "fr-par-1"}}'
19+
body: '{"volume": {"id": "dc156514-8ba0-477b-8b27-dc3233870ef8", "name": "test",
20+
"volume_type": "l_ssd", "export_uri": null, "organization": "fa1e3217-dc80-42ac-85c3-3f034b78b552",
21+
"project": "fa1e3217-dc80-42ac-85c3-3f034b78b552", "server": null, "size": 20000000000,
22+
"state": "available", "creation_date": "2025-07-22T15:32:46.200346+00:00", "modification_date":
23+
"2025-07-22T15:32:46.200346+00:00", "tags": [], "zone": "fr-par-1"}}'
2424
headers:
2525
Content-Length:
2626
- "426"
@@ -29,19 +29,19 @@ interactions:
2929
Content-Type:
3030
- application/json
3131
Date:
32-
- Wed, 23 Oct 2024 12:02:48 GMT
32+
- Tue, 22 Jul 2025 15:32:46 GMT
3333
Location:
34-
- https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/6edefc20-4cc5-462e-a8b0-80dded76c78c
34+
- https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/dc156514-8ba0-477b-8b27-dc3233870ef8
3535
Server:
36-
- Scaleway API Gateway (fr-par-2;edge02)
36+
- Scaleway API Gateway (fr-par-1;edge02)
3737
Strict-Transport-Security:
3838
- max-age=63072000
3939
X-Content-Type-Options:
4040
- nosniff
4141
X-Frame-Options:
4242
- DENY
4343
X-Request-Id:
44-
- a3c78bff-0132-441a-bea4-3c13456e983b
44+
- 1dfd652d-918c-4055-b6f3-4f3c11445818
4545
status: 201 Created
4646
code: 201
4747
duration: ""
@@ -50,8 +50,8 @@ interactions:
5050
form: {}
5151
headers:
5252
User-Agent:
53-
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.0; darwin; arm64) cli-e2e-test
54-
url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/6edefc20-4cc5-462e-a8b0-80dded76c78c
53+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.24.1; linux; amd64) cli-e2e-test
54+
url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/dc156514-8ba0-477b-8b27-dc3233870ef8
5555
method: DELETE
5656
response:
5757
body: ""
@@ -61,17 +61,17 @@ interactions:
6161
Content-Type:
6262
- application/json
6363
Date:
64-
- Wed, 23 Oct 2024 12:02:49 GMT
64+
- Tue, 22 Jul 2025 15:32:46 GMT
6565
Server:
66-
- Scaleway API Gateway (fr-par-2;edge02)
66+
- Scaleway API Gateway (fr-par-1;edge02)
6767
Strict-Transport-Security:
6868
- max-age=63072000
6969
X-Content-Type-Options:
7070
- nosniff
7171
X-Frame-Options:
7272
- DENY
7373
X-Request-Id:
74-
- 5006c81d-55ca-4c43-a3fd-b54d53432122
74+
- ea6a4ba9-f064-4d2e-8726-3894a128163b
7575
status: 204 No Content
7676
code: 204
7777
duration: ""

0 commit comments

Comments
 (0)