Skip to content

Commit

Permalink
Fix issue in testSourceMetricCommandWithTimestamp integ test with dif…
Browse files Browse the repository at this point in the history
…ferent timezones and locales. (#2522) (#2524)

* Timezon fix



* Timezon fix



---------


(cherry picked from commit fcc4be3)

Signed-off-by: Vamsi Manohar <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 1848d86 commit 429f9c8
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import lombok.SneakyThrows;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -97,10 +98,12 @@ public void testSourceMetricCommand() {
@Test
@SneakyThrows
public void testSourceMetricCommandWithTimestamp() {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// Generate timestamp string for one hour less than the current time
String timestamp = LocalDateTime.now().minusHours(1).format(formatter);
String query =
"source=my_prometheus.prometheus_http_requests_total | where @timestamp > '"
+ format.format(new Date(System.currentTimeMillis() - 3600 * 1000))
+ timestamp
+ "' | sort + @timestamp | head 5";

JSONObject response = executeQuery(query);
Expand Down

0 comments on commit 429f9c8

Please sign in to comment.