@@ -17,7 +17,10 @@ func TestTemplateLog(t *testing.T) {
1717 "flyteexamples-production" ,
1818 "spark-kubernetes-driver" ,
1919 "cri-o://abc" ,
20- "main_logs" )
20+ "main_logs" ,
21+ 1426349294 ,
22+ 1623782877 ,
23+ )
2124 assert .NoError (t , err )
2225 assert .Equal (t , tl .GetName (), "main_logs" )
2326 assert .Equal (t , tl .GetMessageFormat (), core .TaskLog_JSON )
@@ -37,11 +40,13 @@ func Test_templateLogPlugin_Regression(t *testing.T) {
3740 messageFormat core.TaskLog_MessageFormat
3841 }
3942 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
4550 }
4651 tests := []struct {
4752 name string
@@ -57,11 +62,13 @@ func Test_templateLogPlugin_Regression(t *testing.T) {
5762 messageFormat : core .TaskLog_JSON ,
5863 },
5964 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 ,
6572 },
6673 core.TaskLog {
6774 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) {
7784 messageFormat : core .TaskLog_JSON ,
7885 },
7986 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 ,
8594 },
8695 core.TaskLog {
8796 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) {
97106 messageFormat : core .TaskLog_JSON ,
98107 },
99108 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 ,
105116 },
106117 core.TaskLog {
107118 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) {
118129 messageFormat : tt .fields .messageFormat ,
119130 }
120131
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 )
122133 if (err != nil ) != tt .wantErr {
123134 t .Errorf ("GetTaskLog() error = %v, wantErr %v" , err , tt .wantErr )
124135 return
@@ -154,12 +165,14 @@ func TestTemplateLogPlugin_NewTaskLog(t *testing.T) {
154165 },
155166 args {
156167 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 ,
163176 },
164177 },
165178 Output {
@@ -173,6 +186,35 @@ func TestTemplateLogPlugin_NewTaskLog(t *testing.T) {
173186 },
174187 false ,
175188 },
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+ },
176218 }
177219 for _ , tt := range tests {
178220 t .Run (tt .name , func (t * testing.T ) {
0 commit comments