Github user tzulitai commented on a diff in the pull request:

    https://github.com/apache/flink/pull/6074#discussion_r190786548
  
    --- Diff: flink-end-to-end-tests/test-scripts/elasticsearch-common.sh ---
    @@ -61,8 +61,9 @@ function verify_result {
             rm $TEST_DATA_DIR/output
         fi
     
    -    while : ; do
    -      curl 'localhost:9200/index/_search?q=*&pretty&size=21' > 
$TEST_DATA_DIR/output
    +    # make sure can terminate properly with control-C.
    +    while [ $? -ne 130 ]; do
    --- End diff --
    
    I would prefer that we just wrap the Elasticsearch querying to another 
function, that improves readability.
    
    Something along the lines of:
    ```
    function fetch_elasticsearch {
        curl 'localhost:9200/index3/_count?q=*&pretty' > $TEST_DATA_DIR/output
        echo $(grep '\"count\"' $TEST_DATA_DIR/output | awk '{print $3}' | sed 
's/\(.*\),/\1 /')
    }
    
    function verify_result {
        local numRecords=$1
    
        if [ -f "$TEST_DATA_DIR/output" ]; then
            rm $TEST_DATA_DIR/output
        fi
    
        while (( $(fetch_elasticsearch) < $numRecords )) ; do
          echo "Waiting for Elasticsearch records ..."
          sleep 1
        done
    }
    ```


---

Reply via email to