@@ -1509,21 +1509,157 @@ d-98x-redis-advertised-1:31318.shard-7hy@falkordb-shard-7hy-redis-advertised-0:3
15091509 End
15101510
15111511 Describe " scale_in_redis_cluster_shard()"
1512- Context " when KB_CLUSTER_COMPONENT_IS_SCALING_IN env is not set"
1512+ Context " when no scale-in signal is set"
15131513 setup () {
1514- export KB_CLUSTER_COMPONENT_IS_SCALING_IN=" "
1514+ unset KB_CLUSTER_COMPONENT_IS_SCALING_IN
1515+ export CURRENT_SHARD_COMPONENT_NAME=" falkordb-shard-98x"
1516+ export KB_CLUSTER_COMPONENT_DELETING_LIST=" "
1517+ export KB_CLUSTER_COMPONENT_UNDELETED_LIST=" falkordb-shard-98x,falkordb-shard-7hy"
1518+ }
1519+ Before " setup"
1520+
1521+ un_setup () {
1522+ unset KB_CLUSTER_COMPONENT_IS_SCALING_IN
1523+ unset CURRENT_SHARD_COMPONENT_NAME
1524+ unset KB_CLUSTER_COMPONENT_DELETING_LIST
1525+ unset KB_CLUSTER_COMPONENT_UNDELETED_LIST
1526+ }
1527+ After " un_setup"
1528+
1529+ It " returns 0 and skips scale-in cleanup"
1530+ When call scale_in_redis_cluster_shard
1531+ The status should be success
1532+ The output should include " The KB_CLUSTER_COMPONENT_IS_SCALING_IN env is not set and current component is not exclusively in KB_CLUSTER_COMPONENT_DELETING_LIST, skip scaling in"
1533+ End
1534+ End
1535+
1536+ Context " when legacy KB_CLUSTER_COMPONENT_IS_SCALING_IN env is not set but deleting lists identify scale-in target"
1537+ find_exist_available_node () {
1538+ echo " falkordb-shard-7hy-0.namespace.svc.cluster.local:6379"
1539+ }
1540+
1541+ get_current_comp_nodes_for_scale_in () {
1542+ current_comp_primary_node=(" falkordb-shard-98x-0.namespace.svc.cluster.local:6379" )
1543+ current_comp_other_nodes=(" falkordb-shard-98x-1.namespace.svc.cluster.local:6379" )
1544+ }
1545+
1546+ get_cluster_id () {
1547+ echo " cluster_id_123"
1548+ }
1549+
1550+ scale_in_shard_rebalance_to_zero () {
1551+ return 0
1552+ }
1553+
1554+ scale_in_shard_del_node () {
1555+ return 0
1556+ }
1557+
1558+ setup () {
1559+ unset KB_CLUSTER_COMPONENT_IS_SCALING_IN
1560+ export CURRENT_SHARD_COMPONENT_SHORT_NAME=" shard-98x"
1561+ export CURRENT_SHARD_COMPONENT_NAME=" falkordb-shard-98x"
1562+ export KB_CLUSTER_POD_NAME_LIST=" falkordb-shard-98x-0,falkordb-shard-98x-1,falkordb-shard-7hy-0,falkordb-shard-7hy-1,falkordb-shard-jwl-0,falkordb-shard-jwl-1,falkordb-shard-kpl-0,falkordb-shard-kpl-1"
1563+ export KB_CLUSTER_POD_HOST_IP_LIST=" 10.42.0.1,10.42.0.2,10.42.0.3,10.42.0.4,10.42.0.5,10.42.0.6,10.42.0.7,10.42.0.8"
1564+ export KB_CLUSTER_COMPONENT_POD_NAME_LIST=" falkordb-shard-98x-0,falkordb-shard-98x-1"
1565+ export KB_CLUSTER_COMPONENT_POD_HOST_IP_LIST=" 10.42.0.1,10.42.0.2"
1566+ export KB_CLUSTER_POD_IP_LIST=" 172.42.0.1,172.42.0.2,172.42.0.3,172.42.0.4,172.42.0.5,172.42.0.6,172.42.0.7,172.42.0.8"
1567+ export KB_CLUSTER_COMPONENT_LIST=" falkordb-shard-98x,falkordb-shard-7hy,falkordb-shard-jwl,falkordb-shard-kpl"
1568+ export KB_CLUSTER_COMPONENT_DELETING_LIST=" falkordb-shard-98x"
1569+ export KB_CLUSTER_COMPONENT_UNDELETED_LIST=" falkordb-shard-7hy,falkordb-shard-jwl,falkordb-shard-kpl"
1570+ export SERVICE_PORT=" 6379"
1571+ }
1572+ Before " setup"
1573+
1574+ un_setup () {
1575+ unset KB_CLUSTER_COMPONENT_IS_SCALING_IN
1576+ unset CURRENT_SHARD_COMPONENT_SHORT_NAME
1577+ unset CURRENT_SHARD_COMPONENT_NAME
1578+ unset KB_CLUSTER_POD_NAME_LIST
1579+ unset KB_CLUSTER_POD_HOST_IP_LIST
1580+ unset KB_CLUSTER_COMPONENT_POD_NAME_LIST
1581+ unset KB_CLUSTER_COMPONENT_POD_HOST_IP_LIST
1582+ unset KB_CLUSTER_POD_IP_LIST
1583+ unset KB_CLUSTER_COMPONENT_LIST
1584+ unset KB_CLUSTER_COMPONENT_DELETING_LIST
1585+ unset KB_CLUSTER_COMPONENT_UNDELETED_LIST
1586+ unset SERVICE_PORT
1587+ }
1588+ After " un_setup"
1589+
1590+ It " runs scale-in cleanup without the legacy scaling-in flag"
1591+ When call scale_in_redis_cluster_shard
1592+ The status should be success
1593+ The output should include " Detected scale-in context from KB_CLUSTER_COMPONENT_DELETING_LIST/UNDELETED_LIST"
1594+ The output should include " FalkorDB cluster scale in shard rebalance to zero successfully"
1595+ The output should include " FalkorDB cluster scale in shard delete node falkordb-shard-98x-0.namespace.svc.cluster.local:6379 successfully"
1596+ The output should include " FalkorDB cluster scale in shard delete node falkordb-shard-98x-1.namespace.svc.cluster.local:6379 successfully"
1597+ End
1598+ End
1599+
1600+ Context " when shardRemove action identifies the removed shard"
1601+ find_exist_available_node () {
1602+ echo " falkordb-shard-7hy-0.namespace.svc.cluster.local:6379"
1603+ }
1604+
1605+ get_current_comp_nodes_for_scale_in () {
1606+ current_comp_primary_node=(" falkordb-shard-98x-0.namespace.svc.cluster.local:6379" )
1607+ current_comp_other_nodes=(" falkordb-shard-98x-1.namespace.svc.cluster.local:6379" )
1608+ }
1609+
1610+ get_cluster_id () {
1611+ echo " cluster_id_123"
1612+ }
1613+
1614+ scale_in_shard_rebalance_to_zero () {
1615+ return 0
1616+ }
1617+
1618+ scale_in_shard_del_node () {
1619+ return 0
1620+ }
1621+
1622+ setup () {
1623+ unset KB_CLUSTER_COMPONENT_IS_SCALING_IN
1624+ export KB_REMOVE_SHARD_NAME=" 98x"
1625+ export CURRENT_SHARD_COMPONENT_SHORT_NAME=" shard-98x"
1626+ export CURRENT_SHARD_COMPONENT_NAME=" falkordb-shard-98x"
1627+ export KB_CLUSTER_POD_NAME_LIST=" falkordb-shard-98x-0,falkordb-shard-98x-1,falkordb-shard-7hy-0,falkordb-shard-7hy-1,falkordb-shard-jwl-0,falkordb-shard-jwl-1,falkordb-shard-kpl-0,falkordb-shard-kpl-1"
1628+ export KB_CLUSTER_POD_HOST_IP_LIST=" 10.42.0.1,10.42.0.2,10.42.0.3,10.42.0.4,10.42.0.5,10.42.0.6,10.42.0.7,10.42.0.8"
1629+ export KB_CLUSTER_COMPONENT_POD_NAME_LIST=" falkordb-shard-98x-0,falkordb-shard-98x-1"
1630+ export KB_CLUSTER_COMPONENT_POD_HOST_IP_LIST=" 10.42.0.1,10.42.0.2"
1631+ export KB_CLUSTER_POD_IP_LIST=" 172.42.0.1,172.42.0.2,172.42.0.3,172.42.0.4,172.42.0.5,172.42.0.6,172.42.0.7,172.42.0.8"
1632+ export KB_CLUSTER_COMPONENT_LIST=" falkordb-shard-98x,falkordb-shard-7hy,falkordb-shard-jwl,falkordb-shard-kpl"
1633+ export KB_CLUSTER_COMPONENT_DELETING_LIST=" "
1634+ export KB_CLUSTER_COMPONENT_UNDELETED_LIST=" "
1635+ export SERVICE_PORT=" 6379"
15151636 }
15161637 Before " setup"
15171638
15181639 un_setup () {
15191640 unset KB_CLUSTER_COMPONENT_IS_SCALING_IN
1641+ unset KB_REMOVE_SHARD_NAME
1642+ unset CURRENT_SHARD_COMPONENT_SHORT_NAME
1643+ unset CURRENT_SHARD_COMPONENT_NAME
1644+ unset KB_CLUSTER_POD_NAME_LIST
1645+ unset KB_CLUSTER_POD_HOST_IP_LIST
1646+ unset KB_CLUSTER_COMPONENT_POD_NAME_LIST
1647+ unset KB_CLUSTER_COMPONENT_POD_HOST_IP_LIST
1648+ unset KB_CLUSTER_POD_IP_LIST
1649+ unset KB_CLUSTER_COMPONENT_LIST
1650+ unset KB_CLUSTER_COMPONENT_DELETING_LIST
1651+ unset KB_CLUSTER_COMPONENT_UNDELETED_LIST
1652+ unset SERVICE_PORT
15201653 }
15211654 After " un_setup"
15221655
1523- It " returns 0 when KB_CLUSTER_COMPONENT_IS_SCALING_IN env is not set "
1656+ It " runs scale-in cleanup and derives deleting lists from KB_REMOVE_SHARD_NAME "
15241657 When call scale_in_redis_cluster_shard
15251658 The status should be success
1526- The output should include " The KB_CLUSTER_COMPONENT_IS_SCALING_IN env is not set, skip scaling in"
1659+ The output should include " Detected scale-in context from KB_REMOVE_SHARD_NAME"
1660+ The output should include " FalkorDB cluster scale in shard rebalance to zero successfully"
1661+ The output should include " FalkorDB cluster scale in shard delete node falkordb-shard-98x-0.namespace.svc.cluster.local:6379 successfully"
1662+ The output should include " FalkorDB cluster scale in shard delete node falkordb-shard-98x-1.namespace.svc.cluster.local:6379 successfully"
15271663 End
15281664 End
15291665
0 commit comments