9
9
import pytablewriter
10
10
from pytablewriter import MarkdownTableWriter
11
11
12
- # 7 days expire
13
- STALL_INFO_DAYS = 7
12
+ # 30 days expire
13
+ STALL_INFO_DAYS = 30
14
14
EXPIRE_TIME_SECS_PROFILE_KEYS = 60 * 60 * 24 * STALL_INFO_DAYS
15
15
EXPIRE_TIME_MSECS_PROFILE_KEYS = EXPIRE_TIME_SECS_PROFILE_KEYS * 1000
16
16
@@ -65,33 +65,21 @@ def generate_artifacts_table_grafana_redis(
65
65
profile_markdown_str = profile_markdown_str .replace ("\n " , "" )
66
66
profile_id = "{}_{}_hash_{}" .format (start_time_str , setup_name , tf_github_sha )
67
67
profile_string_testcase_markdown_key = "profile:{}:{}" .format (profile_id , test_name )
68
- zset_profiles = "profiles:{}_{}_{}" .format (
69
- tf_github_org , tf_github_repo , setup_name
70
- )
71
- zset_profiles_setup = "profiles:setups:{}_{}" .format (
72
- tf_github_org ,
73
- tf_github_repo ,
74
- )
75
- profile_set_redis_key = "profile:{}:testcases" .format (profile_id )
76
- zset_profiles_setups_testcases = "profiles:testcases:{}_{}_{}" .format (
77
- tf_github_org ,
78
- tf_github_repo ,
79
- setup_name ,
80
- )
81
- zset_profiles_setups_testcases_profileid = "profiles:ids:{}_{}_{}_{}_{}" .format (
82
- tf_github_org ,
83
- tf_github_repo ,
68
+ (
69
+ profile_set_redis_key ,
70
+ zset_profiles ,
71
+ zset_profiles_setup ,
72
+ zset_profiles_setups_testcases ,
73
+ zset_profiles_setups_testcases_branches ,
74
+ zset_profiles_setups_testcases_branches_latest_link ,
75
+ zset_profiles_setups_testcases_profileid ,
76
+ ) = get_profile_zset_names (
77
+ profile_id ,
84
78
setup_name ,
85
79
test_name ,
86
80
tf_github_branch ,
87
- )
88
- zset_profiles_setups_testcases_branches = "profiles:branches:{}_{}_{}_{}" .format (
89
- tf_github_org , tf_github_repo , setup_name , test_name
90
- )
91
- zset_profiles_setups_testcases_branches_latest_link = (
92
- "latest_profiles:by.branch:{}_{}_{}_{}" .format (
93
- tf_github_org , tf_github_repo , setup_name , test_name
94
- )
81
+ tf_github_org ,
82
+ tf_github_repo ,
95
83
)
96
84
https_link = "{}?var-org={}&var-repo={}&var-setup={}&var-branch={}" .format (
97
85
grafana_profile_dashboard ,
@@ -103,13 +91,31 @@ def generate_artifacts_table_grafana_redis(
103
91
test_name ,
104
92
profile_id ,
105
93
)
106
- if push_results_redistimeseries :
94
+ if push_results_redistimeseries is True :
95
+ sorted_set_keys = [
96
+ zset_profiles ,
97
+ zset_profiles_setups_testcases_profileid ,
98
+ zset_profiles_setups_testcases ,
99
+ zset_profiles_setup ,
100
+ zset_profiles_setups_testcases_branches_latest_link ,
101
+ ]
102
+ logging .info (
103
+ "Propulating the profile helper ZSETs: {}" .format (" " .join (sorted_set_keys ))
104
+ )
107
105
current_time = time .time () * 1000
108
106
timeframe_by_branch = current_time - EXPIRE_TIME_MSECS_PROFILE_KEYS
109
- redis_conn .zadd (
107
+ res = redis_conn .zadd (
110
108
zset_profiles_setups_testcases_branches ,
111
109
{tf_github_branch : start_time_ms },
112
110
)
111
+ logging .info (
112
+ "Result of ZADD {} {} {} = {}" .format (
113
+ zset_profiles_setups_testcases_branches ,
114
+ start_time_ms ,
115
+ tf_github_branch ,
116
+ res ,
117
+ )
118
+ )
113
119
redis_conn .zadd (
114
120
zset_profiles_setups_testcases_branches_latest_link ,
115
121
{https_link : start_time_ms },
@@ -130,14 +136,13 @@ def generate_artifacts_table_grafana_redis(
130
136
zset_profiles ,
131
137
{profile_id : start_time_ms },
132
138
)
133
- sorted_set_keys = [
134
- zset_profiles ,
135
- zset_profiles_setups_testcases_profileid ,
136
- zset_profiles_setups_testcases ,
137
- zset_profiles_setup ,
138
- zset_profiles_setups_testcases_branches_latest_link ,
139
- ]
139
+
140
140
for keyname in sorted_set_keys :
141
+ logging .info (
142
+ "Expiring all elements with score between 0 and {}" .format (
143
+ int (timeframe_by_branch )
144
+ )
145
+ )
141
146
redis_conn .zremrangebyscore (keyname , 0 , int (timeframe_by_branch ))
142
147
143
148
redis_conn .sadd (profile_set_redis_key , test_name )
@@ -153,3 +158,45 @@ def generate_artifacts_table_grafana_redis(
153
158
)
154
159
)
155
160
return https_link
161
+
162
+
163
+ def get_profile_zset_names (
164
+ profile_id , setup_name , test_name , tf_github_branch , tf_github_org , tf_github_repo
165
+ ):
166
+ profile_set_redis_key = "profile:{}:testcases" .format (profile_id )
167
+ zset_profiles = "profiles:{}_{}_{}" .format (
168
+ tf_github_org , tf_github_repo , setup_name
169
+ )
170
+ zset_profiles_setup = "profiles:setups:{}_{}" .format (
171
+ tf_github_org ,
172
+ tf_github_repo ,
173
+ )
174
+ zset_profiles_setups_testcases = "profiles:testcases:{}_{}_{}" .format (
175
+ tf_github_org ,
176
+ tf_github_repo ,
177
+ setup_name ,
178
+ )
179
+ zset_profiles_setups_testcases_profileid = "profiles:ids:{}_{}_{}_{}_{}" .format (
180
+ tf_github_org ,
181
+ tf_github_repo ,
182
+ setup_name ,
183
+ test_name ,
184
+ tf_github_branch ,
185
+ )
186
+ zset_profiles_setups_testcases_branches = "profiles:branches:{}_{}_{}_{}" .format (
187
+ tf_github_org , tf_github_repo , setup_name , test_name
188
+ )
189
+ zset_profiles_setups_testcases_branches_latest_link = (
190
+ "latest_profiles:by.branch:{}_{}_{}_{}" .format (
191
+ tf_github_org , tf_github_repo , setup_name , test_name
192
+ )
193
+ )
194
+ return (
195
+ profile_set_redis_key ,
196
+ zset_profiles ,
197
+ zset_profiles_setup ,
198
+ zset_profiles_setups_testcases ,
199
+ zset_profiles_setups_testcases_branches ,
200
+ zset_profiles_setups_testcases_branches_latest_link ,
201
+ zset_profiles_setups_testcases_profileid ,
202
+ )
0 commit comments