601 Commits

Author SHA1 Message Date
Frank Schmid
39caddc404
Merge pull request #4713 from erikerikson/fix-4687-cyclic-variable-dependencies
Eliminate/Report Hung Promises (#4687), Prepopulate Stage and Region (#4311), Handle Quoted Strings (#4734)
2018-02-20 13:56:27 +01:00
Erik Erikson
ffc7686465 fix pending promise test bugs 2018-02-16 18:46:28 -08:00
Erik Erikson
91f50f6918 add 'use strict' for node 4.x and 5.x 2018-02-16 17:26:40 -08:00
Erik Erikson
4400ffc9e4 fix #4311 & #4734, separate PromiseTracker, minutiae
#4311
  see prepopulateService - attempts to pre-populate the region and stage settings necessary for making a request to AWS, rejecting and dependencies thereon it runs into during that process
  see the `deep` variable work.  this was a knock-on effect of providing pre-population.  it actually represents an obscure class of bugs where the recursive population previously in getDeepValue caused the caller not to be in charge of population choices (thus fixing for pre-population) but also caused potential deadlocks resulting from getDeepValue creating circular dependencies.

#4734
  see splitByComma - a regex to do the splitting but ignore quoted commas was getting very deep and involved.  Instead, identify quoted string boundaries, then identify commas (including white space around them) and take those commas not contained by quotes as the locations for splitting the given string.  Trim the string as well (removing leading and trailing white space).
  add sophistication to the overwrite syntax, allowing for whitespace and repetitions (for robustness)
  add sophistication to the string ref syntax, allowing for use in identifying multiple quoted strings in a variable (i.e. for overwrites)

#NotCreated
  fix a bug I created earlier in the branch that caused reporting to be less informative (see renderMatches)

separate PromiseTracker
  move this class into its own file for the purpose of increasing testability and offering reuse

minutiae
  filter the properties given to populateVariables so as to avoid attempting resolution on non-variables.  Efficiency and noise reduction change.  Also cleans up the code (e.g. see populateObject and its use)
  cleaning of overwrite as a side effect
  offer variable cleaning as a idiom
  reorder the Variables.js `require`s to be in alphabetical order
2018-02-16 17:13:03 -08:00
Erik Erikson
3606589ff2 Do not double-reject errors
Calling .then here creates a new promise.  One that is not returned and generating a rejection within that promise can lead to unhandledRejection events being inappropriately raised.
As such, don't declare unneeded variables.
2018-02-06 16:35:16 -08:00
Erik Erikson
8f69678a88 remove .only from describe for Variables tests
add expected rejection message
2018-02-03 13:14:11 -08:00
Erik Erikson
c18eb70a28 Eliminate Deadlocks, Report Hung Promises (#4687)
Add a "PromiseTracker" to the Variables class.  It provides tracking and reporting of pending variable resolutions during service populations.
Decompose populateObject and populateProperty into smaller pieces that are easier to understand.
Additionally, remove the immediate recursive resolution of variables, recursing only at the Object or Property entry point (when changes have been made).  This avoids a problem where the resolved value, prior to being replaced in the containing object or value refers to itself and thereby is waiting on its own resolution before it will resolve itself.
Return the given value in warnIfNotFound so that it can chain.
2018-02-02 19:29:19 -08:00
Alexey Kotlyarov
d5dc0cbf4b Do not explicitly color messages in white
On white background terminals, white text is unreadable. Use the default
terminal color instead.

Fixes #4673
2018-01-29 19:33:35 +11:00
Craig R Webster
271b45009d Fix typo in 'syntax' 2018-01-03 19:15:41 +08:00
Takahiro Horike
ba979a7a8f
Merge pull request #4590 from 8bites/master
Add support of serverless.js configuration file
2017-12-22 11:23:05 +09:00
Pavel Vlasov
d05e45668e validate serverless.js to export plain object + address feedback 2017-12-20 08:50:10 +11:00
Pavel Vlasov
ea7c6620af fix eslint 2017-12-19 20:35:07 +11:00
Pavel Vlasov
bca4da55b3 add support for serverless.js 2017-12-19 20:14:39 +11:00
horike37
4a3e140dc2 update code to synchronous 2017-12-19 01:10:43 +09:00
horike37
fbce5ed4ae add suggestion feature 2017-12-17 15:13:20 +09:00
horike37
0cf7c9a329 first commit 2017-12-16 20:27:33 +09:00
horike37
355bfa01c0 fix the plugin commands bug 2017-12-12 05:05:00 +09:00
Frank Schmid
81c896bc12
Removed reintroduction of stage+region in request. Added options.
Delete bucket was still using them

Hopefully all :)

Further test fixes.

.... worked too long yesterday

Fixed Variable tests

Remove not used parameters from request() and add options with warning
2017-12-11 12:33:35 +01:00
Erik Erikson
df5dc28961 add tests to get to 100% line coverage
1. add tests that validate string value defaults in overrides.
2. add test of behavior when a javascript's export does not contain the attribute declared in the variable.
3. add tests of behavior when an SSM parameter is not found and the request to the SSM service fails.

add returns to tests that weren't returning their promises (and were thereby risking false positives.
2017-12-08 00:53:58 -08:00
Erik Erikson
32e660d94c add tests to validate that nested variables inside overwrites are resolved 2017-12-07 12:49:09 -08:00
Erik Erikson
6a0784ce2f add now passing "populate once" tests, use populate over render 2017-12-06 16:48:54 -08:00
Erik Erikson
c8ebe25968 fix build by adding `'use strict'; to generated 'async.load.js' 2017-12-06 16:38:51 -08:00
Erik Erikson
d6abd689b6 fix migrated tests 2017-12-06 16:20:17 -08:00
Erik Erikson
8c1fe6dfcc Refactor, simplify, correct, add tests
Increase name consistency
Improve names to be-what-they-are
Reduce cyclomatic complexity
Include overrides population fix
Add variable methods documentation
Add more tests around significant variable patterns/risky cases
2017-12-06 15:59:07 -08:00
Frank Schmid
bce1264d7b
Fixed merge 2017-12-07 00:35:13 +01:00
Frank Schmid
8f70c13a9c
Merge branch 'master' into circular-vars 2017-12-07 00:22:55 +01:00
Frank Schmid
2e09606f13
Merge remote-tracking branch 'remotes/upstream/master' into circular-vars 2017-12-06 13:20:51 +01:00
Frank Schmid
8ff661835e
Merge branch 'master' into populate-default-objects 2017-12-06 12:34:50 +01:00
Erik Erikson
dea94bc310 Add significant variable usage corner cases 2017-12-05 14:31:00 -08:00
Frank Schmid
8cd604cd41
Wrap cached value into promise (addresses issue mentioned in #4509) 2017-12-05 12:39:48 +01:00
Frank Schmid
5526802a1b
Added request cache and queue to AWS provider
Make sure that requests are throttled. Use a queue for the requests.

Added new expected parameter to request() call in variables test

Added request cache tests
Check that request is indeed called 1000 times

Cache promises, not values

Use request cache for AWS variable requests

Use fromCallback instead of "new Promise" anti-pattern.

Added request cache to AWS provider
2017-12-05 12:39:39 +01:00
Frank Schmid
37340467ed
Populate objects if default syntax targets an object 2017-12-04 18:08:39 +01:00
e-e-e
f90c6d2782 return resolver promise; fix lint 2017-12-03 21:25:22 +11:00
e-e-e
57d898d39e replace promise in cache with cached result once resolved. 2017-12-02 12:03:33 +11:00
Benjamin Forster
fae0ccb1d7 update variable name in test to be more descriptive 2017-12-01 10:40:23 +11:00
Benjamin Forster
6e6fea3fa2 update ssm cache to generic variable cache. 2017-12-01 10:33:30 +11:00
Benjamin Forster
382f6900e0 update test to show that cache is working 2017-11-30 10:08:23 +11:00
Benjamin Forster
33b666c431 add test 2017-11-29 17:49:52 +11:00
Benjamin Forster
e780a59b66 fix linter 2017-11-29 17:21:41 +11:00
Benjamin Forster
de22ae698b add cache to ssm variables 2017-11-29 17:10:05 +11:00
Erik Erikson
143a2aa65b Account for duplicate copies without populating more than once. As a result, populate in place. 2017-11-17 17:30:15 -08:00
Frank Schmid
e823679340 Fixed package-lock and unit tests after rebase (conflicts) 2017-11-17 00:17:28 +01:00
Philipp Muens
9fd1c457d6 Fix stub setups and teardowns in tests 2017-11-17 00:04:21 +01:00
Eslam A. Hefnawy
535f425344 added tests 2017-11-17 00:00:58 +01:00
Eslam A. Hefnawy
bebcdf3057 added support for circular references in variable system 2017-11-17 00:00:57 +01:00
horike37
0bb444ac76 minor tweak 2017-11-09 01:27:09 +09:00
horike37
dbe02ab0e8 Merge branch 'master' of github.com:serverless/serverless 2017-11-08 10:30:50 +09:00
Frank Schmid
5744a08a91 Fixed #getValueFromFile():should work for absolute paths with ~ unit test 2017-11-07 12:21:06 +01:00
Frank Schmid
3e826ef598 Reworked remaining variable tests to use sinon chai notation 2017-11-07 11:49:07 +01:00
horike37
9cb43195be add test if symlink works 2017-11-07 09:36:20 +09:00