Skip to content
Merged
Show file tree
Hide file tree
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
24 changes: 15 additions & 9 deletions conformance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -559,17 +559,23 @@ cargo xtask conformance run --profile rustfs --endpoint http://127.0.0.1:9100 \
--rulings conformance/rulings/rustfs-profile.toml --json report.json
```

The fixture opt-in supports owned buckets, objects, multipart uploads with declared parts, and enabled
versioning. Setup records each returned upload ID and uploads the declared parts, capturing returned
The fixture opt-in supports owned buckets, objects, multipart uploads with declared parts, enabled
versioning, and Object Lock buckets. Setup records each returned upload ID and uploads the declared parts, capturing returned
ETags when requested. Cleanup aborts tracked uploads with known IDs, including after setup failure.
An existing bucket is never adopted. Versioned buckets are enabled and read back before setup
objects or authored writes run. Structured path-style object PUT, CopyObject and DELETE exchanges
may write within owned versioned buckets; the runner records each returned version ID, including
objects or authored writes run. Object Lock buckets are created with `x-amz-bucket-object-lock-enabled: true`
and verified by reading back both `?object-lock` and `?versioning` as `Enabled` before setup objects
are put with exact version tracking. Structured path-style object PUT, CopyObject and DELETE exchanges
may write within owned unlocked versioned buckets; the runner records each returned version ID, including
delete markers, and deletes those exact versions before removing the bucket. Copy sources must
also use owned versioned buckets. Unclassified raw or HTTP/2 mutations, request subresources,
ambiguous framing and Host overrides remain unsupported. Missing upload or version identities, or
failed cleanup, retain ownership and block the next case. Object Lock and authored multipart writes,
including completion, remain unsupported and report their capability reason.
also use owned unlocked versioned buckets. Authored writes against Object Lock buckets require
`--allow-external-writes`, under which cleanup deletes versions with `x-amz-bypass-governance-retention: true`
and lifts active Legal Hold (`OFF`) before retrying `DELETE`; cases that would apply irremovable
`COMPLIANCE` object retention are skipped at preflight before any remote contact so they never wedge
a bucket. Unclassified raw or HTTP/2 mutations, request subresources,
ambiguous framing and Host overrides remain unsupported without `--allow-external-writes`. Missing upload or version identities, or
failed cleanup, retain ownership and block the next case. Authored multipart writes without
`--allow-external-writes`, including completion, remain unsupported and report their capability reason.

**Writes need `--allow-external-writes`.** Without it the runner sends no authored write to an
endpoint. A request counts as a write unless its bytes can only read: anything but GET, HEAD or
Expand Down Expand Up @@ -614,7 +620,7 @@ in its list of cases configured by id that an endpoint can still judge, and ever
**What can run against an external endpoint at all.** Two gates run before any traffic: the clock
gate skips, at the `clock` phase, a case that pins `clock.fixed` (or a server `skew_ms`) an
endpoint on its own wall clock cannot follow — the text report counts these on a `clock:` line —
and the preflight gate above. Of the 895 cases, 538 (60.1%) pass these gates with
and the preflight gate above. Of the 895 cases, 537 (60.0%) pass these gates with
`--allow-external-writes` and 128 (14.3%) without it, with `--allow-external-fixtures` in both and
the endpoint on its own wall clock. `writes_tests::the_readme_states_the_externally_runnable_share_of_this_corpus`
recomputes both numbers from the corpus with the runner's own gates and fails until this sentence
Expand Down
2 changes: 1 addition & 1 deletion crates/conformance/MAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ ADRs; this map only selects files.
| `src/conn/external_pacing.rs` | Cleartext external-body delays and early-response observation. | A delayed chunk is sent too early or after a response already exists. |
| `src/conn/external_endpoint.rs`, `src/conn/external_identity.rs` | Strict HTTP(S) endpoint parsing, resolution, and protocol selection; the one `HEAD /` probe whose `Server` header is the report's `target_build`. | An endpoint scheme, authority, host, or default port is handled incorrectly, or the report names a build the target did not send. |
| `src/conn/external_fixture.rs` | Opt-in external owned bucket/object/version/multipart planning and mutation boundaries. | A remote fixture shape or authored mutation is accepted incorrectly. |
| `src/conn/external_fixture/clock.rs`, `src/conn/external_fixture/versioned.rs`, `src/conn/external_fixture/versioned_tests.rs` | UTC conversion and exact version ownership, enablement, write boundaries and cleanup proofs. | A control time, version identity, authored write or version cleanup is wrong. |
| `src/conn/external_fixture/clock.rs`, `src/conn/external_fixture/versioned.rs`, `src/conn/external_fixture/versioned_tests.rs`, `src/conn/external_fixture/object_lock.rs`, `src/conn/external_fixture/object_lock_tests.rs` | UTC conversion, exact version ownership, and Object Lock enablement verification, preflight COMPLIANCE refusal, and locked version cleanup. | A control time, version identity, Object Lock readback, authored write, or locked cleanup is wrong. |
| `src/conn/external_fixture/lifecycle.rs`, `src/conn/external_fixture/batch_delete.rs`, `src/conn/external_fixture/batch_delete_tests.rs` | Applies validated external plans over keep-alive control sockets, batch-deletes owned objects via `DeleteObjects` with fail-closed ownership retention and `501` fallback, and cleans objects before buckets. | A remote create, keep-alive reuse, batch cleanup, rollback, or ownership order is wrong. |
| `src/conn/external_fixture/multipart.rs`, `src/conn/external_fixture/object.rs`, `src/conn/external_fixture/object_tests.rs`, `src/conn/external_fixture/multipart_tests.rs`, `src/conn/external_fixture/parts_tests.rs`, `src/conn/external_fixture/parts_peer.rs` | Object plans and socket controls for object/upload ownership, part payloads, refusal and cleanup. | External fixture bytes, returned upload identities, preflight validation or cleanup order changes. |
| `src/conn/external_fixture/writes.rs`, `src/conn/external_fixture/writes_tests.rs`, `src/conn/external_fixture/h2_guard_tests.rs`, `src/conn/external_fixture/response_xml.rs` | The `--allow-external-writes` gate (a write case is skipped before any traffic without it; HTTP/2 scripts are classified by decoded `:method`) and the declared-bucket emptying it needs, controlled on a recording endpoint; the empty-endpoint check; the one strict reader of fixture response XML. | An external write is sent without the flag, refused with it, or leaves a declared bucket behind, or a fixture response is misread. |
Expand Down
55 changes: 41 additions & 14 deletions crates/conformance/src/conn/external_fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! Opt-in owned bucket, object, version, and multipart fixtures for an external endpoint.
//! Opt-in owned bucket, object, version, Object Lock, and multipart fixtures for an external endpoint.
//!
//! Responsible for: validating the narrow remote-setup subset, restricting authored writes to
//! Responsible for: validating the remote-setup subset, restricting authored writes to
//! classified owned versions unless `--allow-external-writes` granted them, and holding
//! successful or unresolved remote ownership.
//! NOT responsible for: locked or fault fixtures; endpoint resolution; authored
//! NOT responsible for: fault fixtures; endpoint resolution; authored
//! exchange pacing; or response judgement. Upstream: `external`; downstream: the endpoint selected
//! by `crate::cli`.

Expand All @@ -39,6 +39,9 @@ mod multipart;
#[cfg(test)]
mod multipart_tests;
mod object;
mod object_lock;
#[cfg(test)]
mod object_lock_tests;
#[cfg(test)]
mod object_tests;
mod region;
Expand Down Expand Up @@ -88,6 +91,7 @@ struct BucketPlan {
absent: bool,
region: region::FixtureRegion,
versioned: bool,
object_lock: bool,
}

#[derive(Debug)]
Expand All @@ -102,6 +106,7 @@ struct OwnedBucket {
name: String,
region: region::FixtureRegion,
versioned: bool,
object_lock: bool,
}

impl ExternalFixtures {
Expand All @@ -126,13 +131,17 @@ impl ExternalFixtures {
self.control_connection = None;
}

/// Whether `target` addresses an object inside an owned versioning-enabled bucket.
/// Whether `target` addresses an object inside an owned versioning-enabled or Object Lock bucket.
pub(super) fn is_versioned_object_target(&self, target: &str) -> bool {
let path = target.split_once('?').map_or(target, |(path, _)| path);
let Some((bucket, key)) = path.strip_prefix('/').and_then(|rest| rest.split_once('/')) else {
return false;
};
!key.is_empty() && self.owned_buckets.iter().any(|owned| owned.name == bucket && owned.versioned)
!key.is_empty()
&& self
.owned_buckets
.iter()
.any(|owned| owned.name == bucket && (owned.versioned || owned.object_lock))
}

fn plan(&self, setup: &Value, decoder: &crate::inprocess::InProcess) -> Result<FixturePlan, SutError> {
Expand Down Expand Up @@ -178,21 +187,38 @@ impl ExternalFixtures {
)));
}
let versioning = bucket.read("setup.buckets[].versioning").and_then(Value::as_str);
if !matches!(versioning, None | Some("disabled" | "enabled"))
|| bucket.read("setup.buckets[].object_lock").and_then(Value::as_bool) == Some(true)
{
let absent = match bucket.read("setup.buckets[].absent") {
None => false,
Some(value) => value.as_bool().ok_or_else(|| {
SutError::Environment(format!(
"external bucket state for `{name}` is not supported; `absent` must be a boolean"
))
})?,
};
let object_lock = match bucket.read("setup.buckets[].object_lock") {
None => false,
Some(value) => value.as_bool().ok_or_else(|| {
SutError::Environment(format!(
"external bucket state for `{name}` is not supported; `object_lock` must be a boolean"
))
})?,
};
if !matches!(versioning, None | Some("disabled" | "enabled")) {
return Err(SutError::Environment(format!(
"external bucket state for `{name}` is not supported; object fixtures require versioning disabled or enabled"
)));
}
if object_lock && (absent || versioning == Some("disabled")) {
return Err(SutError::Environment(format!(
"external bucket state for `{name}` is not supported; object fixtures require an owned, non-absent, unlocked bucket with versioning disabled or enabled"
"external bucket state for `{name}` is not supported; object_lock requires a non-absent bucket with versioning not disabled"
)));
}
plan.push(BucketPlan {
name: name.to_owned(),
absent: bucket
.read("setup.buckets[].absent")
.and_then(Value::as_bool)
.unwrap_or(false),
absent,
region: region::FixtureRegion::parse(bucket.read("setup.buckets[].region").and_then(Value::as_str))?,
versioned: versioning == Some("enabled"),
object_lock,
});
}
let objects = object::plans(setup, &plan, decoder)?;
Expand Down Expand Up @@ -475,7 +501,8 @@ mod tests {
"[[buckets]]\nname = \"fixture-one\"\n[[multipart_uploads]]\nbucket = \"fixture-one\"\nkey = \"one\"\nparts = [{ part_number = 1, unknown = true }]\n",
"fault = { operation = \"PutObject\", at = \"after_commit\", code = \"InternalError\" }\n",
"[[buckets]]\nname = \"fixture-one\"\nversioning = \"suspended\"\n",
"[[buckets]]\nname = \"fixture-one\"\nobject_lock = true\n",
"[[buckets]]\nname = \"fixture-one\"\nversioning = \"disabled\"\nobject_lock = true\n",
"[[buckets]]\nname = \"fixture-one\"\nabsent = true\nobject_lock = true\n",
"[[buckets]]\nname = \"fixture-one\"\nregion = \"../us-west-2\"\n",
"[[buckets]]\nname = \"../escape\"\n",
] {
Expand Down
40 changes: 34 additions & 6 deletions crates/conformance/src/conn/external_fixture/lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,19 @@ impl Conn {
name: bucket.name,
region: bucket.region,
versioned: false,
object_lock: false,
});
}
continue;
}
let create_body = bucket.region.create_body();
let headers = (!create_body.is_empty())
.then(|| ("content-type".to_owned(), "application/xml".to_owned()))
.into_iter()
.collect::<Vec<_>>();
let mut headers = Vec::new();
if !create_body.is_empty() {
headers.push(("content-type".to_owned(), "application/xml".to_owned()));
}
if bucket.object_lock {
headers.push(("x-amz-bucket-object-lock-enabled".to_owned(), "true".to_owned()));
}
let status = match self.fixture_control_status("PUT", &target, &bucket.region, create_body, &headers) {
Ok(status) => status,
Err(error) => return Err(self.abort_external_prepare(error)),
Expand All @@ -104,8 +108,11 @@ impl Conn {
name: bucket.name,
region: bucket.region,
versioned: bucket.versioned,
object_lock: bucket.object_lock,
};
let enablement = if owned.versioned {
let enablement = if owned.object_lock {
self.verify_fixture_object_lock(&owned)
} else if owned.versioned {
self.enable_fixture_versioning(&owned)
} else {
Ok(())
Expand Down Expand Up @@ -141,7 +148,7 @@ impl Conn {
.external_fixtures
.owned_buckets
.iter()
.any(|bucket| bucket.name == object.bucket && bucket.versioned)
.any(|bucket| bucket.name == object.bucket && (bucket.versioned || bucket.object_lock))
{
if let Err(error) = self.put_fixture_version(&object) {
return Err(self.abort_external_prepare(error));
Expand Down Expand Up @@ -262,13 +269,34 @@ impl Conn {
}
failed_uploads.reverse();
self.external_fixtures.owned_uploads = failed_uploads;
let locked_buckets: BTreeSet<String> = self
.external_fixtures
.owned_buckets
.iter()
.filter(|bucket| bucket.object_lock)
.map(|bucket| bucket.name.clone())
.collect();
let mut failed_versions = Vec::new();
while let Some(version) = self.external_fixtures.owned_versions.pop() {
let Some(id) = version.version_id.as_deref() else {
messages.push(super::versioned::unresolved().to_string());
failed_versions.push(version);
continue;
};
if self.external_fixtures.writes && locked_buckets.contains(&version.bucket) {
if let Err(error) = self.delete_locked_fixture_version(
&version.bucket,
&version.target,
id,
&version.region,
!version.delete_marker,
true,
) {
messages.push(error.to_string());
failed_versions.push(version);
}
continue;
}
let target = super::object::query_target(&version.target, "versionId", id);
match self.fixture_control_status("DELETE", &target, &version.region, &[], &[]) {
Ok(204) => {}
Expand Down
15 changes: 13 additions & 2 deletions crates/conformance/src/conn/external_fixture/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub(super) fn plans(setup: &Value, buckets: &[BucketPlan], decoder: &InProcess)
};
let headers = object_headers(content_type, storage_class, metadata)?;
let target = object_target(bucket, key)?;
if bucket_plan.versioned {
if bucket_plan.versioned || bucket_plan.object_lock {
super::versioned::object_bucket(&target)?;
}
plans.push(ObjectPlan {
Expand Down Expand Up @@ -179,6 +179,18 @@ pub(super) fn object_target(bucket: &str, key: &str) -> Result<String, SutError>
/// `target` with one query parameter, its value percent-encoded as an unreserved-only string.
pub(super) fn query_target(target: &str, name: &str, value: &str) -> String {
let mut target = format!("{target}?{name}=");
append_query_value(&mut target, value);
target
}

/// `target` with a bare subresource and one percent-encoded query parameter (e.g. `?legal-hold&versionId=...`).
pub(super) fn subresource_query_target(target: &str, subresource: &str, name: &str, value: &str) -> String {
let mut target = format!("{target}?{subresource}&{name}=");
append_query_value(&mut target, value);
target
}

fn append_query_value(target: &mut String, value: &str) {
for byte in value.bytes() {
if byte.is_ascii_alphanumeric() || matches!(byte, b'-' | b'_' | b'.' | b'~') {
target.push(char::from(byte));
Expand All @@ -188,7 +200,6 @@ pub(super) fn query_target(target: &str, name: &str, value: &str) -> String {
target.push(char::from(hex_digit(byte & 0x0f)));
}
}
target
}

const fn hex_digit(nibble: u8) -> u8 {
Expand Down
Loading