pub struct DataDrivenGenerator;Expand description
Generates k6 JavaScript code for data-driven testing
Implementations§
Source§impl DataDrivenGenerator
impl DataDrivenGenerator
Sourcepub fn generate_imports(file_type: DataFileType) -> String
pub fn generate_imports(file_type: DataFileType) -> String
Generate k6 imports for data-driven testing
Sourcepub fn generate_data_loading(config: &DataDrivenConfig) -> String
pub fn generate_data_loading(config: &DataDrivenConfig) -> String
Generate k6 code to load the data file
Sourcepub fn generate_row_selection(distribution: DataDistribution) -> String
pub fn generate_row_selection(distribution: DataDistribution) -> String
Generate k6 code for row selection based on distribution strategy
Sourcepub fn generate_apply_mappings(mappings: &[DataMapping]) -> String
pub fn generate_apply_mappings(mappings: &[DataMapping]) -> String
Generate k6 code to apply mappings from row data
Sourcepub fn generate_setup(config: &DataDrivenConfig) -> String
pub fn generate_setup(config: &DataDrivenConfig) -> String
Generate complete data-driven test setup code
Sourcepub fn generate_iteration_code(config: &DataDrivenConfig) -> String
pub fn generate_iteration_code(config: &DataDrivenConfig) -> String
Generate code for within the default function
Sourcepub fn generate_per_uri_control_code(config: &DataDrivenConfig) -> String
pub fn generate_per_uri_control_code(config: &DataDrivenConfig) -> String
Generate k6 code for per-URI control mode
This mode allows each row in the CSV/JSON to specify:
- HTTP method (GET, POST, PUT, PATCH, DELETE)
- URI/path to call
- Request body (JSON string)
- Query parameters (JSON string or key=value&key=value format)
- Additional headers (JSON string)
- Attack type for security testing
- Expected status code for validation
Example CSV:
method,uri,body,query_params,headers,attack_type,expected_status
GET,/virtualservice,,include_name=true,,sqli,200
POST,/virtualservice,"{\"name\":\"test-vs\",\"port\":80}",,,,201
PUT,/virtualservice/{uuid},"{\"name\":\"updated-vs\"}",,,,200
DELETE,/virtualservice/{uuid},,,,xss,204Sourcepub fn generate_per_uri_metrics(operations: &[(String, String)]) -> String
pub fn generate_per_uri_metrics(operations: &[(String, String)]) -> String
Generate metrics declarations for per-URI control mode
Sourcepub fn generate_per_uri_control_script(
config: &DataDrivenConfig,
target_url: &str,
custom_headers: &HashMap<String, String>,
skip_tls_verify: bool,
) -> String
pub fn generate_per_uri_control_script( config: &DataDrivenConfig, target_url: &str, custom_headers: &HashMap<String, String>, skip_tls_verify: bool, ) -> String
Generate a complete per-URI control mode script
Auto Trait Implementations§
impl Freeze for DataDrivenGenerator
impl RefUnwindSafe for DataDrivenGenerator
impl Send for DataDrivenGenerator
impl Sync for DataDrivenGenerator
impl Unpin for DataDrivenGenerator
impl UnwindSafe for DataDrivenGenerator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more