Cant' run tests, ./kong/pdk/init.lua:209: in main chunk

Hi all,

I’m just getting set up with kong for the first time. I’ve written my own plugin and want to run the tests in the spec folder. I’ve checked out kong, lua-resty-core and busted and have them all on the lua path and openresty in the bin path.

If I try run “make test” as per https://github.com/Kong/kong#tests I get this issue

Error → ./kong/pdk/init.lua @ 209
suite spec/01-unit/11-reports_spec.lua
./kong/pdk/init.lua:209: assertion failed!

stack traceback:
./kong/pdk/init.lua:209: in main chunk

Error → spec/01-unit/13-plugins_version_spec.lua @ 7
Plugins lazy_setup
…5.1/kong/plugins/my_custom_plugin/handler.lua:10: attempt to index global ‘kong’ (a nil value)

I’ve been stuck on this a while now and really could use some insight if someone has some. That issue that there’s an error on 209 is an openresty dependency issue but I can confirm is it’s int lua_path and path (bin path)

Not sure it will help but below is the full error when testing

[root@2b5805e7a216 kong]# make test
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●✱●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●✱●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●✱✱✱✱●●●●●●●●●●●✱●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●✱●●●●●●●✱●●●●●●●●●●2019/10/12 22:05:28 [error] 74092#0: *2 [lua] init.lua:1060: post_crud_event(): [db] failed to propagate CRUD operation: nil, context: ngx.timer
2019/10/12 22:05:28 [error] 74092#0: *2 [lua] init.lua:1060: post_crud_event(): [db] failed to propagate CRUD operation: nil, context: ngx.timer
●●●●●●●●●●●●●●●●●●●✱✱●●●●◌●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●✱●●●●●●●●●●●●●●●2019/10/12 22:05:46 [error] 74092#0: *7 lua entry thread aborted: runtime error: /usr/local/share/lua/5.1/resty/dns/balancer/base.lua:1206: attempt to index field ‘lastQuery’ (a nil value)
stack traceback:
coroutine 0:
/usr/local/share/lua/5.1/resty/dns/balancer/base.lua: in function ‘cb_expire’
/usr/local/share/lua/5.1/resty/timer.lua:87: in function </usr/local/share/lua/5.1/resty/timer.lua:51>, context: ngx.timer
●●●●●●●●●●●●●●●●●●●●●●●●●●●✱✱●●●●●●●●●●●●●●●●●
738 successes / 0 failures / 15 errors / 1 pending : 24.196098 seconds

Pending → spec/01-unit/05-utils_spec.lua @ 33
Utils is_valid_uuid() invalidates UUIDs with invalid variants

Error → ./kong/pdk/init.lua @ 209
suite spec/01-unit/01-db/01-schema/02-metaschema_spec.lua
./kong/pdk/init.lua:209: assertion failed!

stack traceback:
./kong/pdk/init.lua:209: in main chunk

Error → spec/01-unit/01-db/01-schema/06-routes_spec.lua @ 250
routes schema paths attribute must dry-run values that are considered regexes
./kong/pdk/init.lua:209: assertion failed!

stack traceback:
./kong/pdk/init.lua:209: in main chunk

Error → ./kong/pdk/init.lua @ 209
suite spec/01-unit/01-db/01-schema/10-migrations_spec.lua
./kong/pdk/init.lua:209: assertion failed!

stack traceback:
./kong/pdk/init.lua:209: in main chunk

Error → ./kong/pdk/init.lua @ 209
suite spec/01-unit/01-db/01-schema/11-declarative_config/01-validate_spec.lua
./kong/pdk/init.lua:209: assertion failed!

stack traceback:
./kong/pdk/init.lua:209: in main chunk

Error → ./kong/pdk/init.lua @ 209
suite spec/01-unit/01-db/01-schema/11-declarative_config/02-process_auto_fields_spec.lua
./kong/pdk/init.lua:209: assertion failed!

stack traceback:
./kong/pdk/init.lua:209: in main chunk

Error → ./kong/pdk/init.lua @ 209
suite spec/01-unit/01-db/01-schema/11-declarative_config/03-flatten_spec.lua
./kong/pdk/init.lua:209: assertion failed!

stack traceback:
./kong/pdk/init.lua:209: in main chunk

Error → ./kong/pdk/init.lua @ 209
suite spec/01-unit/01-db/02-db-errors_spec.lua
./kong/pdk/init.lua:209: assertion failed!

stack traceback:
./kong/pdk/init.lua:209: in main chunk

Error → ./kong/pdk/init.lua @ 209
suite spec/01-unit/01-db/05-cassandra_spec.lua
./kong/pdk/init.lua:209: assertion failed!

stack traceback:
./kong/pdk/init.lua:209: in main chunk

Error → ./kong/pdk/init.lua @ 209
suite spec/01-unit/01-db/07-dao/01-plugins_spec.lua
./kong/pdk/init.lua:209: assertion failed!

stack traceback:
./kong/pdk/init.lua:209: in main chunk

Error → ./kong/pdk/init.lua @ 209
suite spec/01-unit/03-conf_loader_spec.lua
./kong/pdk/init.lua:209: assertion failed!

stack traceback:
./kong/pdk/init.lua:209: in main chunk

Error → ./kong/pdk/init.lua @ 209
suite spec/01-unit/04-prefix_handler_spec.lua
./kong/pdk/init.lua:209: assertion failed!

stack traceback:
./kong/pdk/init.lua:209: in main chunk

Error → spec/01-unit/08-router_spec.lua @ 2550
Router has_capturing_groups()
./kong/pdk/init.lua:209: assertion failed!

stack traceback:
./kong/pdk/init.lua:209: in main chunk

Error → ./kong/pdk/init.lua @ 209
suite spec/01-unit/10-log_serializer_spec.lua
./kong/pdk/init.lua:209: assertion failed!

stack traceback:
./kong/pdk/init.lua:209: in main chunk

Error → ./kong/pdk/init.lua @ 209
suite spec/01-unit/11-reports_spec.lua
./kong/pdk/init.lua:209: assertion failed!

stack traceback:
./kong/pdk/init.lua:209: in main chunk

Error → spec/01-unit/13-plugins_version_spec.lua @ 7
Plugins lazy_setup
…5.1/kong/plugins/my-custom-plugin/handler.lua:10: attempt to index global ‘kong’ (a nil value)

stack traceback:
…5.1/kong/plugins/my-custom-plugin/handler.lua:10: in main chunk

make: *** [test] Error 1

You might be running into some weirdness with mismatched Kong and OpenResty versions. For instance, Kong 1.3 currently requires openresty 1.15.8.1 with Kong’s OpenResty patches applied. Also, the following comment:

attempt to index global ‘kong’

Suggests something might be going wrong with your lua path, such that it isn’t picking up init.lua within the kong/ directory of the repo. I wonder if they who wrote the instructions for this unit tests have ./ and ./?/init.lua as part of their lua path implicitly?


© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