@@ -17,7 +17,10 @@ func TestTemplateLog(t *testing.T) {
17
17
"flyteexamples-production" ,
18
18
"spark-kubernetes-driver" ,
19
19
"cri-o://abc" ,
20
- "main_logs" )
20
+ "main_logs" ,
21
+ 1426349294 ,
22
+ 1623782877 ,
23
+ )
21
24
assert .NoError (t , err )
22
25
assert .Equal (t , tl .GetName (), "main_logs" )
23
26
assert .Equal (t , tl .GetMessageFormat (), core .TaskLog_JSON )
@@ -37,11 +40,13 @@ func Test_templateLogPlugin_Regression(t *testing.T) {
37
40
messageFormat core.TaskLog_MessageFormat
38
41
}
39
42
type args struct {
40
- podName string
41
- namespace string
42
- containerName string
43
- containerID string
44
- logName string
43
+ podName string
44
+ namespace string
45
+ containerName string
46
+ containerID string
47
+ logName string
48
+ podUnixStartTime int64
49
+ podUnixFinishTime int64
45
50
}
46
51
tests := []struct {
47
52
name string
@@ -57,11 +62,13 @@ func Test_templateLogPlugin_Regression(t *testing.T) {
57
62
messageFormat : core .TaskLog_JSON ,
58
63
},
59
64
args {
60
- podName : "f-uuid-driver" ,
61
- namespace : "flyteexamples-production" ,
62
- containerName : "spark-kubernetes-driver" ,
63
- containerID : "cri-o://abc" ,
64
- logName : "main_logs" ,
65
+ podName : "f-uuid-driver" ,
66
+ namespace : "flyteexamples-production" ,
67
+ containerName : "spark-kubernetes-driver" ,
68
+ containerID : "cri-o://abc" ,
69
+ logName : "main_logs" ,
70
+ podUnixStartTime : 123 ,
71
+ podUnixFinishTime : 12345 ,
65
72
},
66
73
core.TaskLog {
67
74
Uri : "https://console.aws.amazon.com/cloudwatch/home?region=us-east-1#logEventViewer:group=/flyte-production/kubernetes;stream=var.log.containers.f-uuid-driver_flyteexamples-production_spark-kubernetes-driver-abc.log" ,
@@ -77,11 +84,13 @@ func Test_templateLogPlugin_Regression(t *testing.T) {
77
84
messageFormat : core .TaskLog_JSON ,
78
85
},
79
86
args {
80
- podName : "podName" ,
81
- namespace : "flyteexamples-production" ,
82
- containerName : "spark-kubernetes-driver" ,
83
- containerID : "cri-o://abc" ,
84
- logName : "main_logs" ,
87
+ podName : "podName" ,
88
+ namespace : "flyteexamples-production" ,
89
+ containerName : "spark-kubernetes-driver" ,
90
+ containerID : "cri-o://abc" ,
91
+ logName : "main_logs" ,
92
+ podUnixStartTime : 123 ,
93
+ podUnixFinishTime : 12345 ,
85
94
},
86
95
core.TaskLog {
87
96
Uri : "https://console.cloud.google.com/logs/viewer?project=test-gcp-project&angularJsUrl=%2Flogs%2Fviewer%3Fproject%3Dtest-gcp-project&resource=aws_ec2_instance&advancedFilter=resource.labels.pod_name%3DpodName" ,
@@ -97,11 +106,13 @@ func Test_templateLogPlugin_Regression(t *testing.T) {
97
106
messageFormat : core .TaskLog_JSON ,
98
107
},
99
108
args {
100
- podName : "flyteexamples-development-task-name" ,
101
- namespace : "flyteexamples-development" ,
102
- containerName : "ignore" ,
103
- containerID : "ignore" ,
104
- logName : "main_logs" ,
109
+ podName : "flyteexamples-development-task-name" ,
110
+ namespace : "flyteexamples-development" ,
111
+ containerName : "ignore" ,
112
+ containerID : "ignore" ,
113
+ logName : "main_logs" ,
114
+ podUnixStartTime : 123 ,
115
+ podUnixFinishTime : 12345 ,
105
116
},
106
117
core.TaskLog {
107
118
Uri : "https://dashboard.k8s.net/#!/log/flyteexamples-development/flyteexamples-development-task-name/pod?namespace=flyteexamples-development" ,
@@ -118,7 +129,7 @@ func Test_templateLogPlugin_Regression(t *testing.T) {
118
129
messageFormat : tt .fields .messageFormat ,
119
130
}
120
131
121
- got , err := s .GetTaskLog (tt .args .podName , tt .args .namespace , tt .args .containerName , tt .args .containerID , tt .args .logName )
132
+ got , err := s .GetTaskLog (tt .args .podName , tt .args .namespace , tt .args .containerName , tt .args .containerID , tt .args .logName , tt . args . podUnixStartTime , tt . args . podUnixFinishTime )
122
133
if (err != nil ) != tt .wantErr {
123
134
t .Errorf ("GetTaskLog() error = %v, wantErr %v" , err , tt .wantErr )
124
135
return
@@ -154,12 +165,14 @@ func TestTemplateLogPlugin_NewTaskLog(t *testing.T) {
154
165
},
155
166
args {
156
167
input : Input {
157
- HostName : "my-host" ,
158
- PodName : "my-pod" ,
159
- Namespace : "my-namespace" ,
160
- ContainerName : "my-container" ,
161
- ContainerID : "ignore" ,
162
- LogName : "main_logs" ,
168
+ HostName : "my-host" ,
169
+ PodName : "my-pod" ,
170
+ Namespace : "my-namespace" ,
171
+ ContainerName : "my-container" ,
172
+ ContainerID : "ignore" ,
173
+ LogName : "main_logs" ,
174
+ PodUnixStartTime : 123 ,
175
+ PodUnixFinishTime : 12345 ,
163
176
},
164
177
},
165
178
Output {
@@ -173,6 +186,35 @@ func TestTemplateLogPlugin_NewTaskLog(t *testing.T) {
173
186
},
174
187
false ,
175
188
},
189
+ {
190
+ "ddog" ,
191
+ fields {
192
+ templateURI : "https://app.datadoghq.com/logs?event&from_ts={{ .podUnixStartTime }}&live=true&query=pod_name%3A{{ .podName }}&to_ts={{ .podUnixFinishTime }}" ,
193
+ messageFormat : core .TaskLog_JSON ,
194
+ },
195
+ args {
196
+ input : Input {
197
+ HostName : "my-host" ,
198
+ PodName : "my-pod" ,
199
+ Namespace : "my-namespace" ,
200
+ ContainerName : "my-container" ,
201
+ ContainerID : "ignore" ,
202
+ LogName : "main_logs" ,
203
+ PodUnixStartTime : 123 ,
204
+ PodUnixFinishTime : 12345 ,
205
+ },
206
+ },
207
+ Output {
208
+ TaskLogs : []* core.TaskLog {
209
+ {
210
+ Uri : "https://app.datadoghq.com/logs?event&from_ts=123&live=true&query=pod_name%3Amy-pod&to_ts=12345" ,
211
+ MessageFormat : core .TaskLog_JSON ,
212
+ Name : "main_logs" ,
213
+ },
214
+ },
215
+ },
216
+ false ,
217
+ },
176
218
}
177
219
for _ , tt := range tests {
178
220
t .Run (tt .name , func (t * testing.T ) {
0 commit comments