diff options
author | Alex Shatov <alexs@att.com> | 2018-05-07 14:51:18 -0400 |
---|---|---|
committer | Alex Shatov <alexs@att.com> | 2018-05-07 14:51:18 -0400 |
commit | d1195c61ca01888d8752a84a2c008719b24b6ba5 (patch) | |
tree | af4782921f02a850590b3ac19f425f3736797756 | |
parent | a46339420faefc49cb48adf2989a0884ff961278 (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
-rw-r--r-- | lib/policy.js | 2 | ||||
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | pom.xml | 2 | ||||
-rw-r--r-- | tests/test_policy.js | 76 | ||||
-rw-r--r-- | version.properties | 2 |
5 files changed, 39 insertions, 45 deletions
diff --git a/lib/policy.js b/lib/policy.js index 4a3248d..1aefc8a 100644 --- a/lib/policy.js +++ b/lib/policy.js @@ -349,7 +349,7 @@ const app = require('express')(); app.set('x-powered-by', false); app.set('etag', false); app.use(require('./middleware').checkType('application/json')); -app.use(require('body-parser').json({strict: true})); +app.use(require('body-parser').json({strict: true, limit: '150mb'})); app.use(function(req, res, next) { logger.info(req.dcaeReqId, "new req: " + req.method + " " + req.originalUrl + diff --git a/package.json b/package.json index 60061c3..7cd05ce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "onap-dcae-deployment-handler", - "version": "4.4.2", + "version": "4.4.3", "description": "ONAP DCAE Deployment Handler", "main": "deployment-handler.js", "dependencies": { @@ -29,7 +29,7 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property. <groupId>org.onap.dcaegen2.platform</groupId> <artifactId>deployment-handler</artifactId> <name>dcaegen2-platform-deployment-handler</name> - <version>2.1.2-SNAPSHOT</version> + <version>2.1.3-SNAPSHOT</version> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 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, () => { diff --git a/version.properties b/version.properties index 56a8b6d..796f86d 100644 --- a/version.properties +++ b/version.properties @@ -1,6 +1,6 @@ major=2
minor=1
-patch=2
+patch=3
base_version=${major}.${minor}.${patch}
release_version=${base_version}
snapshot_version=${base_version}-SNAPSHOT
|