Skip to content

Commit

Permalink
fix flaky tests
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolay Ulmasov <[email protected]>
  • Loading branch information
r3stl355 committed Dec 29, 2023
1 parent 73bc9aa commit 2491af8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
15 changes: 14 additions & 1 deletion crates/deltalake-core/tests/command_restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,25 @@ async fn test_restore_by_version() -> Result<(), Box<dyn Error>> {

#[tokio::test]
async fn test_restore_by_datetime() -> Result<(), Box<dyn Error>> {
// use chrono::{Duration};
use std::time::{SystemTime, UNIX_EPOCH};

let context = setup_test().await?;
let mut table = context.table;
let history = table.history(Some(10)).await?;
let timestamp = history.get(1).unwrap().timestamp.unwrap();
let naive = NaiveDateTime::from_timestamp_millis(timestamp).unwrap();
let datetime: DateTime<Utc> = Utc.from_utc_datetime(&naive);
let datetime: DateTime<Utc> = Utc.from_utc_datetime(&naive); // - Duration::hours(1);

let now = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_millis();
if now as i64 <= datetime.timestamp_millis() {
println!("--> Now: {} < history[1].timestamp: {}", now, datetime.timestamp_millis());
}
assert!(now as i64 > datetime.timestamp_millis());


let result = DeltaOps(table)
.restore()
Expand Down
6 changes: 6 additions & 0 deletions python/tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import pathlib
import random
import shutil
import threading
from datetime import date, datetime
from math import inf
Expand Down Expand Up @@ -871,6 +872,11 @@ def test_replace_where_overwrite(
filter_string: str,
):
table_path = tmp_path / sub_path

# Sometimes the path is already there resulting in failed test
if table_path.exists():
shutil.rmtree(table_path)

sample_data = pa.table(
{
"p1": pa.array(["1", "1", "2", "2"], pa.string()),
Expand Down

0 comments on commit 2491af8

Please sign in to comment.