Skip to content

Commit

Permalink
Add test_target_mode_change
Browse files Browse the repository at this point in the history
  • Loading branch information
bmeagherix committed Jan 14, 2025
1 parent 972fa0f commit 2c6aa32
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/api2/test_fibre_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,54 @@ def test_target_delete(self, fc_hosts):
# Make sure we DON'T have a mapping
assert len(call('fcport.query', [['target.id', '=', target_id]])) == 0

def test_target_mode_change(self, fc_hosts):
"""
Ensure that when we change the mode of a mapped FC target, the
mapping gets removed.
"""
with target_lun_zero('fctarget0', 'fcextent0', 100) as config:
target_id = config['target']['id']

# Change the mode of the target
call('iscsi.target.update', target_id, {'mode': 'FC'})

# Now we should be able to successfully map the target
with fcport_create(fc_hosts[0]['alias'], target_id, True):
# Make sure we have a mapping
assert len(call('fcport.query', [['target.id', '=', target_id]])) == 1

# Change the mode of the target to BOTH
call('iscsi.target.update', target_id, {'mode': 'BOTH'})

# Make sure we STILL have a mapping
assert len(call('fcport.query', [['target.id', '=', target_id]])) == 1

# Change the mode of the target to ISCSI
call('iscsi.target.update', target_id, {'mode': 'ISCSI'})

# Make sure we DON'T have a mapping
assert len(call('fcport.query', [['target.id', '=', target_id]])) == 0

# Change the mode of the target to BOTH
call('iscsi.target.update', target_id, {'mode': 'BOTH'})

# Map the target again
with fcport_create(fc_hosts[0]['alias'], target_id, True):
# Make sure we have a mapping
assert len(call('fcport.query', [['target.id', '=', target_id]])) == 1

# Change the mode of the target to BOTH
call('iscsi.target.update', target_id, {'mode': 'FC'})

# Make sure we STILL have a mapping
assert len(call('fcport.query', [['target.id', '=', target_id]])) == 1

# Change the mode of the target to ISCSI
call('iscsi.target.update', target_id, {'mode': 'ISCSI'})

# Make sure we DON'T have a mapping
assert len(call('fcport.query', [['target.id', '=', target_id]])) == 0

def test_npiv_setting(self, fc_hosts):
# Try to set NPIV to -1
with pytest.raises(ValidationErrors) as ve:
Expand Down

0 comments on commit 2c6aa32

Please sign in to comment.