Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue in testSourceMetricCommandWithTimestamp integ test with different timezones and locales. #2522

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading