Skip to content

Commit

Permalink
fix Windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
fstab committed Apr 30, 2017
1 parent d4ec249 commit cec7c62
Showing 1 changed file with 68 additions and 63 deletions.
131 changes: 68 additions & 63 deletions integration-test.sh
Expand Up @@ -105,82 +105,87 @@ echo '30.07.2016 14:37:33 alice 2.5' >> $log_file
echo '30.07.2016 14:43:02 bob 2.5' >> $log_file

function checkMetric() {
val=$(curl -s http://localhost:9144/metrics | grep -v '#' | grep "$1 ") || ( echo "FAILED: Metric '$1' not found." >&2 && exit -1 )
echo $val | grep "$1 $2" > /dev/null || ( echo "FAILED: Expected '$1 $2', but got '$val'." >&2 && exit -1 )
escaped=$(echo $1 | sed 's,\\,\\\\,g')
val=$(curl -s http://localhost:9144/metrics | grep -v '#' | grep "$escaped ") || ( echo "FAILED: Metric '$1' not found." >&2 && exit -1 )
echo $val | grep "$escaped $2" > /dev/null || ( echo "FAILED: Expected '$1 $2', but got '$val'." >&2 && exit -1 )
}

input=$(cygpath -w $log_file | sed 's,\\,\\\\,g')

echo "Checking metrics..."

checkMetric "grok_test_counter_nolabels{input=\"$(cygpath -w $log_file)\"}" 3
checkMetric "grok_test_counter_labels{input=\"$(cygpath -w $log_file)\",user=\"alice\"}" 2
checkMetric "grok_test_counter_labels{input=\"$(cygpath -w $log_file)\",user=\"bob\"}" 1

checkMetric "grok_test_gauge_nolabels{input=\"$(cygpath -w $log_file)\"}" 2.5
checkMetric "grok_test_gauge_labels{input=\"$(cygpath -w $log_file)\",user=\"alice\"}" 2.5
checkMetric "grok_test_gauge_labels{input=\"$(cygpath -w $log_file)\",user=\"bob\"}" 2.5

checkMetric "grok_test_histogram_nolabels_bucket{input=\"$(cygpath -w $log_file)\",le=\"1\"}" 0
checkMetric "grok_test_histogram_nolabels_bucket{input=\"$(cygpath -w $log_file)\",le=\"2\"}" 1
checkMetric "grok_test_histogram_nolabels_bucket{input=\"$(cygpath -w $log_file)\",le=\"3\"}" 3
checkMetric "grok_test_histogram_nolabels_bucket{input=\"$(cygpath -w $log_file)\",le=\"+Inf\"}" 3
checkMetric "grok_test_histogram_nolabels_sum{input=\"$(cygpath -w $log_file)\"}" 6.5
checkMetric "grok_test_histogram_nolabels_count{input=\"$(cygpath -w $log_file)\"}" 3

checkMetric "grok_test_histogram_labels_bucket{input=\"$(cygpath -w $log_file)\",user=\"alice\",le=\"1\"}" 0
checkMetric "grok_test_histogram_labels_bucket{input=\"$(cygpath -w $log_file)\",user=\"alice\",le=\"2\"}" 1
checkMetric "grok_test_histogram_labels_bucket{input=\"$(cygpath -w $log_file)\",user=\"alice\",le=\"3\"}" 2
checkMetric "grok_test_histogram_labels_bucket{input=\"$(cygpath -w $log_file)\",user=\"alice\",le=\"+Inf\"}" 2
checkMetric "grok_test_histogram_labels_sum{input=\"$(cygpath -w $log_file)\",user=\"alice\"}" 4
checkMetric "grok_test_histogram_labels_count{input=\"$(cygpath -w $log_file)\",user=\"alice\"}" 2

checkMetric "grok_test_histogram_labels_bucket{input=\"$(cygpath -w $log_file)\",user=\"bob\",le=\"1\"}" 0
checkMetric "grok_test_histogram_labels_bucket{input=\"$(cygpath -w $log_file)\",user=\"bob\",le=\"2\"}" 0
checkMetric "grok_test_histogram_labels_bucket{input=\"$(cygpath -w $log_file)\",user=\"bob\",le=\"3\"}" 1
checkMetric "grok_test_histogram_labels_bucket{input=\"$(cygpath -w $log_file)\",user=\"bob\",le=\"+Inf\"}" 1
checkMetric "grok_test_histogram_labels_sum{input=\"$(cygpath -w $log_file)\",user=\"bob\"}" 2.5
checkMetric "grok_test_histogram_labels_count{input=\"$(cygpath -w $log_file)\",user=\"bob\"}" 1

checkMetric "grok_test_summary_nolabels{input=\"$(cygpath -w $log_file)\",quantile=\"0.9\"}" 2.5
checkMetric "grok_test_summary_nolabels_sum{input=\"$(cygpath -w $log_file)\"}" 6.5
checkMetric "grok_test_summary_nolabels_count{input=\"$(cygpath -w $log_file)\"}" 3

checkMetric "grok_test_summary_labels{input=\"$(cygpath -w $log_file)\",user=\"alice\",quantile=\"0.9\"}" 2.5
checkMetric "grok_test_summary_labels_sum{input=\"$(cygpath -w $log_file)\",user=\"alice\"}" 4
checkMetric "grok_test_summary_labels_count{input=\"$(cygpath -w $log_file)\",user=\"alice\"}" 2

checkMetric "grok_test_summary_labels{input=\"$(cygpath -w $log_file)\",user=\"bob\",quantile=\"0.9\"}" 2.5
checkMetric "grok_test_summary_labels_sum{input=\"$(cygpath -w $log_file)\",user=\"bob\"}" 2.5
checkMetric "grok_test_summary_labels_count{input=\"$(cygpath -w $log_file)\",user=\"bob\"}" 1
curl -s http://localhost:9144/metrics

checkMetric "grok_test_counter_nolabels{input=\"$input\"}" 3
checkMetric "grok_test_counter_labels{input=\"$input\",user=\"alice\"}" 2
checkMetric "grok_test_counter_labels{input=\"$input\",user=\"bob\"}" 1

checkMetric "grok_test_gauge_nolabels{input=\"$input\"}" 2.5
checkMetric "grok_test_gauge_labels{input=\"$input\",user=\"alice\"}" 2.5
checkMetric "grok_test_gauge_labels{input=\"$input\",user=\"bob\"}" 2.5

checkMetric "grok_test_histogram_nolabels_bucket{input=\"$input\",le=\"1\"}" 0
checkMetric "grok_test_histogram_nolabels_bucket{input=\"$input\",le=\"2\"}" 1
checkMetric "grok_test_histogram_nolabels_bucket{input=\"$input\",le=\"3\"}" 3
checkMetric "grok_test_histogram_nolabels_bucket{input=\"$input\",le=\"+Inf\"}" 3
checkMetric "grok_test_histogram_nolabels_sum{input=\"$input\"}" 6.5
checkMetric "grok_test_histogram_nolabels_count{input=\"$input\"}" 3

checkMetric "grok_test_histogram_labels_bucket{input=\"$input\",user=\"alice\",le=\"1\"}" 0
checkMetric "grok_test_histogram_labels_bucket{input=\"$input\",user=\"alice\",le=\"2\"}" 1
checkMetric "grok_test_histogram_labels_bucket{input=\"$input\",user=\"alice\",le=\"3\"}" 2
checkMetric "grok_test_histogram_labels_bucket{input=\"$input\",user=\"alice\",le=\"+Inf\"}" 2
checkMetric "grok_test_histogram_labels_sum{input=\"$input\",user=\"alice\"}" 4
checkMetric "grok_test_histogram_labels_count{input=\"$input\",user=\"alice\"}" 2

checkMetric "grok_test_histogram_labels_bucket{input=\"$input\",user=\"bob\",le=\"1\"}" 0
checkMetric "grok_test_histogram_labels_bucket{input=\"$input\",user=\"bob\",le=\"2\"}" 0
checkMetric "grok_test_histogram_labels_bucket{input=\"$input\",user=\"bob\",le=\"3\"}" 1
checkMetric "grok_test_histogram_labels_bucket{input=\"$input\",user=\"bob\",le=\"+Inf\"}" 1
checkMetric "grok_test_histogram_labels_sum{input=\"$input\",user=\"bob\"}" 2.5
checkMetric "grok_test_histogram_labels_count{input=\"$input\",user=\"bob\"}" 1

checkMetric "grok_test_summary_nolabels{input=\"$input\",quantile=\"0.9\"}" 2.5
checkMetric "grok_test_summary_nolabels_sum{input=\"$input\"}" 6.5
checkMetric "grok_test_summary_nolabels_count{input=\"$input\"}" 3

checkMetric "grok_test_summary_labels{input=\"$input\",user=\"alice\",quantile=\"0.9\"}" 2.5
checkMetric "grok_test_summary_labels_sum{input=\"$input\",user=\"alice\"}" 4
checkMetric "grok_test_summary_labels_count{input=\"$input\",user=\"alice\"}" 2

checkMetric "grok_test_summary_labels{input=\"$input\",user=\"bob\",quantile=\"0.9\"}" 2.5
checkMetric "grok_test_summary_labels_sum{input=\"$input\",user=\"bob\"}" 2.5
checkMetric "grok_test_summary_labels_count{input=\"$input\",user=\"bob\"}" 1

# Check built-in metrics (except for processing time and buffer load):

checkMetric "grok_exporter_lines_total{input=\"$(cygpath -w $log_file)\",status=\"ignored\"}" 1
checkMetric "grok_exporter_lines_total{input=\"$(cygpath -w $log_file)\",status=\"matched\"}" 3

checkMetric "grok_exporter_lines_matching_total{input=\"$(cygpath -w $log_file)\",metric=\"grok_test_counter_labels\"}" 3
checkMetric "grok_exporter_lines_matching_total{input=\"$(cygpath -w $log_file)\",metric=\"grok_test_counter_nolabels\"}" 3
checkMetric "grok_exporter_lines_matching_total{input=\"$(cygpath -w $log_file)\",metric=\"grok_test_gauge_labels\"}" 3
checkMetric "grok_exporter_lines_matching_total{input=\"$(cygpath -w $log_file)\",metric=\"grok_test_gauge_nolabels\"}" 3
checkMetric "grok_exporter_lines_matching_total{input=\"$(cygpath -w $log_file)\",metric=\"grok_test_histogram_labels\"}" 3
checkMetric "grok_exporter_lines_matching_total{input=\"$(cygpath -w $log_file)\",metric=\"grok_test_histogram_nolabels\"}" 3
checkMetric "grok_exporter_lines_matching_total{input=\"$(cygpath -w $log_file)\",metric=\"grok_test_summary_labels\"}" 3
checkMetric "grok_exporter_lines_matching_total{input=\"$(cygpath -w $log_file)\",metric=\"grok_test_summary_nolabels\"}" 3

checkMetric "grok_exporter_line_processing_errors_total{input=\"$(cygpath -w $log_file)\",metric=\"grok_test_counter_labels\"}" 0
checkMetric "grok_exporter_line_processing_errors_total{input=\"$(cygpath -w $log_file)\",metric=\"grok_test_counter_nolabels\"}" 0
checkMetric "grok_exporter_line_processing_errors_total{input=\"$(cygpath -w $log_file)\",metric=\"grok_test_gauge_labels\"}" 0
checkMetric "grok_exporter_line_processing_errors_total{input=\"$(cygpath -w $log_file)\",metric=\"grok_test_gauge_nolabels\"}" 0
checkMetric "grok_exporter_line_processing_errors_total{input=\"$(cygpath -w $log_file)\",metric=\"grok_test_histogram_labels\"}" 0
checkMetric "grok_exporter_line_processing_errors_total{input=\"$(cygpath -w $log_file)\",metric=\"grok_test_histogram_nolabels\"}" 0
checkMetric "grok_exporter_line_processing_errors_total{input=\"$(cygpath -w $log_file)\",metric=\"grok_test_summary_labels\"}" 0
checkMetric "grok_exporter_line_processing_errors_total{input=\"$(cygpath -w $log_file)\",metric=\"grok_test_summary_nolabels\"}" 0
checkMetric "grok_exporter_lines_total{input=\"$input\",status=\"ignored\"}" 1
checkMetric "grok_exporter_lines_total{input=\"$input\",status=\"matched\"}" 3

checkMetric "grok_exporter_lines_matching_total{input=\"$input\",metric=\"grok_test_counter_labels\"}" 3
checkMetric "grok_exporter_lines_matching_total{input=\"$input\",metric=\"grok_test_counter_nolabels\"}" 3
checkMetric "grok_exporter_lines_matching_total{input=\"$input\",metric=\"grok_test_gauge_labels\"}" 3
checkMetric "grok_exporter_lines_matching_total{input=\"$input\",metric=\"grok_test_gauge_nolabels\"}" 3
checkMetric "grok_exporter_lines_matching_total{input=\"$input\",metric=\"grok_test_histogram_labels\"}" 3
checkMetric "grok_exporter_lines_matching_total{input=\"$input\",metric=\"grok_test_histogram_nolabels\"}" 3
checkMetric "grok_exporter_lines_matching_total{input=\"$input\",metric=\"grok_test_summary_labels\"}" 3
checkMetric "grok_exporter_lines_matching_total{input=\"$input\",metric=\"grok_test_summary_nolabels\"}" 3

checkMetric "grok_exporter_line_processing_errors_total{input=\"$input\",metric=\"grok_test_counter_labels\"}" 0
checkMetric "grok_exporter_line_processing_errors_total{input=\"$input\",metric=\"grok_test_counter_nolabels\"}" 0
checkMetric "grok_exporter_line_processing_errors_total{input=\"$input\",metric=\"grok_test_gauge_labels\"}" 0
checkMetric "grok_exporter_line_processing_errors_total{input=\"$input\",metric=\"grok_test_gauge_nolabels\"}" 0
checkMetric "grok_exporter_line_processing_errors_total{input=\"$input\",metric=\"grok_test_histogram_labels\"}" 0
checkMetric "grok_exporter_line_processing_errors_total{input=\"$input\",metric=\"grok_test_histogram_nolabels\"}" 0
checkMetric "grok_exporter_line_processing_errors_total{input=\"$input\",metric=\"grok_test_summary_labels\"}" 0
checkMetric "grok_exporter_line_processing_errors_total{input=\"$input\",metric=\"grok_test_summary_nolabels\"}" 0

rm $log_file
echo '30.07.2016 14:45:59 alice 2.5' >> $log_file

sleep 0.1
echo "Checking metrics..."

checkMetric "grok_test_counter_nolabels{input=\"$(cygpath -w $log_file)\"}" 4
checkMetric "grok_test_counter_nolabels{input=\"$input\"}" 4

echo SUCCESS

0 comments on commit cec7c62

Please sign in to comment.