Skip to content

Commit

Permalink
improved internal apitest, added parallel test cases; see #74105
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Hempel committed Nov 13, 2024
1 parent fb00969 commit 8763f5f
Show file tree
Hide file tree
Showing 23 changed files with 301 additions and 189 deletions.
10 changes: 5 additions & 5 deletions apitest/insert_multi_cs_image.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[
{
"name": "POST /api/v1/db/cs_image",
"name": "POST /api/v1/db/cs_image ({{ datastore `n_single_objects` }} objects in one request)",
"request": {
"body": [
{{ range $idx, $v := N ( datastore "n_single_objects" ) }}
{{ range $idx, $v := N ( datastore `n_single_objects` ) }}
{{ if gt $idx 0 }}, {{ end }}
{
"_mask": "cs_image__all_fields",
Expand All @@ -26,17 +26,17 @@
"order_matters": true
},
"body": [
{{ range $idx, $v := N ( datastore "n_single_objects" ) }}
{{ range $idx, $v := N ( datastore `n_single_objects` ) }}
{{ if gt $idx 0 }}, {{ end }}
{
"cs_image": {
"name:control": {
"starts_with": "HU0",
"ends_with": "0{{ add ( add $idx 1 ) ( datastore "n_single_objects" ) }}"
"ends_with": "0{{ add ( add $idx 1 ) ( datastore `n_single_objects` ) }}"
},
"description:control": {
"starts_with": "DESC: #30",
"ends_with": "{{ add ( add $idx 1 ) ( datastore "n_single_objects" ) }}"
"ends_with": "{{ add ( add $idx 1 ) ( datastore `n_single_objects` ) }}"
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions apitest/insert_single_cs_image.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{{ range $idx, $v := N ( datastore "n_single_objects" ) }}
{{ range $idx, $v := N ( datastore `n_single_objects` ) }}
{
"name": "POST /api/v1/db/cs_image",
"name": "POST /api/v1/db/cs_image (#{{ $idx }})",
"request": {
"body": [
{
Expand Down Expand Up @@ -36,7 +36,7 @@
],
"statuscode": 200
},
"store_response_qjson": {
"store_response_gjson": {
"cs_image_id_{{ $idx }}": "body.0.cs_image._id",
"cs_image_version_{{ $idx }}": "body.0.cs_image._version"
}
Expand Down
37 changes: 37 additions & 0 deletions apitest/insert_single_cs_image_parallel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[
{
"name": "POST /api/v1/db/cs_image ({{ datastore `n_single_objects` }} parallel object uploads)",
"request": {
"body": [
{
"_mask": "cs_image__all_fields",
"_objecttype": "cs_image",
"cs_image": {
"_version": 1,
"name": null
}
}
],
"endpoint": "db/cs_image",
"method": "POST",
"query_params": {
"format": "long"
}
},
"response": {
"body": [
{
"cs_image": {
"name:control": {
"match": "HU0+\\d"
},
"description:control": {
"match": "DESC: #30\\d+"
}
}
}
],
"statuscode": 200
}
}
]
24 changes: 23 additions & 1 deletion apitest/manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
//////////////////////////////////////////////////////
// //
// This apitest only works if plugin zip exists at //
// ../../build/fylr-plugin-sequence.zip //
// //
// Run `make zip` before running apitest //
// //
//////////////////////////////////////////////////////

{{ $n_objects := 5 }}

{
"name": "fylr-plugin-sequence",
"header_from_store": {
Expand All @@ -12,20 +23,31 @@
{
"store": {
"as_root": true,
"n_single_objects": 3
"n_single_objects": {{ $n_objects }}
}
}

// single editor instance saves objects
, "@setup/all.json"
, "@testcases.json"

// parallel saving of objects
, "@setup/all.json"
, "{{ $n_objects }}@insert_single_cs_image_parallel.json"

// tests with test user account with minimal objecttype permissions
, {
"store": {
"as_root": false
}
}

// single editor instance saves objects
, "@setup/all.json"
, "@testcases.json"

// parallel saving of objects
, "@setup/all.json"
, "{{ $n_objects }}@insert_single_cs_image_parallel.json"
]
}
6 changes: 6 additions & 0 deletions apitest/plugin/all.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
"@put_zip.json",
"@wait_for_zip_done.json",
"@plugin_init.json",
"@enable_plugin.json"
]
18 changes: 18 additions & 0 deletions apitest/plugin/enable_plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"name": "enable fylr-plugin-sequence plugin",
"request": {
"endpoint": "plugin/manage/{{ datastore `plugin_id` }}",
"method": "POST",
"body": {
"id": {{ datastore `plugin_id` }},
"enabled": true
}
},
"response": {
"body": {
"enabled": true
}
}
}
]
31 changes: 31 additions & 0 deletions apitest/plugin/plugin_init.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[
{
"name": "PUT /api/v1/plugin/manage",
"request": {
"body": {
"type": "zip",
"url": "",
"zip_file": {
"_id": {{ datastore `plugin_zip_id` }},
"preferred": true
}
},
"endpoint": "plugin/manage",
"method": "PUT"
},
"response": {
"body": {
"id:control": {
"is_number": true
},
"zip_file": {
"_id": {{ datastore `plugin_zip_id` }}
}
},
"statuscode": 200
},
"store_response_gjson": {
"plugin_id": "body.id"
}
}
]
27 changes: 27 additions & 0 deletions apitest/plugin/put_zip.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[
{
"name": "post build/easydb-plugin-sequence.zip to eas/put",
"request": {
"body": {
"file": "@../../build/fylr-plugin-sequence.zip"
},
"body_type": "multipart",
"endpoint": "eas/put",
"method": "POST",
"query_params": {
"produce_versions": "[false]"
}
},
"response": {
"statuscode": 200,
"body": [
{
"extension": "zip"
}
]
},
"store_response_gjson": {
"plugin_zip_id": "body.0._id"
}
}
]
26 changes: 26 additions & 0 deletions apitest/plugin/wait_for_zip_done.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[
{
"name": "GET /api/v1/eas",
"request": {
"endpoint": "eas",
"method": "GET",
"query_params": {
"format": "standard",
"ids": "[{{ datastore `plugin_zip_id` }}]"
}
},
"response": {
"statuscode": 200,
"body": {
"{{ datastore `plugin_zip_id` }}": {
"_id": {{ datastore `plugin_zip_id` }},
"status": "done",
"extension": "zip",
"is_original": true
}
}
},
"timeout_ms": 60000,
"delay_ms": 1000
}
]
6 changes: 3 additions & 3 deletions apitest/setup/POST_datamodel.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"endpoint": "schema/user/HEAD",
"method": "POST",
"body": {{ datastore "setup_datamodel" | qjson "schema" }}
"body": {{ datastore "setup_datamodel" | gjson "schema" }}
}
}
,{
Expand All @@ -18,7 +18,7 @@
},
"endpoint": "mask/HEAD",
"method": "POST",
"body": {{ datastore "setup_datamodel" | qjson "mask" }}
"body": {{ datastore "setup_datamodel" | gjson "mask" }}
}
}
,{
Expand All @@ -29,7 +29,7 @@
},
"endpoint": "l10n/user/HEAD",
"method": "POST",
"body": {{ datastore "setup_datamodel" | qjson "keys" }}
"body": {{ datastore "setup_datamodel" | gjson "keys" }}
}
}
]
4 changes: 2 additions & 2 deletions apitest/setup/all.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
// get settings again, after purge we have a new db instance id
,"@get_settings.json"
,"@root_session.json"
,"@post_config.json"
,"@POST_datamodel_commit.json"
,"@plugin_init.json"
,"@../plugin/all.json"
,"@post_config.json"
{{ if not (datastore `as_root`) }}
,"@create_testuser.json"
,"@update_objecttype_permissions.json"
Expand Down
14 changes: 7 additions & 7 deletions apitest/setup/base-config-fylr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
"plugin": {
"fylr-plugin-sequence": {
"config": {
"fylr-plugin-sequence.insert_sequence.objecttypes": {
"objecttype_settings": [
"sequence": {
"objecttype": "sequence",
"ref_field": "sequence.reference",
"num_field": "sequence.number"
},
"objecttypes": {
"sequence_settings": [
{
"enabled": true,
"update_objecttype": "cs_image",
Expand All @@ -28,11 +33,6 @@
"only_insert": true
}
]
},
"fylr-plugin-sequence.insert_sequence.sequence": {
"sequence_objecttype": "sequence",
"sequence_ref_field": "sequence.reference",
"sequence_num_field": "sequence.number"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion apitest/setup/create_testuser.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"response": {
"statuscode": 200
},
"store_response_qjson": {
"store_response_gjson": {
"testuser_id": "body.0.user._id"
}
}
22 changes: 0 additions & 22 deletions apitest/setup/enable_fylr_example_plugin.json

This file was deleted.

Loading

0 comments on commit 8763f5f

Please sign in to comment.