Skip to content

Commit f33184c

Browse files
committed
WIP - working through other component changes, rebased from main
1 parent e390ef0 commit f33184c

File tree

13 files changed

+55
-66
lines changed

13 files changed

+55
-66
lines changed

components/nimbus/android/src/test/java/org/mozilla/experiments/nimbus/NimbusBuilderTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package org.mozilla.experiments.nimbus
77
import android.content.Context
88
import androidx.test.core.app.ApplicationProvider
99
import kotlinx.coroutines.Job
10-
import mozilla.appservices.remotesettings.RemoteSettingsConfig2
10+
import mozilla.appservices.remotesettings.RemoteSettingsConfig
1111
import mozilla.appservices.remotesettings.RemoteSettingsService
1212
import org.junit.Assert.assertEquals
1313
import org.junit.Assert.assertFalse
@@ -34,7 +34,7 @@ class NimbusBuilderTest {
3434
}.build(
3535
appInfo,
3636
NimbusServerSettings(
37-
remoteSettingsService = RemoteSettingsService(storageDir = "dummy", config = RemoteSettingsConfig2()),
37+
remoteSettingsService = RemoteSettingsService(storageDir = "dummy", config = RemoteSettingsConfig()),
3838
collection = "nimbus-preview",
3939
),
4040
) as DummyNimbus

components/nimbus/tests/common/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44
#![cfg(feature = "rkv-safe-mode")]
55

6-
use remote_settings::{RemoteSettingsConfig2, RemoteSettingsContext, RemoteSettingsService};
6+
use remote_settings::{RemoteSettingsConfig, RemoteSettingsContext, RemoteSettingsService};
77
use rkv::StoreOptions;
88

99
// utilities shared between tests
@@ -78,7 +78,7 @@ fn new_test_client_internal(
7878
..Default::default()
7979
};
8080

