aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlex Shatov <alexs@att.com>2018-05-07 14:51:18 -0400
committerAlex Shatov <alexs@att.com>2018-05-07 14:51:18 -0400
commitd1195c61ca01888d8752a84a2c008719b24b6ba5 (patch)
treeaf4782921f02a850590b3ac19f425f3736797756 /tests
parenta46339420faefc49cb48adf2989a0884ff961278 (diff)
fixed 413 "request entity too large" for /policy
- increased the message limit to 150mb on policy-update API to avoid 413 on catchup messages from policy-handler - external version 2.1.3, internal version 4.4.3 - unit test code coverage Statements : 84% ( 940/1119 ) Branches : 62.75% ( 320/510 ) Functions : 81.15% ( 155/191 ) Lines : 84.15% ( 929/1104 ) Change-Id: Iafd27b37fde6b0a310f2ba805f505f380b58ec1f Signed-off-by: Alex Shatov <alexs@att.com> Issue-ID: DCAEGEN2-491
Diffstat (limited to 'tests')
-rw-r--r--tests/test_policy.js76
1 files changed, 35 insertions, 41 deletions
diff --git a/tests/test_policy.js b/tests/test_policy.js
index 86d6ab4..0d7550e 100644
--- a/tests/test_policy.js
+++ b/tests/test_policy.js
@@ -88,6 +88,14 @@ function create_policy(policy_id, policy_version=1, matching_conditions=null) {
};
}
+const message_catch_up = {
+ "errored_scopes": [],
+ "catch_up": true,
+ "scope_prefixes": ["DCAE_alex.Config_", "DCAE.Config_"],
+ "errored_policies": {},
+ "latest_policies": {}
+};
+
const cloudify_node_instances = [
{
"deployment_id": DEPLOYMENT_ID,
@@ -239,22 +247,18 @@ function test_get_policy_components(dh_server) {
function test_post_policy_catch_up(dh_server) {
const req_path = "/policy";
- const message = {
- "errored_scopes": ["CLAMP.Config_"],
- "catch_up": true,
- "scope_prefixes": ["DCAE_alex.Config_", "DCAE.Config_"],
- "errored_policies": {},
- "latest_policies": {
- [MONKEYED_POLICY_ID]: create_policy(MONKEYED_POLICY_ID, 55),
- [MONKEYED_POLICY_ID_2]: create_policy(MONKEYED_POLICY_ID_2, 22, {"key1": "value1"}),
- [MONKEYED_POLICY_ID_4]: create_policy(MONKEYED_POLICY_ID_4, 77, {"service": "alex_service"}),
- [MONKEYED_POLICY_ID_5]: create_policy(MONKEYED_POLICY_ID_5, "nan_version"),
- [MONKEYED_POLICY_ID_6]: create_policy(MONKEYED_POLICY_ID_6, 66),
- "junk_policy": create_policy("junk_policy", "nan_version"),
- "fail_filtered": create_policy("fail_filtered", 12, {"ONAPName": "not-match"}),
- "fail_filtered_2": create_policy("fail_filtered_2", 32, {"ConfigName": "not-match2"}),
- "": create_policy("", 1)
- }
+ const message = JSON.parse(JSON.stringify(message_catch_up));
+ message.errored_scopes = ["CLAMP.Config_"];
+ message.latest_policies = {
+ [MONKEYED_POLICY_ID]: create_policy(MONKEYED_POLICY_ID, 55),
+ [MONKEYED_POLICY_ID_2]: create_policy(MONKEYED_POLICY_ID_2, 22, {"key1": "value1"}),
+ [MONKEYED_POLICY_ID_4]: create_policy(MONKEYED_POLICY_ID_4, 77, {"service": "alex_service"}),
+ [MONKEYED_POLICY_ID_5]: create_policy(MONKEYED_POLICY_ID_5, "nan_version"),
+ [MONKEYED_POLICY_ID_6]: create_policy(MONKEYED_POLICY_ID_6, 66),
+ "junk_policy": create_policy("junk_policy", "nan_version"),
+ "fail_filtered": create_policy("fail_filtered", 12, {"ONAPName": "not-match"}),
+ "fail_filtered_2": create_policy("fail_filtered_2", 32, {"ConfigName": "not-match2"}),
+ "": create_policy("", 1)
};
const test_txt = "POST " + req_path + " - catchup " + JSON.stringify(message);
describe(test_txt, () => {
@@ -306,6 +310,11 @@ function test_post_policy_catch_up(dh_server) {
return JSON.stringify(resp_to_exe);
});
+ for (var extra_i = 1; extra_i <= 100000; extra_i++) {
+ const policy_id = "extra_" + extra_i;
+ message.latest_policies[policy_id] = create_policy(policy_id, extra_i);
+ }
+
return chai.request(dh_server.app).post(req_path)
.set('content-type', 'application/json')
.set('X-ECOMP-RequestID', 'test_post_policy_catch_up')
@@ -324,20 +333,15 @@ function test_post_policy_catch_up(dh_server) {
console.error(action_timer.step, "err for", test_txt, err);
throw err;
});
- }).timeout(30000);
+ }).timeout(60000);
});
}
function test_fail_cfy_policy_catch_up(dh_server) {
const req_path = "/policy";
- const message = {
- "errored_scopes": [],
- "catch_up": true,
- "scope_prefixes": ["DCAE_alex.Config_", "DCAE.Config_"],
- "errored_policies": {},
- "latest_policies": {
- [MONKEYED_POLICY_ID_6]: create_policy(MONKEYED_POLICY_ID_6, 66)
- }
+ const message = JSON.parse(JSON.stringify(message_catch_up));
+ message.latest_policies = {
+ [MONKEYED_POLICY_ID_6]: create_policy(MONKEYED_POLICY_ID_6, 66)
};
const test_txt = "fail POST " + req_path + " - catchup without execution_id " + JSON.stringify(message);
describe(test_txt, () => {
@@ -384,14 +388,9 @@ function test_fail_cfy_policy_catch_up(dh_server) {
function test_fail_400_cfy_policy_catch_up(dh_server) {
const req_path = "/policy";
- const message = {
- "errored_scopes": [],
- "catch_up": true,
- "scope_prefixes": ["DCAE_alex.Config_", "DCAE.Config_"],
- "errored_policies": {},
- "latest_policies": {
- [MONKEYED_POLICY_ID_6]: create_policy(MONKEYED_POLICY_ID_6, 66)
- }
+ const message = JSON.parse(JSON.stringify(message_catch_up));
+ message.latest_policies = {
+ [MONKEYED_POLICY_ID_6]: create_policy(MONKEYED_POLICY_ID_6, 66)
};
const test_txt = "fail 400 POST " + req_path + " - existing_running_execution_error " + JSON.stringify(message);
describe(test_txt, () => {
@@ -433,14 +432,9 @@ function test_fail_400_cfy_policy_catch_up(dh_server) {
function test_fail_404_cfy_policy_catch_up(dh_server) {
const req_path = "/policy";
- const message = {
- "errored_scopes": [],
- "catch_up": true,
- "scope_prefixes": ["DCAE_alex.Config_", "DCAE.Config_"],
- "errored_policies": {},
- "latest_policies": {
- [MONKEYED_POLICY_ID_6]: create_policy(MONKEYED_POLICY_ID_6, 66)
- }
+ const message = JSON.parse(JSON.stringify(message_catch_up));
+ message.latest_policies = {
+ [MONKEYED_POLICY_ID_6]: create_policy(MONKEYED_POLICY_ID_6, 66)
};
const test_txt = "fail 404 POST " + req_path + " - not_found_error " + JSON.stringify(message);
describe(test_txt, () => {