@@ -2,47 +2,28 @@ load "$LIB_BATS_ASSERT/load.bash"
2
2
load " $LIB_BATS_SUPPORT /load.bash"
3
3
4
4
@test " steampipe cache functionality check ON" {
5
- skip " TODO - test using steampipe query command"
6
5
run steampipe plugin install chaos
7
- cd $FUNCTIONALITY_TEST_MOD
8
6
9
- run steampipe check benchmark.check_cache_benchmark --export test.json --max-parallel 1
7
+ # start service to turn on caching
8
+ steampipe service start
10
9
11
- # store the unique number from 1st control in `content`
12
- content=$( cat test.json | jq ' .groups[].controls[0].results[0].resource' )
13
- # store the unique number from 2nd control in `new_content`
14
- new_content=$( cat test.json | jq ' .groups[].controls[1].results[0].resource' )
15
- echo $content
16
- echo $new_content
10
+ # run two queries to check if the results are the same
11
+ run steampipe query " select unique_col from chaos_cache_check limit 1" --output json > output1.json
12
+ run steampipe query " select unique_col from chaos_cache_check limit 1" --output json > output2.json
17
13
18
- # verify that `content` and `new_content` are the same
19
- assert_equal " $new_content " " $content "
20
- rm -f test.json
21
- }
14
+ # stop service
15
+ steampipe service stop
22
16
23
- @test " steampipe cache functionality check OFF" {
24
- skip " TODO - test using steampipe query command"
25
- cd $FUNCTIONALITY_TEST_MOD
26
-
27
- # set the env variable to false
28
- export STEAMPIPE_CACHE=false
29
- run steampipe check benchmark.check_cache_benchmark --export test.json --max-parallel 1
30
-
31
- # store the unique number from 1st control in `content`
32
- content=$( cat test.json | jq ' .groups[].controls[0].results[0].resource' )
33
- # store the unique number from 2nd control in `new_content`
34
- new_content=$( cat test.json | jq ' .groups[].controls[1].results[0].resource' )
35
- echo $content
36
- echo $new_content
37
-
38
- # verify that `content` and `new_content` are not the same
39
- if [[ " $content " == " $new_content " ]]; then
40
- flag=1
41
- else
42
- flag=0
43
- fi
44
- assert_equal " $flag " " 0"
45
- rm -f test.json
17
+ unique1=$( cat output1.json | jq ' .rows[0].unique_col' )
18
+ unique2=$( cat output2.json | jq ' .rows[0].unique_col' )
19
+
20
+ echo $unique1
21
+ echo $unique2
22
+
23
+ assert_equal " $unique1 " " $unique2 "
24
+
25
+ rm -f output1.json
26
+ rm -f output2.json
46
27
}
47
28
48
29
@test " steampipe cache functionality check ON(check content of results, not just the unique column)" {
@@ -103,41 +84,6 @@ load "$LIB_BATS_SUPPORT/load.bash"
103
84
assert_not_equal " $unique1 " " $unique3 "
104
85
}
105
86
106
- @test " verify cache ttl works when set in connections options" {
107
- skip " skipping - this is a deprecated functionality"
108
-
109
- cp $SRC_DATA_DIR /chaos_ttl_options.spc $STEAMPIPE_INSTALL_DIR /config/chaos_ttl_options.spc
110
-
111
- # start the service
112
- steampipe service start
113
-
114
- # cache functionality check since cache=true in options
115
- steampipe query " select unique_col from chaos_ttl_options.chaos_cache_check where id=2" --output json > out1.json
116
- steampipe query " select unique_col from chaos_ttl_options.chaos_cache_check where id=2" --output json > out2.json
117
-
118
- # wait for 15 seconds - the value of the TTL in connection options
119
- sleep 15
120
-
121
- # run the query again
122
- steampipe query " select unique_col from chaos_ttl_options.chaos_cache_check where id=2" --output json > out3.json
123
-
124
- # stop the service
125
- steampipe service stop
126
-
127
- unique1=$( cat out1.json | jq ' .[].unique_col' )
128
- unique2=$( cat out2.json | jq ' .[].unique_col' )
129
- unique3=$( cat out3.json | jq ' .[].unique_col' )
130
-
131
- # remove the output and the config files
132
- rm -f out* .json
133
- rm -f $STEAMPIPE_INSTALL_DIR /config/chaos_ttl_options.spc
134
-
135
- # the first and the seconds query should have the same value
136
- assert_equal " $unique1 " " $unique2 "
137
- # the third query should have a different value
138
- assert_not_equal " $unique1 " " $unique3 "
139
- }
140
-
141
87
@test " verify cache ttl works when set in database options" {
142
88
skip " TODO - fix and test using steampipe query command"
143
89
export STEAMPIPE_LOG=info
0 commit comments