fix tests

This commit is contained in:
tamo 2021-05-05 18:03:21 +02:00
parent efca63f9ce
commit 24192fc550
No known key found for this signature in database
GPG Key ID: 20CD8020AFA88D69
6 changed files with 7 additions and 9 deletions

View File

@ -89,7 +89,6 @@ pub fn import_index(size: usize, dump_path: &Path, index_path: &Path) -> anyhow:
// extract `settings.json` file and import content
let settings = import_settings(&dump_path)?;
dbg!(&settings);
let settings: index_controller::Settings = settings.into();
let update_builder = UpdateBuilder::new(0);
index.update_settings(&settings, update_builder)?;

View File

@ -25,7 +25,6 @@ pub fn import_index(size: usize, dump_path: &Path, index_path: &Path) -> anyhow:
let settings = import_settings(&dump_path)?;
let update_builder = UpdateBuilder::new(0);
index.update_settings(&settings, update_builder)?;
dbg!(settings);
let update_builder = UpdateBuilder::new(1);
let file = File::open(&dump_path.join("documents.jsonl"))?;

View File

@ -178,8 +178,8 @@ mod test {
self.as_ref().snapshot(uuid, path).await
}
async fn dump(&self, uuid: Uuid, path: PathBuf) -> IndexResult<()> {
self.as_ref().dump(uuid, path).await
async fn dump(&self, uid: String, uuid: Uuid, path: PathBuf) -> IndexResult<()> {
self.as_ref().dump(uid, uuid, path).await
}
async fn get_index_stats(&self, uuid: Uuid) -> IndexResult<IndexStats> {

View File

@ -241,7 +241,7 @@ where
tokio::task::spawn_blocking(move || -> anyhow::Result<()> {
update_store.dump(&uuids, path.to_path_buf())?;
// Perform the snapshot of each index concurently. Only a third of the capabilities of
// Perform the dump of each index concurently. Only a third of the capabilities of
// the index actor at a time not to put too much pressure on the index actor
let path = &path;
let handle = &index_handle;

View File

@ -11,6 +11,7 @@ use arc_swap::ArcSwap;
use heed::types::{ByteSlice, OwnedType, SerdeJson};
use heed::zerocopy::U64;
use heed::{BytesDecode, BytesEncode, CompactionOption, Database, Env, EnvOpenOptions};
use log::error;
use parking_lot::{Mutex, MutexGuard};
use tokio::runtime::Handle;
use tokio::sync::mpsc;
@ -77,6 +78,7 @@ pub enum State {
Idle,
Processing(Uuid, Processing),
Snapshoting,
Dumping,
}
impl<'a> BytesEncode<'a> for NextIdCodec {
@ -227,7 +229,7 @@ impl UpdateStore {
match res {
Ok(Some(_)) => (),
Ok(None) => break,
Err(e) => eprintln!("error while processing update: {}", e),
Err(e) => error!("error while processing update: {}", e),
}
}
// the ownership on the arc has been taken, we need to exit.
@ -520,7 +522,7 @@ impl UpdateStore {
pub fn dump(&self, uuids: &HashSet<(String, Uuid)>, path: PathBuf) -> anyhow::Result<()> {
use std::io::prelude::*;
let state_lock = self.state.write();
state_lock.swap(State::Snapshoting); // TODO: TAMO rename the state somehow
state_lock.swap(State::Dumping);
let txn = self.env.write_txn()?;

View File

@ -82,9 +82,7 @@ async fn reset_all_settings() {
assert_eq!(response["searchableAttributes"], json!(["bar"]));
assert_eq!(response["stopWords"], json!(["the"]));
eprintln!("BEFORE");
index.delete_settings().await;
eprintln!("AFTER");
index.wait_update_id(1).await;
let (response, code) = index.settings().await;