Skip to content

Commit bc1eb23

Browse files
authored
Merge pull request #260 from alexander-ding/enh/rename-api-groups
Rename iscsi to iSCSI
2 parents cf06152 + 219b990 commit bc1eb23

File tree

4 files changed

+69
-69
lines changed

4 files changed

+69
-69
lines changed

integrationtests/iscsi_ps_scripts.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ import (
99
"testing"
1010
)
1111

12-
func installIscsiTarget() error {
13-
_, err := runPowershellScript(IscsiTargetInstallScript)
12+
func installISCSITarget() error {
13+
_, err := runPowershellScript(iSCSITargetInstallScript)
1414
if err != nil {
1515
return fmt.Errorf("failed installing iSCSI target. err=%v", err)
1616
}
1717

1818
return nil
1919
}
2020

21-
const IscsiTargetInstallScript = `
21+
const iSCSITargetInstallScript = `
2222
$ErrorActionPreference = "Stop"
2323
$ProgressPreference = "SilentlyContinue"
2424
@@ -30,12 +30,12 @@ Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\iSCSI Target" -Name AllowLoopBa
3030
Restart-Service WinTarget
3131
`
3232

33-
type IscsiSetupConfig struct {
33+
type iSCSISetupConfig struct {
3434
Iqn string `json:"iqn"`
3535
Ip string `json:"ip"`
3636
}
3737

38-
const IscsiEnvironmentSetupScript = `
38+
const iSCSIEnvironmentSetupScript = `
3939
$ErrorActionPreference = "Stop"
4040
$ProgressPreference = "SilentlyContinue"
4141
@@ -59,7 +59,7 @@ $output = @{
5959
$output | ConvertTo-Json | Write-Output
6060
`
6161

62-
const IscsiSetChapScript = `
62+
const iSCSISetChapScript = `
6363
$ErrorActionPreference = "Stop"
6464
$ProgressPreference = "SilentlyContinue"
6565
@@ -72,7 +72,7 @@ Set-IscsiServerTarget -TargetName $targetName -EnableChap $true -Chap $chap
7272
`
7373

7474
func setChap(targetName string, username string, password string) error {
75-
script := fmt.Sprintf(IscsiSetChapScript, targetName, username, password)
75+
script := fmt.Sprintf(iSCSISetChapScript, targetName, username, password)
7676
_, err := runPowershellScript(script)
7777
if err != nil {
7878
return fmt.Errorf("failed setting CHAP on iSCSI target=%v. err=%v", targetName, err)
@@ -81,7 +81,7 @@ func setChap(targetName string, username string, password string) error {
8181
return nil
8282
}
8383

84-
const IscsiSetReverseChapScript = `
84+
const iSCSISetReverseChapScript = `
8585
$ErrorActionPreference = "Stop"
8686
$ProgressPreference = "SilentlyContinue"
8787
@@ -96,7 +96,7 @@ Set-IscsiServerTarget -TargetName $targetName -EnableReverseChap $true -ReverseC
9696
`
9797

9898
func setReverseChap(targetName string, password string) error {
99-
script := fmt.Sprintf(IscsiSetReverseChapScript, targetName, password)
99+
script := fmt.Sprintf(iSCSISetReverseChapScript, targetName, password)
100100
_, err := runPowershellScript(script)
101101
if err != nil {
102102
return fmt.Errorf("failed setting reverse CHAP on iSCSI target=%v. err=%v", targetName, err)
@@ -106,7 +106,7 @@ func setReverseChap(targetName string, password string) error {
106106
}
107107

108108
func cleanup() error {
109-
_, err := runPowershellScript(IscsiCleanupScript)
109+
_, err := runPowershellScript(iSCSICleanupScript)
110110
if err != nil {
111111
return fmt.Errorf("failed cleaning up environment. err=%v", err)
112112
}
@@ -121,7 +121,7 @@ func requireCleanup(t *testing.T) {
121121
}
122122
}
123123

124-
const IscsiCleanupScript = `
124+
const iSCSICleanupScript = `
125125
$ErrorActionPreference = "Stop"
126126
$ProgressPreference = "SilentlyContinue"
127127
@@ -172,14 +172,14 @@ func runPowershellScript(script string) (string, error) {
172172
return string(out), nil
173173
}
174174

175-
func setupEnv(targetName string) (*IscsiSetupConfig, error) {
176-
script := fmt.Sprintf(IscsiEnvironmentSetupScript, targetName)
175+
func setupEnv(targetName string) (*iSCSISetupConfig, error) {
176+
script := fmt.Sprintf(iSCSIEnvironmentSetupScript, targetName)
177177
out, err := runPowershellScript(script)
178178
if err != nil {
179179
return nil, fmt.Errorf("failed setting up environment. err=%v", err)
180180
}
181181

182-
config := IscsiSetupConfig{}
182+
config := iSCSISetupConfig{}
183183
err = json.Unmarshal([]byte(out), &config)
184184
if err != nil {
185185
return nil, err

integrationtests/iscsi_test.go

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ import (
1717
"github.com/stretchr/testify/require"
1818
)
1919

20-
const defaultIscsiPort = 3260
20+
const defaultISCSIPort = 3260
2121
const defaultProtoPort = 0 // default value when port is not set
2222

23-
func TestIscsi(t *testing.T) {
24-
skipTestOnCondition(t, !shouldRunIscsiTests())
23+
func TestISCSI(t *testing.T) {
24+
skipTestOnCondition(t, !shouldRunISCSITests())
2525

26-
err := installIscsiTarget()
26+
err := installISCSITarget()
2727
require.NoError(t, err, "Failed installing iSCSI target")
2828

2929
t.Run("List/Add/Remove TargetPortal (Port=3260)", func(t *testing.T) {
30-
targetPortalTest(t, defaultIscsiPort)
30+
targetPortalTest(t, defaultISCSIPort)
3131
})
3232

3333
t.Run("List/Add/Remove TargetPortal (Port not mentioned, effectively 3260)", func(t *testing.T) {
@@ -58,7 +58,7 @@ func e2eTest(t *testing.T) {
5858

5959
defer requireCleanup(t)
6060

61-
iscsiClient, err := iscsi.New(iscsiapi.New())
61+
iSCSIClient, err := iscsi.New(iscsiapi.New())
6262
require.Nil(t, err)
6363

6464
diskClient, err := disk.New(diskapi.New())
@@ -73,27 +73,27 @@ func e2eTest(t *testing.T) {
7373

7474
tp := &iscsi.TargetPortal{
7575
TargetAddress: config.Ip,
76-
TargetPort: defaultIscsiPort,
76+
TargetPort: defaultISCSIPort,
7777
}
7878

7979
addTpReq := &iscsi.AddTargetPortalRequest{
8080
TargetPortal: tp,
8181
}
82-
_, err = iscsiClient.AddTargetPortal(context.Background(), addTpReq)
82+
_, err = iSCSIClient.AddTargetPortal(context.Background(), addTpReq)
8383
assert.Nil(t, err)
8484

8585
discReq := &iscsi.DiscoverTargetPortalRequest{TargetPortal: tp}
86-
discResp, err := iscsiClient.DiscoverTargetPortal(context.TODO(), discReq)
86+
discResp, err := iSCSIClient.DiscoverTargetPortal(context.TODO(), discReq)
8787
if assert.Nil(t, err) {
8888
assert.Contains(t, discResp.Iqns, config.Iqn)
8989
}
9090

9191
connectReq := &iscsi.ConnectTargetRequest{TargetPortal: tp, Iqn: config.Iqn}
92-
_, err = iscsiClient.ConnectTarget(context.TODO(), connectReq)
92+
_, err = iSCSIClient.ConnectTarget(context.TODO(), connectReq)
9393
assert.Nil(t, err)
9494

9595
tgtDisksReq := &iscsi.GetTargetDisksRequest{TargetPortal: tp, Iqn: config.Iqn}
96-
tgtDisksResp, err := iscsiClient.GetTargetDisks(context.TODO(), tgtDisksReq)
96+
tgtDisksResp, err := iSCSIClient.GetTargetDisks(context.TODO(), tgtDisksReq)
9797
require.Nil(t, err)
9898
require.Len(t, tgtDisksResp.DiskIDs, 1)
9999

@@ -120,7 +120,7 @@ func targetTest(t *testing.T) {
120120

121121
defer requireCleanup(t)
122122

123-
iscsiClient, err := iscsi.New(iscsiapi.New())
123+
iSCSIClient, err := iscsi.New(iscsiapi.New())
124124
require.Nil(t, err)
125125

126126
systemClient, err := system.New(systemapi.New())
@@ -132,27 +132,27 @@ func targetTest(t *testing.T) {
132132

133133
tp := &iscsi.TargetPortal{
134134
TargetAddress: config.Ip,
135-
TargetPort: defaultIscsiPort,
135+
TargetPort: defaultISCSIPort,
136136
}
137137

138138
addTpReq := &iscsi.AddTargetPortalRequest{
139139
TargetPortal: tp,
140140
}
141-
_, err = iscsiClient.AddTargetPortal(context.Background(), addTpReq)
141+
_, err = iSCSIClient.AddTargetPortal(context.Background(), addTpReq)
142142
assert.Nil(t, err)
143143

144144
discReq := &iscsi.DiscoverTargetPortalRequest{TargetPortal: tp}
145-
discResp, err := iscsiClient.DiscoverTargetPortal(context.TODO(), discReq)
145+
discResp, err := iSCSIClient.DiscoverTargetPortal(context.TODO(), discReq)
146146
if assert.Nil(t, err) {
147147
assert.Contains(t, discResp.Iqns, config.Iqn)
148148
}
149149

150150
connectReq := &iscsi.ConnectTargetRequest{TargetPortal: tp, Iqn: config.Iqn}
151-
_, err = iscsiClient.ConnectTarget(context.TODO(), connectReq)
151+
_, err = iSCSIClient.ConnectTarget(context.TODO(), connectReq)
152152
assert.Nil(t, err)
153153

154154
disconReq := &iscsi.DisconnectTargetRequest{TargetPortal: tp, Iqn: config.Iqn}
155-
_, err = iscsiClient.DisconnectTarget(context.TODO(), disconReq)
155+
_, err = iSCSIClient.DisconnectTarget(context.TODO(), disconReq)
156156
assert.Nil(t, err)
157157
}
158158

@@ -169,7 +169,7 @@ func targetChapTest(t *testing.T) {
169169
err = setChap(targetName, username, password)
170170
require.NoError(t, err)
171171

172-
iscsiClient, err := iscsi.New(iscsiapi.New())
172+
iSCSIClient, err := iscsi.New(iscsiapi.New())
173173
require.Nil(t, err)
174174

175175
systemClient, err := system.New(systemapi.New())
@@ -181,17 +181,17 @@ func targetChapTest(t *testing.T) {
181181

182182
tp := &iscsi.TargetPortal{
183183
TargetAddress: config.Ip,
184-
TargetPort: defaultIscsiPort,
184+
TargetPort: defaultISCSIPort,
185185
}
186186

187187
addTpReq := &iscsi.AddTargetPortalRequest{
188188
TargetPortal: tp,
189189
}
190-
_, err = iscsiClient.AddTargetPortal(context.Background(), addTpReq)
190+
_, err = iSCSIClient.AddTargetPortal(context.Background(), addTpReq)
191191
assert.Nil(t, err)
192192

193193
discReq := &iscsi.DiscoverTargetPortalRequest{TargetPortal: tp}
194-
discResp, err := iscsiClient.DiscoverTargetPortal(context.TODO(), discReq)
194+
discResp, err := iSCSIClient.DiscoverTargetPortal(context.TODO(), discReq)
195195
if assert.Nil(t, err) {
196196
assert.Contains(t, discResp.Iqns, config.Iqn)
197197
}
@@ -203,11 +203,11 @@ func targetChapTest(t *testing.T) {
203203
ChapSecret: password,
204204
AuthType: iscsi.ONE_WAY_CHAP,
205205
}
206-
_, err = iscsiClient.ConnectTarget(context.TODO(), connectReq)
206+
_, err = iSCSIClient.ConnectTarget(context.TODO(), connectReq)
207207
assert.Nil(t, err)
208208

209209
disconReq := &iscsi.DisconnectTargetRequest{TargetPortal: tp, Iqn: config.Iqn}
210-
_, err = iscsiClient.DisconnectTarget(context.TODO(), disconReq)
210+
_, err = iSCSIClient.DisconnectTarget(context.TODO(), disconReq)
211211
assert.Nil(t, err)
212212
}
213213

@@ -228,7 +228,7 @@ func targetMutualChapTest(t *testing.T) {
228228
err = setReverseChap(targetName, reverse_password)
229229
require.NoError(t, err)
230230

231-
iscsiClient, err := iscsi.New(iscsiapi.New())
231+
iSCSIClient, err := iscsi.New(iscsiapi.New())
232232
require.Nil(t, err)
233233

234234
systemClient, err := system.New(systemapi.New())
@@ -243,21 +243,21 @@ func targetMutualChapTest(t *testing.T) {
243243

244244
tp := &iscsi.TargetPortal{
245245
TargetAddress: config.Ip,
246-
TargetPort: defaultIscsiPort,
246+
TargetPort: defaultISCSIPort,
247247
}
248248

249249
{
250250
req := &iscsi.AddTargetPortalRequest{
251251
TargetPortal: tp,
252252
}
253-
resp, err := iscsiClient.AddTargetPortal(context.Background(), req)
253+
resp, err := iSCSIClient.AddTargetPortal(context.Background(), req)
254254
assert.Nil(t, err)
255255
assert.NotNil(t, resp)
256256
}
257257

258258
{
259259
req := &iscsi.DiscoverTargetPortalRequest{TargetPortal: tp}
260-
resp, err := iscsiClient.DiscoverTargetPortal(context.TODO(), req)
260+
resp, err := iSCSIClient.DiscoverTargetPortal(context.TODO(), req)
261261
if assert.Nil(t, err) && assert.NotNil(t, resp) {
262262
assert.Contains(t, resp.Iqns, config.Iqn)
263263
}
@@ -266,7 +266,7 @@ func targetMutualChapTest(t *testing.T) {
266266
{
267267
// Try using a wrong initiator password and expect error on connection
268268
req := &iscsi.SetMutualChapSecretRequest{MutualChapSecret: "made-up-pass"}
269-
resp, err := iscsiClient.SetMutualChapSecret(context.TODO(), req)
269+
resp, err := iSCSIClient.SetMutualChapSecret(context.TODO(), req)
270270
require.NoError(t, err)
271271
assert.NotNil(t, resp)
272272
}
@@ -279,22 +279,22 @@ func targetMutualChapTest(t *testing.T) {
279279
AuthType: iscsi.MUTUAL_CHAP,
280280
}
281281

282-
_, err = iscsiClient.ConnectTarget(context.TODO(), connectReq)
282+
_, err = iSCSIClient.ConnectTarget(context.TODO(), connectReq)
283283
assert.NotNil(t, err)
284284

285285
{
286286
req := &iscsi.SetMutualChapSecretRequest{MutualChapSecret: reverse_password}
287-
resp, err := iscsiClient.SetMutualChapSecret(context.TODO(), req)
287+
resp, err := iSCSIClient.SetMutualChapSecret(context.TODO(), req)
288288
require.NoError(t, err)
289289
assert.NotNil(t, resp)
290290
}
291291

292-
_, err = iscsiClient.ConnectTarget(context.TODO(), connectReq)
292+
_, err = iSCSIClient.ConnectTarget(context.TODO(), connectReq)
293293
assert.Nil(t, err)
294294

295295
{
296296
req := &iscsi.DisconnectTargetRequest{TargetPortal: tp, Iqn: config.Iqn}
297-
resp, err := iscsiClient.DisconnectTarget(context.TODO(), req)
297+
resp, err := iSCSIClient.DisconnectTarget(context.TODO(), req)
298298
assert.Nil(t, err)
299299
assert.NotNil(t, resp)
300300
}
@@ -306,7 +306,7 @@ func targetPortalTest(t *testing.T, port uint32) {
306306

307307
defer requireCleanup(t)
308308

309-
iscsiClient, err := iscsi.New(iscsiapi.New())
309+
iSCSIClient, err := iscsi.New(iscsiapi.New())
310310
require.Nil(t, err)
311311

312312
systemClient, err := system.New(systemapi.New())
@@ -323,23 +323,23 @@ func targetPortalTest(t *testing.T, port uint32) {
323323

324324
listReq := &iscsi.ListTargetPortalsRequest{}
325325

326-
listResp, err := iscsiClient.ListTargetPortals(context.Background(), listReq)
326+
listResp, err := iSCSIClient.ListTargetPortals(context.Background(), listReq)
327327
if assert.Nil(t, err) {
328328
assert.Len(t, listResp.TargetPortals, 0,
329329
"Expect no registered target portals")
330330
}
331331

332332
addTpReq := &iscsi.AddTargetPortalRequest{TargetPortal: tp}
333-
_, err = iscsiClient.AddTargetPortal(context.Background(), addTpReq)
333+
_, err = iSCSIClient.AddTargetPortal(context.Background(), addTpReq)
334334
assert.Nil(t, err)
335335

336336
// Port 0 (unset) is handled as the default iSCSI port
337337
expectedPort := port
338338
if expectedPort == 0 {
339-
expectedPort = defaultIscsiPort
339+
expectedPort = defaultISCSIPort
340340
}
341341

342-
gotListResp, err := iscsiClient.ListTargetPortals(context.Background(), listReq)
342+
gotListResp, err := iSCSIClient.ListTargetPortals(context.Background(), listReq)
343343
if assert.Nil(t, err) {
344344
assert.Len(t, gotListResp.TargetPortals, 1)
345345
assert.Equal(t, gotListResp.TargetPortals[0].TargetPort, expectedPort)
@@ -349,10 +349,10 @@ func targetPortalTest(t *testing.T, port uint32) {
349349
remReq := &iscsi.RemoveTargetPortalRequest{
350350
TargetPortal: tp,
351351
}
352-
_, err = iscsiClient.RemoveTargetPortal(context.Background(), remReq)
352+
_, err = iSCSIClient.RemoveTargetPortal(context.Background(), remReq)
353353
assert.Nil(t, err)
354354

355-
listResp, err = iscsiClient.ListTargetPortals(context.Background(), listReq)
355+
listResp, err = iSCSIClient.ListTargetPortals(context.Background(), listReq)
356356
if assert.Nil(t, err) {
357357
assert.Len(t, listResp.TargetPortals, 0,
358358
"Expect no registered target portals after delete")

integrationtests/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func skipTestOnCondition(t *testing.T, condition bool) {
3636
// used to skip iSCSI tests as they affect the test machine
3737
// e.g. install an iSCSI target, format a disk, etc.
3838
// Take care to use disposable clean VMs for tests
39-
func shouldRunIscsiTests() bool {
39+
func shouldRunISCSITests() bool {
4040
return os.Getenv("ENABLE_ISCSI_TESTS") == "TRUE"
4141
}
4242

0 commit comments

Comments
 (0)