kikocis/falkordb-omnistrate public
Changesets · Branches · Tags · Compare
| Changeset | 848dd218fe66b9ed993dd420f2e7197d4d5751203c9c029aaee962041e63fe8c |
|---|---|
| Author | Dudi <16744955+dudizimber@users.noreply.github.com> · 2024-06-05 12:50 +03:00 |
| Committer | GitHub <noreply@github.com> · 2024-06-05 12:50 +03:00 |
| Parents | 6b4963dc2cce, fd4577d48898 |
9 files changed
modified .github/workflows/build-release-image.yaml +5 −5
| @@ -69,10 +69,10 @@ | ||
| 69 | 69 | |
| 70 | 70 | - name: Replace Variables |
| 71 | 71 | run: | |
| 72 | - sed -i 's/$GcpProjectId/${{ vars.GCP_PROJECT_ID }}/g' omnistrate.${{ matrix.plans.key}}.yaml | |
| 73 | - sed -i 's/$GcpProjectNumber/${{ vars.GCP_PROJECT_NUMBER }}/g' omnistrate.${{ matrix.plans.key}}.yaml | |
| 74 | - sed -i 's/$GcpServiceAccountEmail/${{ vars.GCP_SERVICE_ACCOUNT_EMAIL }}/g' omnistrate.${{ matrix.plans.key}}.yaml | |
| 75 | - sed -i 's/$FalkorDBNodeImage/falkordb\/falkordb-node:${{ github.ref_name }}/g' omnistrate.${{ matrix.plans.key}}.yaml | |
| 72 | + sed -i 's/$GcpProjectId/${{ vars.GCP_PROJECT_ID }}/g' omnistrate.${{ matrix.plans.key }}.yaml | |
| 73 | + sed -i 's/$GcpProjectNumber/${{ vars.GCP_PROJECT_NUMBER }}/g' omnistrate.${{ matrix.plans.key }}.yaml | |
| 74 | + sed -i 's/$GcpServiceAccountEmail/${{ vars.GCP_SERVICE_ACCOUNT_EMAIL }}/g' omnistrate.${{ matrix.plans.key }}.yaml | |
| 75 | + sed -i 's/$FalkorDBNodeImage/falkordb\/falkordb-node:${{ github.ref_name }}/g' omnistrate.${{ matrix.plans.key }}.yaml | |
| 76 | 76 | |
| 77 | 77 | - name: Update Omnistrate plan |
| 78 | 78 | if: ${{ contains(vars.OMNISTRATE_RELEASE_PLANS, matrix.plans.key) }} |
| @@ -81,4 +81,4 @@ | ||
| 81 | 81 | username: ${{ secrets.OMNISTRATE_USERNAME }} |
| 82 | 82 | password: ${{ secrets.OMNISTRATE_PASSWORD }} |
| 83 | 83 | file: ${{ matrix.plans.file }} |
| 84 | - plan-name: ${{ matrix.plans.name }} | |
| 84 | + service-name: ${{ matrix.plans.name }} |
modified .github/workflows/build-test-image.yaml +2 −1
| @@ -69,7 +69,7 @@ | ||
| 69 | 69 | sudo add-apt-repository ppa:rmescandon/yq |
| 70 | 70 | sudo apt update |
| 71 | 71 | sudo apt install yq -y |
| 72 | - yq ea '. as $item ireduce ({}; . * $item )' omnistrate.free.yaml omnistrate.pro.yaml | sed 's/FalkorDB Pro/${{ github.ref_name }}/' > merged.yaml | |
| 72 | + yq ea '. as $item ireduce ({}; . * $item )' omnistrate.free.yaml omnistrate.pro.yaml | sed 's/FalkorDB Pro/${{ github.ref_name == 'main' && 'FalkorDB Internal' || github.ref_name }}/' > merged.yaml | |
| 73 | 73 | |
| 74 | 74 | - name: Upload yaml as artifact |
| 75 | 75 | uses: actions/upload-artifact@v2 |
| @@ -205,6 +205,7 @@ | ||
| 205 | 205 | API_PATH: ${{ matrix.instances.apiPath }} |
| 206 | 206 | API_FAILOVER_PATH: ${{ matrix.instances.apiFailoverPath }} |
| 207 | 207 | API_SIGN_IN_PATH: ${{ matrix.instances.apiSignInPath }} |
| 208 | + REF_NAME: ${{ github.ref_name }} | |
| 208 | 209 | extraParams: ${{ matrix.instances.extraParams }} |
| 209 | 210 | run: | |
| 210 | 211 | python ./tests/${{ matrix.instances.testFile }} ${{ secrets.OMNISTRATE_USERNAME }} ${{ secrets.OMNISTRATE_PASSWORD }} ${{ env.CLOUD_PROVIDER }} ${{ env.CLOUD_REGION }} ${{ env.extraParams }} |
modified falkordb-node/node-entrypoint.sh +44 −1
| @@ -243,6 +243,7 @@ | ||
| 243 | 243 | fi |
| 244 | 244 | |
| 245 | 245 | redis-server $NODE_CONF_FILE --logfile $FALKORDB_LOG_FILE_PATH & |
| 246 | + falkordb_pid=$! | |
| 246 | 247 | tail -F $FALKORDB_LOG_FILE_PATH & |
| 247 | 248 | |
| 248 | 249 | sleep 10 |
| @@ -328,6 +329,7 @@ | ||
| 328 | 329 | fi |
| 329 | 330 | |
| 330 | 331 | redis-server $SENTINEL_CONF_FILE --sentinel --logfile $SENTINEL_LOG_FILE_PATH & |
| 332 | + sentinel_pid=$! | |
| 331 | 333 | tail -F $SENTINEL_LOG_FILE_PATH & |
| 332 | 334 | |
| 333 | 335 | sleep 10 |
| @@ -351,6 +353,7 @@ | ||
| 351 | 353 | echo "Starting Metrics" |
| 352 | 354 | exporter_url=$(if [[ $TLS == "true" ]]; then echo "rediss://$NODE_HOST:$NODE_PORT"; else echo "redis://$NODE_HOST_IP:$NODE_PORT"; fi) |
| 353 | 355 | redis_exporter -skip-tls-verification -redis.password $ADMIN_PASSWORD -redis.addr $exporter_url & |
| 356 | + redis_exporter_pid=$! | |
| 354 | 357 | fi |
| 355 | 358 | |
| 356 | 359 | if [[ $RUN_HEALTH_CHECK -eq 1 ]]; then |
| @@ -358,6 +361,7 @@ | ||
| 358 | 361 | if [ -f /usr/local/bin/healthcheck ]; then |
| 359 | 362 | echo "Starting Healthcheck" |
| 360 | 363 | healthcheck & |
| 364 | + healthcheck_pid=$! | |
| 361 | 365 | else |
| 362 | 366 | echo "Healthcheck binary not found" |
| 363 | 367 | fi |
| @@ -365,4 +369,43 @@ | ||
| 365 | 369 | |
| 366 | 370 | while true; do |
| 367 | 371 | sleep 1 |
| 368 | -done | |
| No newline at the end of the file | ||
| 372 | +done | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | +# Handle signals | |
| 378 | + | |
| 379 | +handle_sigterm() { | |
| 380 | + echo "Caught SIGTERM" | |
| 381 | + echo "Stopping FalkorDB" | |
| 382 | + | |
| 383 | + if [[ $RUN_NODE -eq 1 && ! -z $falkordb_pid ]]; then | |
| 384 | + kill -TERM $falkordb_pid | |
| 385 | + fi | |
| 386 | + | |
| 387 | + if [[ $RUN_SENTINEL -eq 1 && ! -z $sentinel_pid ]]; then | |
| 388 | + kill -TERM $sentinel_pid | |
| 389 | + fi | |
| 390 | + | |
| 391 | + if [[ $RUN_METRICS -eq 1 && ! -z $redis_exporter_pid ]]; then | |
| 392 | + kill -TERM $redis_exporter_pid | |
| 393 | + fi | |
| 394 | + | |
| 395 | + if [[ $RUN_HEALTH_CHECK -eq 1 && ! -z $healthcheck_pid ]]; then | |
| 396 | + kill -TERM $healthcheck_pid | |
| 397 | + fi | |
| 398 | + | |
| 399 | + if [[ ! -z $falkordb_pid ]]; then | |
| 400 | + wait $falkordb_pid | |
| 401 | + fi | |
| 402 | + | |
| 403 | + if [[ ! -z $sentinel_pid ]]; then | |
| 404 | + wait $sentinel_pid | |
| 405 | + fi | |
| 406 | + | |
| 407 | +} | |
| 408 | + | |
| 409 | +trap handle_sigterm SIGTERM | |
| 410 | + | |
| 411 | +wait $falkordb_pid | |
| No newline at the end of the file |
modified tests/requirements.txt +1 −1
| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | redis |
| 2 | 2 | requests |
| 3 | -git+https://github.com/FalkorDB/falkordb-py@sentinel | |
| 3 | +git+https://github.com/FalkorDB/falkordb-py | |
| 4 | 4 | pyjwt |
| No newline at the end of the file |
modified tests/test_free.py +11 −0
| @@ -29,6 +29,17 @@ | ||
| 29 | 29 | ) |
| 30 | 30 | SUBSCRIPTION_ID = os.getenv("SUBSCRIPTION_ID", "sub-bHEl5iUoPd") |
| 31 | 31 | |
| 32 | +REF_NAME = os.getenv("REF_NAME", None) | |
| 33 | +if REF_NAME is not None: | |
| 34 | + if len(REF_NAME) > 50: | |
| 35 | + # Replace the second occurrence of REF_NAME with the first 50 characters of REF_NAME | |
| 36 | + API_PATH = f"customer-hosted/{REF_NAME[:50]}".join( | |
| 37 | + API_PATH.split(f"customer-hosted/{REF_NAME}") | |
| 38 | + ) | |
| 39 | + API_FAILOVER_PATH = f"customer-hosted/{REF_NAME[:50]}".join( | |
| 40 | + API_FAILOVER_PATH.split(f"customer-hosted/{REF_NAME}") | |
| 41 | + ) | |
| 42 | + | |
| 32 | 43 | |
| 33 | 44 | def test_free(): |
| 34 | 45 |
modified tests/test_multi_zone.py +27 −13
| @@ -37,6 +37,17 @@ | ||
| 37 | 37 | ) |
| 38 | 38 | SUBSCRIPTION_ID = os.getenv("SUBSCRIPTION_ID", "sub-bHEl5iUoPd") |
| 39 | 39 | |
| 40 | +REF_NAME = os.getenv("REF_NAME", None) | |
| 41 | +if REF_NAME is not None: | |
| 42 | + if len(REF_NAME) > 50: | |
| 43 | + # Replace the second occurrence of REF_NAME with the first 50 characters of REF_NAME | |
| 44 | + API_PATH = f"customer-hosted/{REF_NAME[:50]}".join( | |
| 45 | + API_PATH.split(f"customer-hosted/{REF_NAME}") | |
| 46 | + ) | |
| 47 | + API_FAILOVER_PATH = f"customer-hosted/{REF_NAME[:50]}".join( | |
| 48 | + API_FAILOVER_PATH.split(f"customer-hosted/{REF_NAME}") | |
| 49 | + ) | |
| 50 | + | |
| 40 | 51 | |
| 41 | 52 | def test_multi_zone(): |
| 42 | 53 | |
| @@ -98,7 +109,12 @@ | ||
| 98 | 109 | filter(lambda resource: resource["id"].startswith("node-mz"), resources) |
| 99 | 110 | ) |
| 100 | 111 | sentinel_resource = next( |
| 101 | - (resource for resource in resources if resource["id"].startswith("sentinel-mz")), None | |
| 112 | + ( | |
| 113 | + resource | |
| 114 | + for resource in resources | |
| 115 | + if resource["id"].startswith("sentinel-mz") | |
| 116 | + ), | |
| 117 | + None, | |
| 102 | 118 | ) |
| 103 | 119 | db_0 = FalkorDB( |
| 104 | 120 | host=db_resource[0]["endpoint"], |
| @@ -132,10 +148,14 @@ | ||
| 132 | 148 | }, |
| 133 | 149 | ) |
| 134 | 150 | |
| 135 | - sentinels_list = random.choice(sentinels.sentinels).execute_command("sentinel sentinels master") | |
| 151 | + sentinels_list = random.choice(sentinels.sentinels).execute_command( | |
| 152 | + "sentinel sentinels master" | |
| 153 | + ) | |
| 136 | 154 | |
| 137 | 155 | if len(sentinels_list) != 2: |
| 138 | - raise Exception(f"Sentinel list not correct. Expected 2, got {len(sentinels_list)}") | |
| 156 | + raise Exception( | |
| 157 | + f"Sentinel list not correct. Expected 2, got {len(sentinels_list)}" | |
| 158 | + ) | |
| 139 | 159 | |
| 140 | 160 | graph_0 = db_0.select_graph("test") |
| 141 | 161 | |
| @@ -153,9 +173,7 @@ | ||
| 153 | 173 | print("Triggering failover for node-mz-0") |
| 154 | 174 | # Trigger failover |
| 155 | 175 | instance.trigger_failover( |
| 156 | - replica_id="node-mz-0", | |
| 157 | - wait_for_ready=False, | |
| 158 | - resource_id="node-mz" | |
| 176 | + replica_id="node-mz-0", wait_for_ready=False, resource_id="node-mz" | |
| 159 | 177 | ) |
| 160 | 178 | |
| 161 | 179 | promotion_completed = False |
| @@ -189,13 +207,11 @@ | ||
| 189 | 207 | |
| 190 | 208 | # wait until the node-mz-0 is ready |
| 191 | 209 | instance.wait_for_ready(timeout_seconds=600) |
| 192 | - | |
| 210 | + | |
| 193 | 211 | print("Triggering failover for sentinel-mz-0") |
| 194 | 212 | # Trigger sentinel failover |
| 195 | 213 | instance.trigger_failover( |
| 196 | - replica_id="sentinel-mz-0", | |
| 197 | - wait_for_ready=False, | |
| 198 | - resource_id="sentinel-mz" | |
| 214 | + replica_id="sentinel-mz-0", wait_for_ready=False, resource_id="sentinel-mz" | |
| 199 | 215 | ) |
| 200 | 216 | |
| 201 | 217 | graph_1 = db_1.select_graph("test") |
| @@ -213,9 +229,7 @@ | ||
| 213 | 229 | print("Triggering failover for node-mz-1") |
| 214 | 230 | # Trigger failover |
| 215 | 231 | instance.trigger_failover( |
| 216 | - replica_id="node-mz-1", | |
| 217 | - wait_for_ready=False, | |
| 218 | - resource_id="node-mz" | |
| 232 | + replica_id="node-mz-1", wait_for_ready=False, resource_id="node-mz" | |
| 219 | 233 | ) |
| 220 | 234 | |
| 221 | 235 | promotion_completed = False |
modified tests/test_single_zone.py +27 −13
| @@ -37,6 +37,17 @@ | ||
| 37 | 37 | ) |
| 38 | 38 | SUBSCRIPTION_ID = os.getenv("SUBSCRIPTION_ID", "sub-bHEl5iUoPd") |
| 39 | 39 | |
| 40 | +REF_NAME = os.getenv("REF_NAME", None) | |
| 41 | +if REF_NAME is not None: | |
| 42 | + if len(REF_NAME) > 50: | |
| 43 | + # Replace the second occurrence of REF_NAME with the first 50 characters of REF_NAME | |
| 44 | + API_PATH = f"customer-hosted/{REF_NAME[:50]}".join( | |
| 45 | + API_PATH.split(f"customer-hosted/{REF_NAME}") | |
| 46 | + ) | |
| 47 | + API_FAILOVER_PATH = f"customer-hosted/{REF_NAME[:50]}".join( | |
| 48 | + API_FAILOVER_PATH.split(f"customer-hosted/{REF_NAME}") | |
| 49 | + ) | |
| 50 | + | |
| 40 | 51 | |
| 41 | 52 | def test_single_zone(): |
| 42 | 53 | |
| @@ -98,7 +109,12 @@ | ||
| 98 | 109 | filter(lambda resource: resource["id"].startswith("node-sz"), resources) |
| 99 | 110 | ) |
| 100 | 111 | sentinel_resource = next( |
| 101 | - (resource for resource in resources if resource["id"].startswith("sentinel-sz")), None | |
| 112 | + ( | |
| 113 | + resource | |
| 114 | + for resource in resources | |
| 115 | + if resource["id"].startswith("sentinel-sz") | |
| 116 | + ), | |
| 117 | + None, | |
| 102 | 118 | ) |
| 103 | 119 | db_0 = FalkorDB( |
| 104 | 120 | host=db_resource[0]["endpoint"], |
| @@ -132,10 +148,14 @@ | ||
| 132 | 148 | }, |
| 133 | 149 | ) |
| 134 | 150 | |
| 135 | - sentinels_list = random.choice(sentinels.sentinels).execute_command("sentinel sentinels master") | |
| 151 | + sentinels_list = random.choice(sentinels.sentinels).execute_command( | |
| 152 | + "sentinel sentinels master" | |
| 153 | + ) | |
| 136 | 154 | |
| 137 | 155 | if len(sentinels_list) != 2: |
| 138 | - raise Exception(f"Sentinel list not correct. Expected 2, got {len(sentinels_list)}") | |
| 156 | + raise Exception( | |
| 157 | + f"Sentinel list not correct. Expected 2, got {len(sentinels_list)}" | |
| 158 | + ) | |
| 139 | 159 | |
| 140 | 160 | graph_0 = db_0.select_graph("test") |
| 141 | 161 | |
| @@ -153,9 +173,7 @@ | ||
| 153 | 173 | print("Triggering failover for node-sz-0") |
| 154 | 174 | # Trigger failover |
| 155 | 175 | instance.trigger_failover( |
| 156 | - replica_id="node-sz-0", | |
| 157 | - wait_for_ready=False, | |
| 158 | - resource_id="node-sz" | |
| 176 | + replica_id="node-sz-0", wait_for_ready=False, resource_id="node-sz" | |
| 159 | 177 | ) |
| 160 | 178 | |
| 161 | 179 | promotion_completed = False |
| @@ -189,13 +207,11 @@ | ||
| 189 | 207 | |
| 190 | 208 | # wait until the node-sz-0 is ready |
| 191 | 209 | instance.wait_for_ready(timeout_seconds=600) |
| 192 | - | |
| 210 | + | |
| 193 | 211 | print("Triggering failover for sentinel-sz-0") |
| 194 | 212 | # Trigger sentinel failover |
| 195 | 213 | instance.trigger_failover( |
| 196 | - replica_id="sentinel-sz-0", | |
| 197 | - wait_for_ready=False, | |
| 198 | - resource_id="sentinel-sz" | |
| 214 | + replica_id="sentinel-sz-0", wait_for_ready=False, resource_id="sentinel-sz" | |
| 199 | 215 | ) |
| 200 | 216 | |
| 201 | 217 | graph_1 = db_1.select_graph("test") |
| @@ -213,9 +229,7 @@ | ||
| 213 | 229 | print("Triggering failover for node-sz-1") |
| 214 | 230 | # Trigger failover |
| 215 | 231 | instance.trigger_failover( |
| 216 | - replica_id="node-sz-1", | |
| 217 | - wait_for_ready=False, | |
| 218 | - resource_id="node-sz" | |
| 232 | + replica_id="node-sz-1", wait_for_ready=False, resource_id="node-sz" | |
| 219 | 233 | ) |
| 220 | 234 | |
| 221 | 235 | promotion_completed = False |
modified tests/test_standalone.py +11 −0
| @@ -33,6 +33,17 @@ | ||
| 33 | 33 | ) |
| 34 | 34 | SUBSCRIPTION_ID = os.getenv("SUBSCRIPTION_ID", "sub-bHEl5iUoPd") |
| 35 | 35 | |
| 36 | +REF_NAME = os.getenv("REF_NAME", None) | |
| 37 | +if REF_NAME is not None: | |
| 38 | + if len(REF_NAME) > 50: | |
| 39 | + # Replace the second occurrence of REF_NAME with the first 50 characters of REF_NAME | |
| 40 | + API_PATH = f"customer-hosted/{REF_NAME[:50]}".join( | |
| 41 | + API_PATH.split(f"customer-hosted/{REF_NAME}") | |
| 42 | + ) | |
| 43 | + API_FAILOVER_PATH = f"customer-hosted/{REF_NAME[:50]}".join( | |
| 44 | + API_FAILOVER_PATH.split(f"customer-hosted/{REF_NAME}") | |
| 45 | + ) | |
| 46 | + | |
| 36 | 47 | |
| 37 | 48 | def test_standalone(): |
| 38 | 49 |
modified tests/test_update_memory.py +18 −3
| @@ -34,6 +34,17 @@ | ||
| 34 | 34 | ) |
| 35 | 35 | SUBSCRIPTION_ID = os.getenv("SUBSCRIPTION_ID", "sub-bHEl5iUoPd") |
| 36 | 36 | |
| 37 | +REF_NAME = os.getenv("REF_NAME", None) | |
| 38 | +if REF_NAME is not None: | |
| 39 | + if len(REF_NAME) > 50: | |
| 40 | + # Replace the second occurrence of REF_NAME with the first 50 characters of REF_NAME | |
| 41 | + API_PATH = f"customer-hosted/{REF_NAME[:50]}".join( | |
| 42 | + API_PATH.split(f"customer-hosted/{REF_NAME}") | |
| 43 | + ) | |
| 44 | + API_FAILOVER_PATH = f"customer-hosted/{REF_NAME[:50]}".join( | |
| 45 | + API_FAILOVER_PATH.split(f"customer-hosted/{REF_NAME}") | |
| 46 | + ) | |
| 47 | + | |
| 37 | 48 | |
| 38 | 49 | def test_update_memory(): |
| 39 | 50 | |
| @@ -67,7 +78,9 @@ | ||
| 67 | 78 | instance.generate_data(graph_count=1000) |
| 68 | 79 | |
| 69 | 80 | # Update memory |
| 70 | - instance.update_instance_type(DEPLOYMENT_INSTANCE_TYPE_NEW, wait_until_ready=True) | |
| 81 | + instance.update_instance_type( | |
| 82 | + DEPLOYMENT_INSTANCE_TYPE_NEW, wait_until_ready=True | |
| 83 | + ) | |
| 71 | 84 | |
| 72 | 85 | check_data_loss(instance, keys=1000) |
| 73 | 86 | |
| @@ -89,8 +102,10 @@ | ||
| 89 | 102 | info = connection.execute_command("INFO") |
| 90 | 103 | |
| 91 | 104 | # Check the number of keys |
| 92 | - assert int(info["db0"]["keys"]) > keys, f"Data loss detected. Expected {keys} keys, got {info['db0']['keys']}" | |
| 105 | + assert ( | |
| 106 | + int(info["db0"]["keys"]) > keys | |
| 107 | + ), f"Data loss detected. Expected {keys} keys, got {info['db0']['keys']}" | |
| 93 | 108 | |
| 94 | 109 | |
| 95 | 110 | if __name__ == "__main__": |
| 96 | - test_update_memory() | |
| No newline at the end of the file | ||
| 111 | + test_update_memory() |