|
1 |
| -#! /bin/bash |
| 1 | +#!/bin/bash |
2 | 2 |
|
3 |
| -# test that logging will parse the message field containing |
4 |
| -# embedded JSON into its component fields, and use the |
5 |
| -# original message field in the embedded JSON |
| 3 | +source "$(dirname "${BASH_SOURCE[0]}" )/../lib/init.sh" |
6 | 4 |
|
7 |
| -if [[ $VERBOSE ]]; then |
8 |
| - set -ex |
9 |
| -else |
10 |
| - set -e |
11 |
| - VERBOSE= |
12 |
| -fi |
13 |
| -set -o nounset |
14 |
| -set -o pipefail |
15 |
| - |
16 |
| -if ! type get_running_pod > /dev/null 2>&1 ; then |
17 |
| - . ${OS_O_A_L_DIR:-../..}/deployer/scripts/util.sh |
18 |
| -fi |
19 |
| - |
20 |
| -ARTIFACT_DIR=${ARTIFACT_DIR:-${TMPDIR:-/tmp}/origin-aggregated-logging} |
21 |
| -if [ ! -d $ARTIFACT_DIR ] ; then |
22 |
| - mkdir -p $ARTIFACT_DIR |
23 |
| -fi |
24 |
| - |
25 |
| -# generate a log message in the Kibana logs - Kibana log messages are in JSON format: |
26 |
| -# {"type":"response","@timestamp":"2017-04-07T02:03:37Z","tags":[],"pid":1,"method":"get","statusCode":404,"req":{"url":"/ca30cead-d470-4db8-a2a2-bb71439987e2","method":"get","headers":{"user-agent":"curl/7.29.0","host":"localhost:5601","accept":"*/*"},"remoteAddress":"127.0.0.1","userAgent":"127.0.0.1"},"res":{"statusCode":404,"responseTime":3,"contentLength":9},"message":"GET /ca30cead-d470-4db8-a2a2-bb71439987e2 404 3ms - 9.0B"} |
27 |
| -# logging should parse this and make "type", "tags", "statusCode", etc. as top level fields |
28 |
| -# the "message" field should contain only the embedded message and not the entire JSON blob |
29 |
| - |
30 |
| -es_pod=`get_running_pod es` |
31 |
| -uuid_es=`uuidgen` |
32 |
| -echo Adding test message $uuid_es to Kibana . . . |
33 |
| -add_test_message $uuid_es |
34 |
| -rc=0 |
35 |
| -timeout=600 |
36 |
| -echo Waiting $timeout seconds for $uuid_es to show up in Elasticsearch . . . |
37 |
| -if espod=$es_pod myproject=project.logging. mymessage=$uuid_es expected=1 \ |
38 |
| - wait_until_cmd_or_err test_count_expected test_count_err $timeout ; then |
39 |
| - echo good - $0: found 1 record project logging for $uuid_es |
40 |
| -else |
41 |
| - echo failed - $0: not found 1 record project logging for $uuid_es after $timeout seconds |
42 |
| - echo "Checking journal for $uuid_es..." |
43 |
| - if journalctl | grep $uuid_es ; then |
44 |
| - echo "Found $uuid_es in journal" |
45 |
| - else |
46 |
| - echo "Unable to find $uuid_es in journal" |
47 |
| - fi |
48 |
| - |
49 |
| - exit 1 |
50 |
| -fi |
51 |
| - |
52 |
| -echo Testing if record is in correct format . . . |
53 |
| -query_es_from_es $es_pod project.logging. _search message $uuid_es | \ |
54 |
| - python test-json-parsing.py $uuid_es |
55 |
| - |
56 |
| -echo Success: $0 passed |
57 |
| -exit 0 |
| 5 | +exec ${OS_O_A_L_DIR}/test/json-parsing.sh |
0 commit comments