@@ -1442,6 +1442,7 @@ func TestProjectUpdate(t *testing.T) {
14421442 }
14431443 })
14441444 var latestProject * apiv1.Project
1445+ var updatedProj * apiv1.Project
14451446 latestProject , err = watcher.New [* apiv1.Project ](watchClient ).ByObject (ctx , proj1 , func (latestProject * apiv1.Project ) (bool , error ) {
14461447 if latestProject != nil && latestProject .Status .Namespace != "" {
14471448 return true , nil
@@ -1452,34 +1453,70 @@ func TestProjectUpdate(t *testing.T) {
14521453 t .Fatal ("error while waiting for project to be created:" , err )
14531454 }
14541455 // update default
1455- updatedProj , err := proj1Client .ProjectUpdate (ctx , latestProject , "new-default" , []string {"local" })
1456- if err != nil {
1457- t .Fatal ("error while updating project:" , err )
1456+ for i := 0 ; i < 10 ; i ++ {
1457+ updatedProj , err = proj1Client .ProjectUpdate (ctx , latestProject , "new-default" , []string {"local" })
1458+ if err == nil {
1459+ break
1460+ }
1461+ if ! apierrors .IsConflict (err ) {
1462+ t .Fatal ("error while updating project:" , err )
1463+ }
1464+ latestProject , err = proj1Client .ProjectGet (ctx , projectName )
1465+ if err != nil {
1466+ t .Fatal ("error while getting project:" , err )
1467+ }
14581468 }
14591469
14601470 assert .Equal (t , updatedProj .Spec .DefaultRegion , "new-default" )
14611471 assert .Equal (t , updatedProj .Spec .SupportedRegions , []string {"local" , "new-default" })
14621472
14631473 // swap default from new-default to local
1464- updatedProj , err = proj1Client .ProjectUpdate (ctx , updatedProj , "local" , nil )
1465- if err != nil {
1466- t .Fatal ("error while updating project:" , err )
1474+ for i := 0 ; i < 10 ; i ++ {
1475+ updatedProj , err = proj1Client .ProjectGet (ctx , projectName )
1476+ if err != nil {
1477+ t .Fatal ("error while getting project:" , err )
1478+ }
1479+ updatedProj , err = proj1Client .ProjectUpdate (ctx , updatedProj , "local" , nil )
1480+ if err == nil {
1481+ break
1482+ }
1483+ if ! apierrors .IsConflict (err ) {
1484+ t .Fatal ("error while updating project:" , err )
1485+ }
14671486 }
14681487 assert .Equal (t , updatedProj .Spec .DefaultRegion , "local" )
14691488 assert .Equal (t , updatedProj .Spec .SupportedRegions , []string {"local" , "new-default" })
14701489
14711490 // remove new-default region
1472- updatedProj , err = proj1Client .ProjectUpdate (ctx , updatedProj , "" , []string {"local" })
1473- if err != nil {
1474- t .Fatal ("error while updating project:" , err )
1491+ for i := 0 ; i < 10 ; i ++ {
1492+ updatedProj , err = proj1Client .ProjectGet (ctx , projectName )
1493+ if err != nil {
1494+ t .Fatal ("error while getting project:" , err )
1495+ }
1496+ updatedProj , err = proj1Client .ProjectUpdate (ctx , updatedProj , "" , []string {"local" })
1497+ if err == nil {
1498+ break
1499+ }
1500+ if ! strings .Contains (err .Error (), "please apply your changes to the latest version and try again" ) {
1501+ t .Fatal ("error while updating project:" , err )
1502+ }
14751503 }
14761504 assert .Equal (t , updatedProj .Spec .DefaultRegion , "local" )
14771505 assert .Equal (t , updatedProj .Spec .SupportedRegions , []string {"local" })
14781506
14791507 // set supported regions
1480- updatedProj , err = proj1Client .ProjectUpdate (ctx , updatedProj , "" , []string {"local" , "local3" , "local2" })
1481- if err != nil {
1482- t .Fatal ("error while updating project:" , err )
1508+ for i := 0 ; i < 10 ; i ++ {
1509+ updatedProj , err = proj1Client .ProjectGet (ctx , projectName )
1510+ if err != nil {
1511+ t .Fatal ("error while getting project:" , err )
1512+ }
1513+ updatedProj , err = proj1Client .ProjectUpdate (ctx , updatedProj , "" , []string {"local" , "local3" , "local2" })
1514+ if err == nil {
1515+ break
1516+ }
1517+ if ! apierrors .IsConflict (err ) {
1518+ t .Fatal ("error while updating project:" , err )
1519+ }
14831520 }
14841521 assert .Equal (t , updatedProj .Spec .DefaultRegion , "local" )
14851522 assert .Equal (t , updatedProj .Spec .SupportedRegions , []string {"local" , "local3" , "local2" })
0 commit comments