X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=blobdiff_plain;f=t%2Funit%2Ffrontend%2Fquery_test.c;fp=t%2Funit%2Ffrontend%2Fquery_test.c;h=7640511b692f7bfaa68f5a627066d7b5afa0bf90;hp=e36c302422089adbe740b9ecd2cdd5710bcda03a;hb=026ce2bb377f4055e3a0a1d20a2f91e5a73a49b0;hpb=5a53faeea89f0a24b113f6c273734808fdfccf31 diff --git a/t/unit/frontend/query_test.c b/t/unit/frontend/query_test.c index e36c302..7640511 100644 --- a/t/unit/frontend/query_test.c +++ b/t/unit/frontend/query_test.c @@ -124,7 +124,38 @@ turndown(void) "{\"name\": \"hostname\", \"value\": \"h1\", " \ "\"last_update\": \"1970-01-01 00:00:01 +0000\", " \ "\"update_interval\": \"0s\", \"backends\": []}]}]}" +#define HOST_H2 \ + "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:03 +0000\", " \ + "\"update_interval\": \"0s\", \"backends\": [], " \ + "\"metrics\": [" \ + "{\"name\": \"m1\", \"timeseries\": false, " \ + "\"last_update\": \"1970-01-01 00:00:01 +0000\", " \ + "\"update_interval\": \"0s\", \"backends\": [], " \ + "\"attributes\": [" \ + "{\"name\": \"hostname\", \"value\": \"h2\", " \ + "\"last_update\": \"1970-01-01 00:00:01 +0000\", " \ + "\"update_interval\": \"0s\", \"backends\": []}]}], " \ + "\"services\": [" \ + "{\"name\": \"s1\", \"last_update\": \"1970-01-01 00:00:01 +0000\", " \ + "\"update_interval\": \"0s\", \"backends\": [], " \ + "\"attributes\": [" \ + "{\"name\": \"hostname\", \"value\": \"h2\", " \ + "\"last_update\": \"1970-01-01 00:00:01 +0000\", " \ + "\"update_interval\": \"0s\", \"backends\": []}]}," \ + "{\"name\": \"s2\", \"last_update\": \"1970-01-01 00:00:02 +0000\", " \ + "\"update_interval\": \"0s\", \"backends\": [], " \ + "\"attributes\": [" \ + "{\"name\": \"hostname\", \"value\": \"h2\", " \ + "\"last_update\": \"1970-01-01 00:00:02 +0000\", " \ + "\"update_interval\": \"0s\", \"backends\": []}," \ + "{\"name\": \"k1\", \"value\": 123, " \ + "\"last_update\": \"1970-01-01 00:00:02 +0000\", " \ + "\"update_interval\": \"0s\", \"backends\": []}," \ + "{\"name\": \"k2\", \"value\": 4711, " \ + "\"last_update\": \"1970-01-01 00:00:01 +0000\", " \ + "\"update_interval\": \"0s\", \"backends\": []}]}]}" #define HOST_H1_ARRAY "["HOST_H1"]" +#define HOST_H12_ARRAY "["HOST_H1","HOST_H2"]" #define HOST_H1_LISTING \ "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:01 +0000\", " \ "\"update_interval\": \"0s\", \"backends\": []}" @@ -371,6 +402,14 @@ static struct { SDB_CONNECTION_QUERY, "LOOKUP hosts MATCHING name = 'h1' FILTER age >= 0s", -1, /* always matches */ 0, SDB_CONNECTION_DATA, 1112, SDB_CONNECTION_LOOKUP, HOST_H1_ARRAY, }, + { + SDB_CONNECTION_QUERY, "LOOKUP hosts MATCHING ANY backend = 'b'", -1, + 0, SDB_CONNECTION_DATA, 6, SDB_CONNECTION_LOOKUP, "[]", + }, + { + SDB_CONNECTION_QUERY, "LOOKUP hosts MATCHING ANY backend || 'b' = 'b'", -1, + 0, SDB_CONNECTION_DATA, 2205, SDB_CONNECTION_LOOKUP, HOST_H12_ARRAY, + }, { SDB_CONNECTION_QUERY, "FETCH host 'h1' FILTER age < 0s", -1, /* never matches */ -1, UINT32_MAX, 0, 0, NULL, /* FETCH fails if the object doesn't exist */