apisix-dashboard icon indicating copy to clipboard operation
apisix-dashboard copied to clipboard

make api-test filed

Open JieTrancender opened this issue 6 years ago • 8 comments

Bug report

Describe the bug

I got the newest code of master branch, and then exec make api-test. unfortunate, not pass all test.

How to Reproduce

And this failed test making a dirty data in etcd. image

Screenshots

image

System information

  • OS: [e.g. macOS, Windows]
  • Browser (if applies) [e.g. Chrome, Safari, Edge]
  • Version: [e.g. 2.0-rc3]

Additional context

Add any other context about the problem here.

JieTrancender avatar Dec 02 '20 06:12 JieTrancender

cc @idbeta

juzhiyuan avatar Dec 02 '20 06:12 juzhiyuan

Get more information by adding some log. After the first time to exec make api-test, get a test error. at the same time, dirty data keep in etcd.

TestRoute: route_test.go:396:
        	Error Trace:	route_test.go:396
        	Error:      	Expected nil, but got: &errors.errorString{s:"schema validate failed: script: String length must be greater than or equal to 10"}

image

Then, exec make api-test will repeat this problem. Failure assertion code is: https://github.com/apache/apisix-dashboard/blob/b4ad55d405cb61b97b9147d2924ab8121fa0e406/api/internal/handler/route/route_test.go#L393

The Verified format is so complex, find where making wrong is difficult for me 😬 😬 .

JieTrancender avatar Dec 02 '20 10:12 JieTrancender

I also reproduced in the local environment. @nic-chen

idbeta avatar Dec 02 '20 10:12 idbeta

maybe i know what things happened.

in apisix project script filed used to make lua code by using loadstring function, code in here:

https://github.com/apache/apisix/blob/2472db56c8adbd1495707fffc0e3e4f00a8cab88/apisix/admin/routes.lua#L136-L146

so the type of script is string, schema is script = {type = "string", minLength = 10, maxLength = 102400}. but in this test, script is a object. convert it to go structure, and then make string for lua code. code in here:

https://github.com/apache/apisix-dashboard/blob/c574813eea82edcd6d95a2ea0f8857b736049717/api/internal/handler/route/route.go#L220-L237

answer is clear, the route schema is not suitable. maybe we should use new schema which different from apisix project, but is difficut to maintain in the future, so i think we should keep it consistent.

what do you think?

JieTrancender avatar Dec 05 '20 08:12 JieTrancender

cc @nic-chen @membphis why CI pass?

moonming avatar Dec 05 '20 09:12 moonming

@JieTrancender

Currently, the Manager API relies on Lua and lib dag-to-lua. That's why you run test failed.

please have a look at:

https://github.com/apache/apisix-dashboard/blob/master/.github/workflows/backend-unit-test.yml#L27-L32

and

https://github.com/apache/apisix-dashboard/blob/master/.github/workflows/backend-unit-test.yml#L39-L42

cc @moonming

nic-chen avatar Dec 05 '20 12:12 nic-chen

Developers may not know this tip, FAQ is a good place 😁

juzhiyuan avatar Dec 05 '20 12:12 juzhiyuan

Currently, the Manager API relies on Lua and lib dag-to-lua. That's why you run test failed.

Run make api-test, should check dag-to-lua dependencies, if the dependencies are not installed, we need to download and install.

All of those steps, we'd better write them in Makefile.

membphis avatar Dec 06 '20 13:12 membphis