package awskit-s3-sim

  1. Overview
  2. Docs
In-memory simulator for Awskit S3 tests

Install

dune-project
 Dependency

Authors

Maintainers

Sources

awskit-v0.2.0.tbz
sha256=b69c81378d08f443a276b947d9a2b45913495cb61b2ff3aa0ad74d6b071f32f8
sha512=50714b8eda6ea6e589eb34a305afdfa4870a5e8e4240c091ff5cecd309c21fdfda6163fb6449caad5cdaf800857369df5da0534d822cf152ac76fc16fb9216e5

doc/awskit-s3-sim/Awskit_s3_sim/index.html

Module Awskit_s3_simSource

Deterministic in-memory S3 implementation for tests.

The simulator implements the same synchronous S3 client shape as runtime-backed clients. It stores objects in memory, records operation history, exposes inspection helpers, and supports deterministic fault injection.

module Clock : sig ... end
Sourcetype config = private {
  1. max_list_keys : int;
}

Simulator configuration. max_list_keys caps list-page sizes when the request does not provide a smaller max_keys.

Sourceval config : ?max_list_keys:int -> unit -> (config, Awskit.Error.t) result

Validate and create simulator configuration. max_list_keys must be between 1 and 1000.

Sourceval config_exn : ?max_list_keys:int -> unit -> config

Like config, but raises Awskit.Error.Awskit_error carrying the structured validation error on validation failure.

Sourceval default_config : config

Default simulator configuration.

Sourcetype store

Shared in-memory S3 store. Multiple connections can share one store.

Sourceval create_store : ?config:config -> clock:Clock.t -> unit -> store

Create an empty store using a deterministic clock.

Sourcetype t

Simulator connection handle.

Sourceval connect : store -> credentials:Awskit.Credentials.t -> t

Connect to a store with credentials used by presigning/signing helpers.

Sourceval store : t -> store

Return the underlying shared store.

Sourcemodule Runtime : Awskit_s3.RUNTIME with type 'a t = 'a and type connection = t

Direct-style runtime used by the simulator.

Sourcemodule Body : Awskit_s3.BODY with type 'a io := 'a and type t = Runtime.request_body

In-memory simulator request bodies.

Sourcemodule Reader : Awskit_s3.READER with type 'a io := 'a and type t = Runtime.response_body_reader

In-memory simulator response-body readers.

Sourcetype fault =
  1. | Slow_down
  2. | Internal_error
  3. | Connection_reset
  4. | Response_lost

Deterministic fault kinds that can be injected before operations.

Sourceval inject_fault : t -> fault -> unit

Queue one fault for the next applicable operation. Explicit faults are consumed FIFO.

Sourceval inject_faults : t -> fault list -> unit

Queue several faults in order. Explicit faults are consumed FIFO.

Sourceval clear_faults : t -> unit

Remove queued faults.

Sourceval enable_random_faults : t -> seed:int -> prob:float -> unit

Enable deterministic pseudo-random faults with probability prob.

Sourceval disable_random_faults : t -> unit

Disable random fault injection. Queued explicit faults are unchanged.

Sourcetype operation_record = {
  1. op : [ `Put_object | `Get_object | `Head_object | `Delete_object | `List_objects_v2 | `List_object_versions | `Copy_object | `Delete_objects | `Create_multipart_upload | `Upload_part | `Complete_multipart_upload | `Abort_multipart_upload | `List_parts ];
    (*

    Operation kind.

    *)
  2. bucket : string;
    (*

    Bucket targeted by the operation.

    *)
  3. key : string option;
    (*

    Object key targeted by object/multipart operations.

    *)
  4. timestamp : Ptime.t;
    (*

    Simulated operation time.

    *)
  5. faulted : bool;
    (*

    Whether the operation consumed an injected fault.

    *)
}

Recorded simulator operation.

Sourcetype object_metadata = {
  1. etag : Awskit_s3.Object.Etag.t option;
    (*

    Current object ETag.

    *)
  2. size : int64 option;
    (*

    Current object size in bytes.

    *)
  3. last_modified : Ptime.t option;
    (*

    Current object last-modified timestamp.

    *)
}

Inspectable metadata for the current version of an object.

Sourceval object_metadata : store -> bucket:Awskit_s3.Bucket_name.t -> key:Awskit_s3.Object_key.t -> object_metadata option

Return metadata for the current object version, if present.

Sourceval keys : store -> bucket:Awskit_s3.Bucket_name.t -> string list

Return current object keys in a bucket in lexicographic order.

Sourceval history : store -> operation_record list

Return recorded operations in chronological order.

Sourceval clear_history : store -> unit

Clear recorded operation history.

Sourceval objects_as_strings : store -> bucket:Awskit_s3.Bucket_name.t -> (string * string) list

Return current object bodies as strings in deterministic key order.

Sourcemodule Object : Awskit_s3.OBJECT with type connection := t and type 'a io := 'a and type request_body := Body.t and type response_body_reader := Reader.t

Object operations against the in-memory simulator store.

Sourcemodule Bucket : Awskit_s3.BUCKET with type connection := t and type 'a io := 'a

Bucket operations against the in-memory simulator store.

Sourcemodule Multipart : Awskit_s3.MULTIPART with type connection := t and type 'a io := 'a and type request_body := Body.t

Multipart operations against the in-memory simulator store.

Sourcemodule Presigned : Awskit_s3.PRESIGNED with type connection := t and type 'a io := 'a

Presigned request artifact helpers using the simulator connection's credentials and deterministic clock.