Skip to content

Write and verify delivery

For the complete documentation index see: llms.txt

All documentation pages available in markdown.

Write a dispute record to Aerospike to simulate an authorization-service write, then confirm it reaches Elasticsearch over the encrypted pipeline using the same test.disputes set from the get-started tutorial.

  1. Write a dispute record and verify delivery through Cross-Datacenter Replication (XDR) over mTLS. The script waits for pending XDR work to finish, captures the cumulative success counter, writes the record with aql, and waits for the counter to increase by one.

    Terminal
    Terminal
    write_and_wait_for_xdr() {
    attempt=1
    while [ "$attempt" -le 30 ]; do
    stats="$(docker compose exec -T aerospike asinfo -v 'get-stats:context=xdr;dc=esDC')" || return 1
    baseline="$(printf '%s\n' "$stats" | tr ';' '\n' | awk -F= '$1 == "success" {print $2}')"
    in_queue="$(printf '%s\n' "$stats" | tr ';' '\n' | awk -F= '$1 == "in_queue" {print $2}')"
    in_progress="$(printf '%s\n' "$stats" | tr ';' '\n' | awk -F= '$1 == "in_progress" {print $2}')"
    case "$baseline" in ''|*[!0-9]*) echo 'Could not read the XDR success counter' >&2; return 1;; esac
    case "$in_queue" in ''|*[!0-9]*) echo 'Could not read the XDR queue counter' >&2; return 1;; esac
    case "$in_progress" in ''|*[!0-9]*) echo 'Could not read the XDR in-progress counter' >&2; return 1;; esac
    [ "$in_queue" -eq 0 ] && [ "$in_progress" -eq 0 ] && break
    attempt=$((attempt + 1))
    sleep 1
    done
    if [ "$in_queue" -ne 0 ] || [ "$in_progress" -ne 0 ]; then
    echo 'Timed out waiting for pending XDR deliveries' >&2
    return 1
    fi
    target=$((baseline + 1))
    docker compose exec -T aerospike-tools \
    aql -h aerospike -c "INSERT INTO test.disputes (PK, merchant, amount_cents, status, memo) VALUES ('txn-tls-1', 'Orbit Stream Media', 1599, 'open', 'Streaming plan renewal')" || return 1
    attempt=1
    while [ "$attempt" -le 30 ]; do
    stats="$(docker compose exec -T aerospike asinfo -v 'get-stats:context=xdr;dc=esDC')" || return 1
    success="$(printf '%s\n' "$stats" | tr ';' '\n' | awk -F= '$1 == "success" {print $2}')"
    case "$success" in ''|*[!0-9]*) echo 'Could not read the XDR success counter' >&2; return 1;; esac
    [ "$success" -ge "$target" ] && {
    printf 'baseline=%s target=%s success=%s\n' "$baseline" "$target" "$success"
    return 0
    }
    attempt=$((attempt + 1))
    sleep 1
    done
    echo 'Timed out waiting for the XDR delivery' >&2
    printf '%s\n' "$stats" >&2
    return 1
    }
    write_and_wait_for_xdr
    delivery_status=$?
    unset -f write_and_wait_for_xdr
    [ "$delivery_status" -eq 0 ]
    Insert and XDR delivery result
    Expected output
    OK, 1 record affected.
    baseline=... target=... success=...

    The final line confirms that the cumulative XDR success counter reached the target for this write. If the command times out, see Troubleshoot.

  2. Confirm the record reached Elasticsearch over HTTPS. The -u flag supplies the basic-auth credentials and --cacert trusts the local CA.

    Terminal
    Terminal
    curl -fsS -X POST --cacert ./security/ca.crt \
    -u elastic:changeme-for-dev \
    'https://localhost:9200/aerospike/_refresh' > /dev/null
    curl -fsS --cacert ./security/ca.crt \
    -u elastic:changeme-for-dev \
    'https://localhost:9200/aerospike/_count?pretty'
    Index record count
    Expected output
    {
    "count": 1,
    "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
    }
    }

    The matching count confirms the record reached Elasticsearch through both TLS-protected hops.

The dispute you wrote is indexed and reachable only over TLS. You can now run the same search as a support agent.