@@ -63,9 +63,11 @@ func deepCopy(source map[string]string) map[string]string {
6363func testTranslateMetric (as * assert.Assertions , value int64 , name string , labels map [string ]string , expectedName string ) * sd_api.TypedValue {
6464 metricValue := generateIntMetric (value )
6565 timestamp := time .Now ()
66+ createTime := timestamp .Add (- time .Second )
6667
67- ts := sink .TranslateMetric (timestamp , labels , name , metricValue , timestamp )
68+ ts := sink .TranslateMetric (timestamp , labels , name , metricValue , createTime )
6869
70+ as .NotNil (ts )
6971 as .Equal (ts .Metric .Type , expectedName )
7072 as .Equal (len (ts .Points ), 1 )
7173 return ts .Points [0 ].Value
@@ -132,8 +134,9 @@ func TestTranslateMemoryMajorPageFaults(t *testing.T) {
132134 metricValue := generateIntMetric (20 )
133135 name := "memory/major_page_faults"
134136 timestamp := time .Now ()
137+ createTime := timestamp .Add (- time .Second )
135138
136- ts := sink .TranslateMetric (timestamp , commonLabels , name , metricValue , timestamp )
139+ ts := sink .TranslateMetric (timestamp , commonLabels , name , metricValue , createTime )
137140
138141 as := assert .New (t )
139142 as .Equal (ts .Metric .Type , "container.googleapis.com/container/memory/page_fault_count" )
@@ -146,8 +149,9 @@ func TestTranslateMemoryMinorPageFaults(t *testing.T) {
146149 metricValue := generateIntMetric (42 )
147150 name := "memory/minor_page_faults"
148151 timestamp := time .Now ()
152+ createTime := timestamp .Add (- time .Second )
149153
150- ts := sink .TranslateMetric (timestamp , commonLabels , name , metricValue , timestamp )
154+ ts := sink .TranslateMetric (timestamp , commonLabels , name , metricValue , createTime )
151155
152156 as := assert .New (t )
153157 as .Equal (ts .Metric .Type , "container.googleapis.com/container/memory/page_fault_count" )
@@ -175,8 +179,9 @@ func TestTranslateFilesystemUsage(t *testing.T) {
175179 Name : "filesystem/usage" ,
176180 }
177181 timestamp := time .Now ()
182+ createTime := timestamp .Add (- time .Second )
178183
179- ts := sink .TranslateLabeledMetric (timestamp , commonLabels , metric , timestamp )
184+ ts := sink .TranslateLabeledMetric (timestamp , commonLabels , metric , createTime )
180185
181186 as := assert .New (t )
182187 as .Equal (ts .Metric .Type , "container.googleapis.com/container/disk/bytes_used" )
@@ -193,8 +198,9 @@ func TestTranslateFilesystemLimit(t *testing.T) {
193198 Name : "filesystem/limit" ,
194199 }
195200 timestamp := time .Now ()
201+ createTime := timestamp .Add (- time .Second )
196202
197- ts := sink .TranslateLabeledMetric (timestamp , commonLabels , metric , timestamp )
203+ ts := sink .TranslateLabeledMetric (timestamp , commonLabels , metric , createTime )
198204
199205 as := assert .New (t )
200206 as .Equal (ts .Metric .Type , "container.googleapis.com/container/disk/bytes_total" )
0 commit comments