Add a new "CLI management test" step to the CI pipeline that exercises the full lifecycle of the new management commands against a running daemon: - list target / list lu / list tpgt (read existing config) - create target -> verify in list - create lu -> verify in list - rm lu -> verify removed - rm target -> verify removed Each step validates output with grep assertions so failures are immediately visible. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
232 lines
11 KiB
YAML
232 lines
11 KiB
YAML
# This workflow will build a golang project
|
|
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
|
|
|
|
name: Go
|
|
|
|
on:
|
|
push:
|
|
branches: [ "*" ]
|
|
pull_request:
|
|
|
|
env:
|
|
TARGET: 'iqn.2016-09.com.gotgt.gostor:example_tgt_0'
|
|
TGT_CFG: '{"storages":[{"deviceID":1000,"path":"file:/var/tmp/disk.img","online":true}],"iscsiportals":[{"id":0,"portal":"127.0.0.1:3260"}],"iscsitargets":{"iqn.2016-09.com.gotgt.gostor:example_tgt_0":{"tpgts":{"1":[0]},"luns":{"0":1000}}}}'
|
|
|
|
jobs:
|
|
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.24'
|
|
check-latest: true
|
|
|
|
- name: Depend install
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install libcunit1 libcunit1-doc libcunit1-dev open-iscsi make libnuma-dev -y
|
|
|
|
- name: Gofmt verify
|
|
run: hack/verify-gofmt.sh
|
|
|
|
- name: Build
|
|
run: make
|
|
|
|
- name: Unit Test
|
|
run: go test -v ./pkg/... ./mock/...
|
|
|
|
- name: Function test
|
|
run: |
|
|
dd if=/dev/zero of=/var/tmp/disk.img bs=1024 count=102400
|
|
mkdir $HOME/.gotgt
|
|
echo '${{env.TGT_CFG}}' > $HOME/.gotgt/config.json
|
|
./_output/cmd/bin/gotgt daemon --log debug 1>/dev/null 2>&1 &
|
|
git clone https://github.com/gostor/libiscsi $HOME/libiscsi
|
|
cd $HOME/libiscsi
|
|
sudo ci/install.sh
|
|
export ISCSITEST=yes
|
|
./autogen.sh
|
|
./configure 2>&1 >/dev/null
|
|
make 2>&1 >/dev/null
|
|
|
|
echo "=== Starting Comprehensive libiscsi Tests (60+ tests) ==="
|
|
|
|
# Inquiry Tests
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Inquiry.Standard iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Inquiry.AllocLength iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Inquiry.MandatoryVPDSBC iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Inquiry.SupportedVPD iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Inquiry.VersionDescriptors iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Inquiry.EVPD iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
|
|
# Mandatory Tests
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Mandatory iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.ModeSense6 iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.NoMedia iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
|
|
# Read Tests
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Read6 iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Read10 iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Read12 iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Read16 iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.ReadOnly iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
|
|
# Read Capacity Tests
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.ReadCapacity10 iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.ReadCapacity16 iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
|
|
# Write Tests
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Write10 iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Write12 iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Write16 iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.WriteVerify10 iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.WriteVerify12 iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.WriteVerify16 iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
|
|
# Write Same Tests
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.WriteSame10.Simple iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.WriteSame16.Simple iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
|
|
# Verify Tests
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Verify10 iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Verify12 iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Verify16 iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
|
|
# Prefetch Tests
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Prefetch10 iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Prefetch16 iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
|
|
# Synchronize Cache Tests
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.SynchronizeCache10 iscsi://127.0.0.1:3260/${{env.TARGET}}/0 || true
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.SynchronizeCache16 iscsi://127.0.0.1:3260/${{env.TARGET}}/0 || true
|
|
|
|
# Reserve/Release Tests
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Reserve6.Simple iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
|
|
# Persistent Reservation Tests (known issues with write-path sense data)
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.PrinReadKeys.Simple iscsi://127.0.0.1:3260/${{env.TARGET}}/0 || true
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.PrinReportCapabilities.Simple iscsi://127.0.0.1:3260/${{env.TARGET}}/0 || true
|
|
|
|
# Unmap Tests
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Unmap.Simple iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Unmap.VPD iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.Unmap.ZeroBlocks iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
|
|
# Read Defect Data Tests
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.ReadDefectData10.Simple iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.ReadDefectData12.Simple iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
|
|
# Other SCSI Tests
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.PreventAllow iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.StartStopUnit iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.TestUnitReady iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.ReportSupportedOpcodes.Simple iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
|
|
# iSCSI Protocol Tests
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.iSCSITMF iscsi://127.0.0.1:3260/${{env.TARGET}}/0 || true
|
|
./test-tool/iscsi-test-cu -d -A --test=ALL.iSCSIcmdsn iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
|
|
echo "=== libiscsi Tests Completed ==="
|
|
|
|
# Utility tests
|
|
./utils/iscsi-ls -s iscsi://127.0.0.1:3260/${{env.TARGET}}
|
|
./utils/iscsi-inq iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
./utils/iscsi-readcapacity16 iscsi://127.0.0.1:3260/${{env.TARGET}}/0
|
|
|
|
# iscsi initiator test
|
|
sudo iscsiadm -m discovery -t sendtargets -p 127.0.0.1
|
|
sudo iscsiadm -m node -L all
|
|
sudo iscsiadm -m session
|
|
sudo fdisk -l
|
|
echo -e "n\np\n1\n\n\nt\nc\na\nw" | sudo fdisk /dev/sdb
|
|
sudo mkfs.ext3 /dev/sdb1
|
|
sudo mkdir -p /var/tmp/test
|
|
sudo mount /dev/sdb1 /var/tmp/test
|
|
sudo ls -lh /var/tmp/test/
|
|
|
|
- name: CLI management test
|
|
run: |
|
|
GOTGT=./_output/cmd/bin/gotgt
|
|
|
|
echo "=== CLI Management Tests ==="
|
|
|
|
# 1. List targets - should show the target from config
|
|
echo "--- list target ---"
|
|
$GOTGT list target | tee /tmp/list_target.out
|
|
grep -q "${{env.TARGET}}" /tmp/list_target.out
|
|
echo "PASS: list target shows configured target"
|
|
|
|
# 2. List LUs for the existing target
|
|
echo "--- list lu ---"
|
|
$GOTGT list lu --target "${{env.TARGET}}" | tee /tmp/list_lu.out
|
|
grep -q "LUN" /tmp/list_lu.out
|
|
echo "PASS: list lu returns LU table"
|
|
|
|
# 3. List TPGTs for the existing target
|
|
echo "--- list tpgt ---"
|
|
$GOTGT list tpgt --target "${{env.TARGET}}" | tee /tmp/list_tpgt.out
|
|
grep -q "TPGT" /tmp/list_tpgt.out
|
|
echo "PASS: list tpgt returns TPGT table"
|
|
|
|
# 4. Create a new target via CLI
|
|
echo "--- create target ---"
|
|
NEW_TARGET="iqn.2016-09.com.gotgt.gostor:ci_test_tgt"
|
|
$GOTGT create target --name "$NEW_TARGET" | tee /tmp/create_target.out
|
|
grep -q "successfully created" /tmp/create_target.out
|
|
echo "PASS: create target succeeded"
|
|
|
|
# 5. Verify new target appears in list
|
|
echo "--- verify new target in list ---"
|
|
$GOTGT list target | tee /tmp/list_target2.out
|
|
grep -q "$NEW_TARGET" /tmp/list_target2.out
|
|
echo "PASS: new target visible in list"
|
|
|
|
# 6. Create a new LU on the new target
|
|
echo "--- create lu ---"
|
|
dd if=/dev/zero of=/var/tmp/ci_disk.img bs=1024 count=10240
|
|
$GOTGT create lu --target "$NEW_TARGET" --lun 0 --device-id 2000 --path "file:/var/tmp/ci_disk.img" --block-shift 9 | tee /tmp/create_lu.out
|
|
grep -q "successfully created" /tmp/create_lu.out
|
|
echo "PASS: create lu succeeded"
|
|
|
|
# 7. Verify new LU appears in list
|
|
echo "--- verify new lu in list ---"
|
|
$GOTGT list lu --target "$NEW_TARGET" | tee /tmp/list_lu2.out
|
|
grep -q "/var/tmp/ci_disk.img" /tmp/list_lu2.out
|
|
echo "PASS: new LU visible in list"
|
|
|
|
# 8. Remove the LU
|
|
echo "--- remove lu ---"
|
|
$GOTGT rm lu --target "$NEW_TARGET" --lun 0 | tee /tmp/rm_lu.out
|
|
grep -q "successfully removed" /tmp/rm_lu.out
|
|
echo "PASS: remove lu succeeded"
|
|
|
|
# 9. Verify LU is gone
|
|
echo "--- verify lu removed ---"
|
|
$GOTGT list lu --target "$NEW_TARGET" | tee /tmp/list_lu3.out
|
|
if grep -q "/var/tmp/ci_disk.img" /tmp/list_lu3.out; then
|
|
echo "FAIL: LU still present after removal"
|
|
exit 1
|
|
fi
|
|
echo "PASS: LU no longer in list"
|
|
|
|
# 10. Remove the target
|
|
echo "--- remove target ---"
|
|
$GOTGT rm target --name "$NEW_TARGET" --force | tee /tmp/rm_target.out
|
|
grep -q "successfully removed" /tmp/rm_target.out
|
|
echo "PASS: remove target succeeded"
|
|
|
|
# 11. Verify target is gone
|
|
echo "--- verify target removed ---"
|
|
$GOTGT list target | tee /tmp/list_target3.out
|
|
if grep -q "$NEW_TARGET" /tmp/list_target3.out; then
|
|
echo "FAIL: target still present after removal"
|
|
exit 1
|
|
fi
|
|
echo "PASS: target no longer in list"
|
|
|
|
echo "=== All CLI Management Tests Passed ==="
|