81-
let config = RemoteSettingsConfig2 {
81+
let config = RemoteSettingsConfig {
8282
server: Some(RemoteSettingsServer::Custom {
8383
url: url.as_str().to_string(),
8484
}),

components/nimbus/tests/test_fs_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use std::sync::Arc;
99

1010
use nimbus::error::Result;
11-
use remote_settings::{RemoteSettingsConfig2, RemoteSettingsContext, RemoteSettingsService};
11+
use remote_settings::{RemoteSettingsConfig, RemoteSettingsContext, RemoteSettingsService};
1212

1313
mod common;
1414

@@ -28,7 +28,7 @@ fn test_simple() -> Result<()> {
2828

2929
let url = Url::from_file_path(dir).expect("experiments dir should exist");
3030

31-
let config = RemoteSettingsConfig2 {
31+
let config = RemoteSettingsConfig {
3232
server: Some(RemoteSettingsServer::Custom {
3333
url: url.as_str().to_string(),
3434
}),

components/relay/src/rs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,11 @@ impl RelayRemoteSettingsClient {
298298
#[cfg(test)]
299299
mod tests {
300300
use super::*;
301-
use remote_settings::{RemoteSettingsConfig2, RemoteSettingsServer};
301+
use remote_settings::{RemoteSettingsConfig, RemoteSettingsServer};
302302

303303
// Helper to create a RemoteSettingsService for testing
304304
fn create_test_remote_settings_service() -> Arc<RemoteSettingsService> {
305-
let config = RemoteSettingsConfig2 {
305+
let config = RemoteSettingsConfig {
306306
server: Some(RemoteSettingsServer::Custom {
307307
url: "http://localhost".to_string(),
308308
}),

components/search/src/selector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ mod tests {
161161
use crate::test_helpers::{EngineRecord, ExpectedEngine, SubVariant, Variant};
162162
use crate::{test_helpers, types::*, SearchApiError};
163163
use mockito::mock;
164-
use remote_settings::{RemoteSettingsConfig2, RemoteSettingsContext, RemoteSettingsServer};
164+
use remote_settings::{RemoteSettingsConfig, RemoteSettingsContext, RemoteSettingsServer};
165165
use serde_json::json;
166166

167167
#[test]
@@ -870,7 +870,7 @@ mod tests {
870870
error_support::init_for_tests();
871871
viaduct_dev::init_backend_dev();
872872

873-
let config = RemoteSettingsConfig2 {
873+
let config = RemoteSettingsConfig {
874874
server: Some(RemoteSettingsServer::Custom {
875875
url: mockito::server_url(),
876876
}),

components/suggest/src/benchmarks/client.rs

Lines changed: 30 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use std::collections::HashMap;
66

77
use crate::{error::Error, rs, Result};
88

9+
use remote_settings::{RemoteSettingsConfig, RemoteSettingsContext, RemoteSettingsService};
10+
911
/// Remotes settings client for benchmarking
1012
///
1113
/// This fetches all data in `new`, then implements [rs::Client] by returning the local data.
@@ -20,55 +22,39 @@ pub struct RemoteSettingsBenchmarkClient {
2022
impl RemoteSettingsBenchmarkClient {
2123
pub fn new() -> Result<Self> {
2224
let mut new_benchmark_client = Self::default();
23-
new_benchmark_client.fetch_data_with_client(
24-
remote_settings::RemoteSettings::new(remote_settings::RemoteSettingsConfig {
25-
server: None,
26-
bucket_name: None,
27-
collection_name: rs::Collection::Amp.name().to_owned(),
28-
server_url: None,
29-
})?,
30-
rs::Collection::Amp,
31-
)?;
32-
new_benchmark_client.fetch_data_with_client(
33-
remote_settings::RemoteSettings::new(remote_settings::RemoteSettingsConfig {
34-
server: None,
35-
bucket_name: None,
36-
collection_name: rs::Collection::Other.name().to_owned(),
37-
server_url: None,
38-
})?,
39-
rs::Collection::Other,
40-
)?;
41-
new_benchmark_client.fetch_data_with_client(
42-
remote_settings::RemoteSettings::new(remote_settings::RemoteSettingsConfig {
43-
server: None,
44-
bucket_name: None,
45-
collection_name: rs::Collection::Fakespot.name().to_owned(),
46-
server_url: None,
47-
})?,
48-
rs::Collection::Fakespot,
49-
)?;
25+
new_benchmark_client.fetch_data(rs::Collection::Amp)?;
26+
new_benchmark_client.fetch_data(rs::Collection::Other)?;
27+
new_benchmark_client.fetch_data(rs::Collection::Fakespot)?;
5028
Ok(new_benchmark_client)
5129
}
5230

53-
fn fetch_data_with_client(
54-
&mut self,
55-
client: remote_settings::RemoteSettings,
56-
collection: rs::Collection,
57-
) -> Result<()> {
58-
let response = client.get_records()?;
59-
for r in &response.records {
60-
if let Some(a) = &r.attachment {
61-
self.attachments
62-
.insert(a.location.clone(), client.get_attachment(&a.location)?);
31+
fn fetch_data(&mut self, collection: rs::Collection) -> Result<()> {
32+
let service = RemoteSettingsService::new(
33+
String::from(":memory:"),
34+
RemoteSettingsConfig {
35+
server: None,
36+
bucket_name: None,
37+
app_context: Some(RemoteSettingsContext::default()),
38+
},
39+
);
40+
let client = service.make_client(collection.name().to_string());
41+
let records = client.get_records(true);
42+
if let Some(records) = records {
43+
for r in &records {
44+
if let Some(a) = &r.attachment {
45+
self.attachments
46+
.insert(a.location.clone(), client.get_attachment(r)?);
47+
}
6348
}
49+
self.records.extend(
50+
records
51+
.into_iter()
52+
.filter_map(|r| rs::Record::new(r, collection).ok()),
53+
);
54+
Ok(())
55+
} else {
56+
Err(Error::MissingRecords)
6457
}
65-
self.records.extend(
66-
response
67-
.records
68-
.into_iter()
69-
.filter_map(|r| rs::Record::new(r, collection).ok()),
70-
);
71-
Ok(())
7258
}
7359

7460
pub fn attachment_size_by_record_type(&self) -> Vec<(rs::SuggestRecordType, usize)> {

components/suggest/src/benchmarks/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use std::{
2020
use tempfile::TempDir;
2121

2222
use crate::{SuggestIngestionConstraints, SuggestStore};
23-
use remote_settings::{RemoteSettingsConfig2, RemoteSettingsContext, RemoteSettingsService};
23+
use remote_settings::{RemoteSettingsConfig, RemoteSettingsContext, RemoteSettingsService};
2424

2525
use std::sync::Arc;
2626

@@ -88,7 +88,7 @@ fn new_store() -> SuggestStore {
8888
let temp_dir = tempfile::tempdir().unwrap();
8989
let db_path = temp_dir.path().join(unique_db_filename());
9090
let remote_settings_dir = temp_dir.path().join(unique_remote_settings_dir());
91-
let rs_config = RemoteSettingsConfig2 {
91+
let rs_config = RemoteSettingsConfig {
9292
bucket_name: None,
9393
server: None,
9494
app_context: Some(RemoteSettingsContext::default()),
@@ -106,7 +106,7 @@ fn new_store() -> SuggestStore {
106106
});
107107

108108
let db_path = starter_dir.path().join(unique_db_filename());
109-
let rs_config = RemoteSettingsConfig2 {
109+
let rs_config = RemoteSettingsConfig {
110110
bucket_name: None,
111111
server: None,
112112
app_context: Some(RemoteSettingsContext::default()),

components/suggest/src/error.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ pub enum Error {
2626
#[error("Error from Remote Settings: {0}")]
2727
RemoteSettings(#[from] RemoteSettingsError),
2828

29+
#[error("Remote settings has no records for this collection")]
30+
MissingRecords,
31+
2932
#[error("Remote settings record is missing an attachment (id: u64)")]
3033
MissingAttachment(String),
3134

components/support/nimbus-cli/src/sources/experiment_list.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl TryFrom<&ExperimentListSource> for Value {
220220
is_preview,
221221
} => {
222222
use remote_settings::{
223-
RemoteSettingsConfig2, RemoteSettingsServer, RemoteSettingsService,
223+
RemoteSettingsConfig, RemoteSettingsServer, RemoteSettingsService,
224224
};
225225
let collection_name = if *is_preview {
226226
"nimbus-preview".to_string()
@@ -241,7 +241,7 @@ impl TryFrom<&ExperimentListSource> for Value {
241241
let server = RemoteSettingsServer::Custom {
242242
url: endpoint.clone(),
243243
};
244-
let config = RemoteSettingsConfig2 {
244+
let config = RemoteSettingsConfig {
245245
server: Some(server),
246246
..Default::default()
247247
};

examples/cli-support/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::{
1010
sync::Arc,
1111
};
1212

13-
use remote_settings::{RemoteSettingsConfig2, RemoteSettingsServer, RemoteSettingsService};
13+
use remote_settings::{RemoteSettingsConfig, RemoteSettingsServer, RemoteSettingsService};
1414

1515
pub mod fxa_creds;
1616
pub mod prompt;

0 commit comments

Comments
 (0)