Merge "aconfig: update flag info storage file" into main am: 67e44dd2c3 am: e92999e8d6

Original change: https://android-review.googlesource.com/c/platform/build/+/3046897

Change-Id: I8d1f8c06bc5310444e969a6d8cc70e569b6c312f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Dennis Shen 2024-04-23 18:41:37 +00:00 committed by Automerger Merge Worker
commit c6e2c70cea
12 changed files with 116 additions and 113 deletions

View file

@ -91,9 +91,9 @@ impl FlagInfoHeader {
/// bit field for flag info
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum FlagInfoBit {
IsSticky = 1 << 0,
HasServerOverride = 1 << 0,
IsReadWrite = 1 << 1,
HasOverride = 1 << 2,
HasLocalOverride = 1 << 2,
}
/// Flag info node struct
@ -107,10 +107,10 @@ impl fmt::Debug for FlagInfoNode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln!(
f,
"sticky: {}, readwrite: {}, override: {}",
self.attributes & (FlagInfoBit::IsSticky as u8) != 0,
"readwrite: {}, server override: {}, local override: {}",
self.attributes & (FlagInfoBit::IsReadWrite as u8) != 0,
self.attributes & (FlagInfoBit::HasOverride as u8) != 0,
self.attributes & (FlagInfoBit::HasServerOverride as u8) != 0,
self.attributes & (FlagInfoBit::HasLocalOverride as u8) != 0,
)?;
Ok(())
}

View file

