@@ -12838,6 +12838,15 @@ func TestValidateBackendUpdateConcurrentCore(t *testing.T) {
1283812838}
1283912839
1284012840func TestUpdateBackendVolumesConcurrentCore(t *testing.T) {
12841+ volConfig1 := &storage.VolumeConfig{
12842+ Name: "testVolume1",
12843+ InternalName: "testVolume1",
12844+ }
12845+ volConfig2 := &storage.VolumeConfig{
12846+ Name: "testVolume2",
12847+ InternalName: "testVolume2",
12848+ }
12849+
1284112850 tests := []struct {
1284212851 name string
1284312852 setupMocks func(mockCtrl *gomock.Controller, mockStoreClient *mockpersistentstore.MockStoreClient, o *ConcurrentTridentOrchestrator) storage.Backend
@@ -12852,10 +12861,7 @@ func TestUpdateBackendVolumesConcurrentCore(t *testing.T) {
1285212861
1285312862 // Setup volume that exists in cache but not on backend (should become orphaned)
1285412863 vol := &storage.Volume{
12855- Config: &storage.VolumeConfig{
12856- Name: "testVolume1",
12857- InternalName: "testVolume1",
12858- },
12864+ Config: volConfig1,
1285912865 BackendUUID: "backend-uuid1",
1286012866 Orphaned: false,
1286112867 }
@@ -12864,7 +12870,7 @@ func TestUpdateBackendVolumesConcurrentCore(t *testing.T) {
1286412870 addBackendsToCache(t, mockBackend)
1286512871
1286612872 mockBackend.EXPECT().Driver().Return(mockDriver).Times(1)
12867- mockDriver.EXPECT().Get(gomock.Any(), "testVolume1" ).Return(errors.New("volume not found")).Times(1)
12873+ mockDriver.EXPECT().Get(gomock.Any(), volConfig1 ).Return(errors.New("volume not found")).Times(1)
1286812874
1286912875 mockStoreClient.EXPECT().UpdateVolume(gomock.Any(), gomock.Any()).DoAndReturn(func(ctx context.Context, volume *storage.Volume) error {
1287012876 assert.True(t, volume.Orphaned)
@@ -12893,10 +12899,7 @@ func TestUpdateBackendVolumesConcurrentCore(t *testing.T) {
1289312899
1289412900 // Setup orphaned volume that now exists on backend (should be recovered)
1289512901 vol := &storage.Volume{
12896- Config: &storage.VolumeConfig{
12897- Name: "testVolume1",
12898- InternalName: "testVolume1",
12899- },
12902+ Config: volConfig1,
1290012903 BackendUUID: "backend-uuid1",
1290112904 Orphaned: true,
1290212905 }
@@ -12905,7 +12908,7 @@ func TestUpdateBackendVolumesConcurrentCore(t *testing.T) {
1290512908 addBackendsToCache(t, mockBackend)
1290612909
1290712910 mockBackend.EXPECT().Driver().Return(mockDriver).Times(1)
12908- mockDriver.EXPECT().Get(gomock.Any(), "testVolume1" ).Return(nil).Times(1)
12911+ mockDriver.EXPECT().Get(gomock.Any(), volConfig1 ).Return(nil).Times(1)
1290912912
1291012913 mockStoreClient.EXPECT().UpdateVolume(gomock.Any(), gomock.Any()).DoAndReturn(func(ctx context.Context, volume *storage.Volume) error {
1291112914 assert.False(t, volume.Orphaned)
@@ -12934,10 +12937,7 @@ func TestUpdateBackendVolumesConcurrentCore(t *testing.T) {
1293412937
1293512938 // Setup volume that exists and is not orphaned (no change needed)
1293612939 vol := &storage.Volume{
12937- Config: &storage.VolumeConfig{
12938- Name: "testVolume1",
12939- InternalName: "testVolume1",
12940- },
12940+ Config: volConfig1,
1294112941 BackendUUID: "backend-uuid1",
1294212942 Orphaned: false,
1294312943 }
@@ -12946,7 +12946,7 @@ func TestUpdateBackendVolumesConcurrentCore(t *testing.T) {
1294612946 addBackendsToCache(t, mockBackend)
1294712947
1294812948 mockBackend.EXPECT().Driver().Return(mockDriver).Times(1)
12949- mockDriver.EXPECT().Get(gomock.Any(), "testVolume1" ).Return(nil).Times(1)
12949+ mockDriver.EXPECT().Get(gomock.Any(), volConfig1 ).Return(nil).Times(1)
1295012950
1295112951 // No UpdateVolume call expected since state doesn't change
1295212952 mockBackend.EXPECT().Volumes().Return(&sync.Map{}).Times(1)
@@ -12971,18 +12971,12 @@ func TestUpdateBackendVolumesConcurrentCore(t *testing.T) {
1297112971
1297212972 // Setup multiple volumes with different states
1297312973 vol1 := &storage.Volume{
12974- Config: &storage.VolumeConfig{
12975- Name: "testVolume1",
12976- InternalName: "testVolume1",
12977- },
12974+ Config: volConfig1,
1297812975 BackendUUID: "backend-uuid1",
1297912976 Orphaned: false,
1298012977 }
1298112978 vol2 := &storage.Volume{
12982- Config: &storage.VolumeConfig{
12983- Name: "testVolume2",
12984- InternalName: "testVolume2",
12985- },
12979+ Config: volConfig2,
1298612980 BackendUUID: "backend-uuid1",
1298712981 Orphaned: true,
1298812982 }
@@ -12992,9 +12986,9 @@ func TestUpdateBackendVolumesConcurrentCore(t *testing.T) {
1299212986
1299312987 mockBackend.EXPECT().Driver().Return(mockDriver).Times(2)
1299412988 // Vol1 not found on backend (becomes orphaned)
12995- mockDriver.EXPECT().Get(gomock.Any(), "testVolume1" ).Return(errors.New("not found")).Times(1)
12989+ mockDriver.EXPECT().Get(gomock.Any(), volConfig1 ).Return(errors.New("not found")).Times(1)
1299612990 // Vol2 found on backend (recovered)
12997- mockDriver.EXPECT().Get(gomock.Any(), "testVolume2" ).Return(nil).Times(1)
12991+ mockDriver.EXPECT().Get(gomock.Any(), volConfig2 ).Return(nil).Times(1)
1299812992
1299912993 // Expect two update calls
1300012994 gomock.InOrder(
@@ -13035,10 +13029,7 @@ func TestUpdateBackendVolumesConcurrentCore(t *testing.T) {
1303513029 mockBackend := getMockBackend(mockCtrl, "testBackend1", "backend-uuid1")
1303613030
1303713031 vol := &storage.Volume{
13038- Config: &storage.VolumeConfig{
13039- Name: "testVolume1",
13040- InternalName: "testVolume1",
13041- },
13032+ Config: volConfig1,
1304213033 BackendUUID: "backend-uuid1",
1304313034 Orphaned: false,
1304413035 }
@@ -13061,10 +13052,7 @@ func TestUpdateBackendVolumesConcurrentCore(t *testing.T) {
1306113052 mockBackend := getMockBackend(mockCtrl, "testBackend1", "backend-uuid1")
1306213053
1306313054 vol := &storage.Volume{
13064- Config: &storage.VolumeConfig{
13065- Name: "testVolume1",
13066- InternalName: "testVolume1",
13067- },
13055+ Config: volConfig1,
1306813056 BackendUUID: "backend-uuid1",
1306913057 Orphaned: false,
1307013058 }
@@ -13091,10 +13079,7 @@ func TestUpdateBackendVolumesConcurrentCore(t *testing.T) {
1309113079 mockDriver := mockstorage.NewMockDriver(mockCtrl)
1309213080
1309313081 vol := &storage.Volume{
13094- Config: &storage.VolumeConfig{
13095- Name: "testVolume1",
13096- InternalName: "testVolume1",
13097- },
13082+ Config: volConfig1,
1309813083 BackendUUID: "backend-uuid1",
1309913084 Orphaned: false,
1310013085 }
@@ -13103,7 +13088,7 @@ func TestUpdateBackendVolumesConcurrentCore(t *testing.T) {
1310313088 addBackendsToCache(t, mockBackend)
1310413089
1310513090 mockBackend.EXPECT().Driver().Return(mockDriver).Times(1)
13106- mockDriver.EXPECT().Get(gomock.Any(), "testVolume1" ).Return(errors.New("not found")).Times(1)
13091+ mockDriver.EXPECT().Get(gomock.Any(), volConfig1 ).Return(errors.New("not found")).Times(1)
1310713092
1310813093 // Simulate store update failure
1310913094 mockStoreClient.EXPECT().UpdateVolume(gomock.Any(), gomock.Any()).Return(errors.New("store error")).Times(1)
0 commit comments