@ -32,9 +32,9 @@ enum FlagValueType {
/// Flag info enum, to be consistent with the one defined in
/// aconfig_storage_file/src/flag_info.rs
enum FlagInfoBit {
IsSticky = 1<<0,
HasServerOverride = 1<<0,
IsReadWrite = 1<<1,
HasOverride = 1<<2,
HasLocalOverride = 1<<2,
};
/// Mapped storage file

View file

@ -56,13 +56,13 @@ mod tests {
use aconfig_storage_file::{test_utils::create_test_flag_info_list, FlagInfoBit};
#[test]
// this test point locks down query if flag is sticky
// this test point locks down query if flag has server override
fn test_is_flag_sticky() {
let flag_info_list = create_test_flag_info_list().into_bytes();
for offset in 0..8 {
let attribute =
find_flag_attribute(&flag_info_list[..], FlagValueType::Boolean, offset).unwrap();
assert_eq!((attribute & FlagInfoBit::IsSticky as u8) != 0u8, false);
assert_eq!((attribute & FlagInfoBit::HasServerOverride as u8) != 0u8, false);
}
}
@ -82,13 +82,13 @@ mod tests {
}
#[test]
// this test point locks down query if flag has override
// this test point locks down query if flag has local override
fn test_flag_has_override() {
let flag_info_list = create_test_flag_info_list().into_bytes();
for offset in 0..8 {
let attribute =
find_flag_attribute(&flag_info_list[..], FlagValueType::Boolean, offset).unwrap();
assert_eq!((attribute & FlagInfoBit::HasOverride as u8) != 0u8, false);
assert_eq!((attribute & FlagInfoBit::HasLocalOverride as u8) != 0u8, false);
}
}

View file

@ -508,9 +508,9 @@ files {{
for (offset, expected_value) in is_rw.into_iter().enumerate() {
let attribute =
get_flag_attribute(&flag_info_file, FlagValueType::Boolean, offset as u32).unwrap();
assert!((attribute & FlagInfoBit::IsSticky as u8) == 0u8);
assert_eq!((attribute & FlagInfoBit::IsReadWrite as u8) != 0u8, expected_value);
assert!((attribute & FlagInfoBit::HasOverride as u8) == 0u8);
assert!((attribute & FlagInfoBit::HasServerOverride as u8) == 0u8);
assert!((attribute & FlagInfoBit::HasLocalOverride as u8) == 0u8);
}
}

View file

@ -236,10 +236,10 @@ TEST_F(AconfigStorageTest, test_boolean_flag_info_query) {
for (int index = 0; index < 8; ++index) {
auto attribute = api::get_flag_attribute(*mapped_file, api::FlagValueType::Boolean, index);
ASSERT_TRUE(attribute.ok());
ASSERT_EQ(*attribute & static_cast<uint8_t>(api::FlagInfoBit::IsSticky), 0);
ASSERT_EQ(*attribute & static_cast<uint8_t>(api::FlagInfoBit::HasServerOverride), 0);
ASSERT_EQ((*attribute & static_cast<uint8_t>(api::FlagInfoBit::IsReadWrite)) != 0,
expected_value[index]);
ASSERT_EQ(*attribute & static_cast<uint8_t>(api::FlagInfoBit::HasOverride), 0);
ASSERT_EQ(*attribute & static_cast<uint8_t>(api::FlagInfoBit::HasLocalOverride), 0);
}
}

View file

@ -192,9 +192,9 @@ files {{
for (offset, expected_value) in is_rw.into_iter().enumerate() {
let attribute =
get_flag_attribute(&flag_info_file, FlagValueType::Boolean, offset as u32).unwrap();
assert!((attribute & FlagInfoBit::IsSticky as u8) == 0u8);
assert!((attribute & FlagInfoBit::HasServerOverride as u8) == 0u8);
assert_eq!((attribute & FlagInfoBit::IsReadWrite as u8) != 0u8, expected_value);
assert!((attribute & FlagInfoBit::HasOverride as u8) == 0u8);
assert!((attribute & FlagInfoBit::HasLocalOverride as u8) == 0u8);
}
}

View file

@ -142,15 +142,15 @@ Result<void> set_boolean_flag_value(
return {};
}
/// Set if flag is sticky
Result<void> set_flag_is_sticky(
/// Set if flag has server override
Result<void> set_flag_has_server_override(
const MutableMappedStorageFile& file,
FlagValueType value_type,
uint32_t offset,
bool value) {
auto content = rust::Slice<uint8_t>(
static_cast<uint8_t*>(file.file_ptr), file.file_size);
auto update_cxx = update_flag_is_sticky_cxx(
auto update_cxx = update_flag_has_server_override_cxx(
content, static_cast<uint16_t>(value_type), offset, value);
if (!update_cxx.update_success) {
return Error() << std::string(update_cxx.error_message.c_str());
@ -158,15 +158,15 @@ Result<void> set_flag_is_sticky(
return {};
}
/// Set if flag has override
Result<void> set_flag_has_override(
/// Set if flag has local override
Result<void> set_flag_has_local_override(
const MutableMappedStorageFile& file,
FlagValueType value_type,
uint32_t offset,
bool value) {
auto content = rust::Slice<uint8_t>(
static_cast<uint8_t*>(file.file_ptr), file.file_size);
auto update_cxx = update_flag_has_override_cxx(
auto update_cxx = update_flag_has_local_override_cxx(
content, static_cast<uint16_t>(value_type), offset, value);
if (!update_cxx.update_success) {
return Error() << std::string(update_cxx.error_message.c_str());

View file

@ -41,15 +41,15 @@ Result<void> set_boolean_flag_value(
uint32_t offset,
bool value);
/// Set if flag is sticky
Result<void> set_flag_is_sticky(
/// Set if flag has server override
Result<void> set_flag_has_server_override(
const MutableMappedStorageFile& file,
FlagValueType value_type,
uint32_t offset,
bool value);
/// Set if flag has override
Result<void> set_flag_has_override(
/// Set if flag has local override
Result<void> set_flag_has_local_override(
const MutableMappedStorageFile& file,
FlagValueType value_type,
uint32_t offset,

View file

@ -61,32 +61,32 @@ fn get_flag_attribute_and_offset(
Ok((attribute, head))
}
/// Set if flag is sticky
pub fn update_flag_is_sticky(
/// Set if flag has server override
pub fn update_flag_has_server_override(
buf: &mut [u8],
flag_type: FlagValueType,
flag_index: u32,
value: bool,
) -> Result<(), AconfigStorageError> {
let (attribute, head) = get_flag_attribute_and_offset(buf, flag_type, flag_index)?;
let is_sticky = (attribute & (FlagInfoBit::IsSticky as u8)) != 0;
if is_sticky != value {
buf[head] = (attribute ^ FlagInfoBit::IsSticky as u8).to_le_bytes()[0];
let has_override = (attribute & (FlagInfoBit::HasServerOverride as u8)) != 0;
if has_override != value {
buf[head] = (attribute ^ FlagInfoBit::HasServerOverride as u8).to_le_bytes()[0];
}
Ok(())
}
/// Set if flag has override
pub fn update_flag_has_override(
/// Set if flag has local override
pub fn update_flag_has_local_override(
buf: &mut [u8],
flag_type: FlagValueType,
flag_index: u32,
value: bool,
) -> Result<(), AconfigStorageError> {
let (attribute, head) = get_flag_attribute_and_offset(buf, flag_type, flag_index)?;
let has_override = (attribute & (FlagInfoBit::HasOverride as u8)) != 0;
let has_override = (attribute & (FlagInfoBit::HasLocalOverride as u8)) != 0;
if has_override != value {
buf[head] = (attribute ^ FlagInfoBit::HasOverride as u8).to_le_bytes()[0];
buf[head] = (attribute ^ FlagInfoBit::HasLocalOverride as u8).to_le_bytes()[0];
}
Ok(())
}
@ -98,32 +98,32 @@ mod tests {
use aconfig_storage_read_api::flag_info_query::find_flag_attribute;
#[test]
// this test point locks down is sticky update
fn test_update_flag_is_sticky() {
// this test point locks down has server override update
fn test_update_flag_has_server_override() {
let flag_info_list = create_test_flag_info_list();
let mut buf = flag_info_list.into_bytes();
for i in 0..flag_info_list.header.num_flags {
update_flag_is_sticky(&mut buf, FlagValueType::Boolean, i, true).unwrap();
update_flag_has_server_override(&mut buf, FlagValueType::Boolean, i, true).unwrap();
let attribute = find_flag_attribute(&buf, FlagValueType::Boolean, i).unwrap();
assert!((attribute & (FlagInfoBit::IsSticky as u8)) != 0);
update_flag_is_sticky(&mut buf, FlagValueType::Boolean, i, false).unwrap();
assert!((attribute & (FlagInfoBit::HasServerOverride as u8)) != 0);
update_flag_has_server_override(&mut buf, FlagValueType::Boolean, i, false).unwrap();
let attribute = find_flag_attribute(&buf, FlagValueType::Boolean, i).unwrap();
assert!((attribute & (FlagInfoBit::IsSticky as u8)) == 0);
assert!((attribute & (FlagInfoBit::HasServerOverride as u8)) == 0);
}
}
#[test]
// this test point locks down has override update
fn test_update_flag_has_override() {
// this test point locks down has local override update
fn test_update_flag_has_local_override() {
let flag_info_list = create_test_flag_info_list();
let mut buf = flag_info_list.into_bytes();
for i in 0..flag_info_list.header.num_flags {
update_flag_has_override(&mut buf, FlagValueType::Boolean, i, true).unwrap();
update_flag_has_local_override(&mut buf, FlagValueType::Boolean, i, true).unwrap();
let attribute = find_flag_attribute(&buf, FlagValueType::Boolean, i).unwrap();
assert!((attribute & (FlagInfoBit::HasOverride as u8)) != 0);
update_flag_has_override(&mut buf, FlagValueType::Boolean, i, false).unwrap();
assert!((attribute & (FlagInfoBit::HasLocalOverride as u8)) != 0);
update_flag_has_local_override(&mut buf, FlagValueType::Boolean, i, false).unwrap();
let attribute = find_flag_attribute(&buf, FlagValueType::Boolean, i).unwrap();
assert!((attribute & (FlagInfoBit::HasOverride as u8)) == 0);
assert!((attribute & (FlagInfoBit::HasLocalOverride as u8)) == 0);
}
}
}

View file

@ -75,39 +75,39 @@ pub fn set_boolean_flag_value(
})
}
/// Set if flag is sticky thru mapped file and flush the change to file
/// Set if flag is has server override thru mapped file and flush the change to file
///
/// \input mapped_file: the mapped flag info file
/// \input index: flag index
/// \input value: updated flag sticky value
/// \input value: updated flag has server override value
/// \return a result of ()
///
pub fn set_flag_is_sticky(
pub fn set_flag_has_server_override(
file: &mut MmapMut,
flag_type: FlagValueType,
index: u32,
value: bool,
) -> Result<(), AconfigStorageError> {
crate::flag_info_update::update_flag_is_sticky(file, flag_type, index, value)?;
crate::flag_info_update::update_flag_has_server_override(file, flag_type, index, value)?;
file.flush().map_err(|errmsg| {
AconfigStorageError::MapFlushFail(anyhow!("fail to flush storage file: {}", errmsg))
})
}
/// Set if flag has override thru mapped file and flush the change to file
/// Set if flag has local override thru mapped file and flush the change to file
///
/// \input mapped_file: the mapped flag info file
/// \input index: flag index
/// \input value: updated flag has override value
/// \input value: updated flag has local override value
/// \return a result of ()
///
pub fn set_flag_has_override(
pub fn set_flag_has_local_override(
file: &mut MmapMut,
flag_type: FlagValueType,
index: u32,
value: bool,
) -> Result<(), AconfigStorageError> {
crate::flag_info_update::update_flag_has_override(file, flag_type, index, value)?;
crate::flag_info_update::update_flag_has_local_override(file, flag_type, index, value)?;
file.flush().map_err(|errmsg| {
AconfigStorageError::MapFlushFail(anyhow!("fail to flush storage file: {}", errmsg))
})
@ -206,14 +206,14 @@ mod ffi {
pub error_message: String,
}
// Flag is sticky update return for cc interlop
pub struct FlagIsStickyUpdateCXX {
// Flag has server override update return for cc interlop
pub struct FlagHasServerOverrideUpdateCXX {
pub update_success: bool,
pub error_message: String,
}
// Flag has override update return for cc interlop
pub struct FlagHasOverrideUpdateCXX {
// Flag has local override update return for cc interlop
pub struct FlagHasLocalOverrideUpdateCXX {
pub update_success: bool,
pub error_message: String,
}
@ -232,19 +232,19 @@ mod ffi {
value: bool,
) -> BooleanFlagValueUpdateCXX;
pub fn update_flag_is_sticky_cxx(
pub fn update_flag_has_server_override_cxx(
file: &mut [u8],
flag_type: u16,
offset: u32,
value: bool,
) -> FlagIsStickyUpdateCXX;
) -> FlagHasServerOverrideUpdateCXX;
pub fn update_flag_has_override_cxx(
pub fn update_flag_has_local_override_cxx(
file: &mut [u8],
flag_type: u16,
offset: u32,
value: bool,
) -> FlagHasOverrideUpdateCXX;
) -> FlagHasLocalOverrideUpdateCXX;
pub fn create_flag_info_cxx(
package_map: &str,
@ -270,53 +270,56 @@ pub(crate) fn update_boolean_flag_value_cxx(
}
}
pub(crate) fn update_flag_is_sticky_cxx(
pub(crate) fn update_flag_has_server_override_cxx(
file: &mut [u8],
flag_type: u16,
offset: u32,
value: bool,
) -> ffi::FlagIsStickyUpdateCXX {
) -> ffi::FlagHasServerOverrideUpdateCXX {
match FlagValueType::try_from(flag_type) {
Ok(value_type) => {
match crate::flag_info_update::update_flag_is_sticky(file, value_type, offset, value) {
Ok(()) => ffi::FlagIsStickyUpdateCXX {
match crate::flag_info_update::update_flag_has_server_override(
file, value_type, offset, value,
) {
Ok(()) => ffi::FlagHasServerOverrideUpdateCXX {
update_success: true,
error_message: String::from(""),
},
Err(errmsg) => ffi::FlagIsStickyUpdateCXX {
Err(errmsg) => ffi::FlagHasServerOverrideUpdateCXX {
update_success: false,
error_message: format!("{:?}", errmsg),
},
}
}
Err(errmsg) => ffi::FlagIsStickyUpdateCXX {
Err(errmsg) => ffi::FlagHasServerOverrideUpdateCXX {
update_success: false,
error_message: format!("{:?}", errmsg),
},
}
}
pub(crate) fn update_flag_has_override_cxx(
pub(crate) fn update_flag_has_local_override_cxx(
file: &mut [u8],
flag_type: u16,
offset: u32,
value: bool,
) -> ffi::FlagHasOverrideUpdateCXX {
) -> ffi::FlagHasLocalOverrideUpdateCXX {
match FlagValueType::try_from(flag_type) {
Ok(value_type) => {
match crate::flag_info_update::update_flag_has_override(file, value_type, offset, value)
{
Ok(()) => ffi::FlagHasOverrideUpdateCXX {
match crate::flag_info_update::update_flag_has_local_override(
file, value_type, offset, value,
) {
Ok(()) => ffi::FlagHasLocalOverrideUpdateCXX {
update_success: true,
error_message: String::from(""),
},
Err(errmsg) => ffi::FlagHasOverrideUpdateCXX {
Err(errmsg) => ffi::FlagHasLocalOverrideUpdateCXX {
update_success: false,
error_message: format!("{:?}", errmsg),
},
}
}
Err(errmsg) => ffi::FlagHasOverrideUpdateCXX {
Err(errmsg) => ffi::FlagHasLocalOverrideUpdateCXX {
update_success: false,
error_message: format!("{:?}", errmsg),
},
@ -411,7 +414,7 @@ files {{
}
#[test]
fn test_set_flag_is_sticky() {
fn test_set_flag_has_server_override() {
let flag_info_file = copy_to_temp_file("./tests/flag.info", false).unwrap();
let flag_info_path = flag_info_file.path().display().to_string();
let text_proto = format!(
@ -442,20 +445,20 @@ files {{
)
.unwrap();
for i in 0..8 {
set_flag_is_sticky(&mut file, FlagValueType::Boolean, i, true).unwrap();
set_flag_has_server_override(&mut file, FlagValueType::Boolean, i, true).unwrap();
let attribute =
get_flag_attribute_at_offset(&flag_info_path, FlagValueType::Boolean, i);
assert!((attribute & (FlagInfoBit::IsSticky as u8)) != 0);
set_flag_is_sticky(&mut file, FlagValueType::Boolean, i, false).unwrap();
assert!((attribute & (FlagInfoBit::HasServerOverride as u8)) != 0);
set_flag_has_server_override(&mut file, FlagValueType::Boolean, i, false).unwrap();
let attribute =
get_flag_attribute_at_offset(&flag_info_path, FlagValueType::Boolean, i);
assert!((attribute & (FlagInfoBit::IsSticky as u8)) == 0);
assert!((attribute & (FlagInfoBit::HasServerOverride as u8)) == 0);
}
}
}
#[test]
fn test_set_flag_has_override() {
fn test_set_flag_has_local_override() {
let flag_info_file = copy_to_temp_file("./tests/flag.info", false).unwrap();
let flag_info_path = flag_info_file.path().display().to_string();
let text_proto = format!(
@ -486,14 +489,14 @@ files {{
)
.unwrap();
for i in 0..8 {
set_flag_has_override(&mut file, FlagValueType::Boolean, i, true).unwrap();
set_flag_has_local_override(&mut file, FlagValueType::Boolean, i, true).unwrap();
let attribute =
get_flag_attribute_at_offset(&flag_info_path, FlagValueType::Boolean, i);
assert!((attribute & (FlagInfoBit::HasOverride as u8)) != 0);
set_flag_has_override(&mut file, FlagValueType::Boolean, i, false).unwrap();
assert!((attribute & (FlagInfoBit::HasLocalOverride as u8)) != 0);
set_flag_has_local_override(&mut file, FlagValueType::Boolean, i, false).unwrap();
let attribute =
get_flag_attribute_at_offset(&flag_info_path, FlagValueType::Boolean, i);
assert!((attribute & (FlagInfoBit::HasOverride as u8)) == 0);
assert!((attribute & (FlagInfoBit::HasLocalOverride as u8)) == 0);
}
}
}

View file

@ -156,15 +156,15 @@ TEST_F(AconfigStorageTest, test_invalid_boolean_flag_value_update) {
std::string("InvalidStorageFileOffset(Flag value offset goes beyond the end of the file.)"));
}
/// Test to lock down storage flag stickiness update api
TEST_F(AconfigStorageTest, test_flag_is_sticky_update) {
/// Test to lock down storage flag has server override update api
TEST_F(AconfigStorageTest, test_flag_has_server_override_update) {
auto mapped_file_result = private_api::get_mutable_mapped_file_impl(
storage_record_pb, "mockup", api::StorageFileType::flag_info);
ASSERT_TRUE(mapped_file_result.ok());
auto mapped_file = *mapped_file_result;
for (int offset = 0; offset < 8; ++offset) {
auto update_result = api::set_flag_is_sticky(
auto update_result = api::set_flag_has_server_override(
mapped_file, api::FlagValueType::Boolean, offset, true);
ASSERT_TRUE(update_result.ok());
auto ro_mapped_file = api::MappedStorageFile();
@ -173,9 +173,9 @@ TEST_F(AconfigStorageTest, test_flag_is_sticky_update) {
auto attribute = api::get_flag_attribute(
ro_mapped_file, api::FlagValueType::Boolean, offset);
ASSERT_TRUE(attribute.ok());
ASSERT_TRUE(*attribute & api::FlagInfoBit::IsSticky);
ASSERT_TRUE(*attribute & api::FlagInfoBit::HasServerOverride);
update_result = api::set_flag_is_sticky(
update_result = api::set_flag_has_server_override(
mapped_file, api::FlagValueType::Boolean, offset, false);
ASSERT_TRUE(update_result.ok());
ro_mapped_file.file_ptr = mapped_file.file_ptr;
@ -183,19 +183,19 @@ TEST_F(AconfigStorageTest, test_flag_is_sticky_update) {
attribute = api::get_flag_attribute(
ro_mapped_file, api::FlagValueType::Boolean, offset);
ASSERT_TRUE(attribute.ok());
ASSERT_FALSE(*attribute & api::FlagInfoBit::IsSticky);
ASSERT_FALSE(*attribute & api::FlagInfoBit::HasServerOverride);
}
}
/// Test to lock down storage flag has override update api
TEST_F(AconfigStorageTest, test_flag_has_override_update) {
/// Test to lock down storage flag has local override update api
TEST_F(AconfigStorageTest, test_flag_has_local_override_update) {
auto mapped_file_result = private_api::get_mutable_mapped_file_impl(
storage_record_pb, "mockup", api::StorageFileType::flag_info);
ASSERT_TRUE(mapped_file_result.ok());
auto mapped_file = *mapped_file_result;
for (int offset = 0; offset < 8; ++offset) {
auto update_result = api::set_flag_has_override(
auto update_result = api::set_flag_has_local_override(
mapped_file, api::FlagValueType::Boolean, offset, true);
ASSERT_TRUE(update_result.ok());
auto ro_mapped_file = api::MappedStorageFile();
@ -204,9 +204,9 @@ TEST_F(AconfigStorageTest, test_flag_has_override_update) {
auto attribute = api::get_flag_attribute(
ro_mapped_file, api::FlagValueType::Boolean, offset);
ASSERT_TRUE(attribute.ok());
ASSERT_TRUE(*attribute & api::FlagInfoBit::HasOverride);
ASSERT_TRUE(*attribute & api::FlagInfoBit::HasLocalOverride);
update_result = api::set_flag_has_override(
update_result = api::set_flag_has_local_override(
mapped_file, api::FlagValueType::Boolean, offset, false);
ASSERT_TRUE(update_result.ok());
ro_mapped_file.file_ptr = mapped_file.file_ptr;
@ -214,6 +214,6 @@ TEST_F(AconfigStorageTest, test_flag_has_override_update) {
attribute = api::get_flag_attribute(
ro_mapped_file, api::FlagValueType::Boolean, offset);
ASSERT_TRUE(attribute.ok());
ASSERT_FALSE(*attribute & api::FlagInfoBit::HasOverride);
ASSERT_FALSE(*attribute & api::FlagInfoBit::HasLocalOverride);
}
}

View file

@ -5,8 +5,8 @@ mod aconfig_storage_write_api_test {
use aconfig_storage_read_api::flag_info_query::find_flag_attribute;
use aconfig_storage_read_api::flag_value_query::find_boolean_flag_value;
use aconfig_storage_write_api::{
mapped_file::get_mapped_file, set_boolean_flag_value, set_flag_has_override,
set_flag_is_sticky,
mapped_file::get_mapped_file, set_boolean_flag_value, set_flag_has_local_override,
set_flag_has_server_override,
};
use protobuf::Message;
@ -90,8 +90,8 @@ files {{
}
#[test]
/// Test to lock down flag is sticky update api
fn test_set_flag_is_sticky() {
/// Test to lock down flag has server override update api
fn test_set_flag_has_server_override() {
let flag_value_file = copy_to_temp_rw_file("./flag.val");
let flag_info_file = copy_to_temp_rw_file("./flag.info");
let flag_value_path = flag_value_file.path().display().to_string();
@ -106,20 +106,20 @@ files {{
get_mapped_file(&record_pb_path, "mockup", StorageFileType::FlagInfo).unwrap()
};
for i in 0..8 {
set_flag_is_sticky(&mut file, FlagValueType::Boolean, i, true).unwrap();
set_flag_has_server_override(&mut file, FlagValueType::Boolean, i, true).unwrap();
let attribute =
get_flag_attribute_at_offset(&flag_info_path, FlagValueType::Boolean, i);
assert!((attribute & (FlagInfoBit::IsSticky as u8)) != 0);
set_flag_is_sticky(&mut file, FlagValueType::Boolean, i, false).unwrap();
assert!((attribute & (FlagInfoBit::HasServerOverride as u8)) != 0);
set_flag_has_server_override(&mut file, FlagValueType::Boolean, i, false).unwrap();
let attribute =
get_flag_attribute_at_offset(&flag_info_path, FlagValueType::Boolean, i);
assert!((attribute & (FlagInfoBit::IsSticky as u8)) == 0);
assert!((attribute & (FlagInfoBit::HasServerOverride as u8)) == 0);
}
}
#[test]
/// Test to lock down flag is sticky update api
fn test_set_flag_has_override() {
/// Test to lock down flag has local override update api
fn test_set_flag_has_local_override() {
let flag_value_file = copy_to_temp_rw_file("./flag.val");
let flag_info_file = copy_to_temp_rw_file("./flag.info");
let flag_value_path = flag_value_file.path().display().to_string();
@ -134,14 +134,14 @@ files {{
get_mapped_file(&record_pb_path, "mockup", StorageFileType::FlagInfo).unwrap()
};
for i in 0..8 {
set_flag_has_override(&mut file, FlagValueType::Boolean, i, true).unwrap();
set_flag_has_local_override(&mut file, FlagValueType::Boolean, i, true).unwrap();
let attribute =
get_flag_attribute_at_offset(&flag_info_path, FlagValueType::Boolean, i);
assert!((attribute & (FlagInfoBit::HasOverride as u8)) != 0);
set_flag_has_override(&mut file, FlagValueType::Boolean, i, false).unwrap();
assert!((attribute & (FlagInfoBit::HasLocalOverride as u8)) != 0);
set_flag_has_local_override(&mut file, FlagValueType::Boolean, i, false).unwrap();
let attribute =
get_flag_attribute_at_offset(&flag_info_path, FlagValueType::Boolean, i);
assert!((attribute & (FlagInfoBit::HasOverride as u8)) == 0);
assert!((attribute & (FlagInfoBit::HasLocalOverride as u8)) == 0);
}
}
}