apisix-ingress-controller icon indicating copy to clipboard operation
apisix-ingress-controller copied to clipboard

Add e2e test cases for plugins

Open tokers opened this issue 4 years ago • 27 comments

Issue description

We don't cover plugins in e2e test suites, although we support them already. Here I want to initiate a plan to add test cases for most of all plugins in Apache APISIX.

If you're interested in writing some test cases for several plugins, please writing comments like:

I'd like to write e2e test cases for plugin "fault-injection".

Then, I'll create a dedicated issue and assign it to you. After the PR is merged, the checkbox in this description will be clicked.

Test case samples are here:

  • https://github.com/apache/apisix-ingress-controller/blob/2486c0f5cce43c3554d61b88f2aa97db35e6c70c/test/e2e/plugins/fault_injection.go
  • https://github.com/apache/apisix-ingress-controller/blob/2486c0f5cce43c3554d61b88f2aa97db35e6c70c/test/e2e/plugins/redirect.go

You may have to learn some usages about ginkgo.

A test case should be a complete e2e case, it contains the configuration create/update/delete on "control plane" (in our case is applying k8s resources like ApisixRoute, ApisixUpstream to Kubernetes), then waiting for it to be effective, and sending requests to "data plane" (APISIX), asserting the response is valid.

When you want to run these cases on your local environment, be sure a Kubernetes cluster is installed, you can create a kubernetes cluster with minikube or kind.

You may try to push images in advance or your cases might be timed out when first run. Related images are:

  • apache/apisix-ingress-controller:dev
  • apache/apisix:dev
  • bitnami/etcd:3.4.14-debian-10-r0
  • kennethreitz/httpbin

You can change the Describe or It block in your case to FDescribe or FIt so only these cases will be run when you executing make e2e-test directive. By default make e2e-test will build apisix-ingress-controller from scratch, you can add E2E_SKIP_BUILD=1 to skip this step, and using E2E_CONCURRENCY to control the concurrency of cases.

tokers avatar Mar 29 '21 09:03 tokers

Great Job ~

gxthrj avatar Mar 29 '21 09:03 gxthrj

Great Job ~

gxthrj avatar Mar 29 '21 09:03 gxthrj

I'd like to write e2e test cases for plugin "key-auth".

Firstsawyou avatar Apr 06 '21 14:04 Firstsawyou

I'd like to write e2e test cases for plugin "key-auth".

any update?

juzhiyuan avatar Apr 08 '21 04:04 juzhiyuan

I'd like to write e2e test cases for plugin "key-auth".

any update?

Currently, there is no configuration that supports the consumer object. I need to wait for the consumer configuration to be supported before submitting this test.

Firstsawyou avatar Apr 10 '21 10:04 Firstsawyou

I'd like to write e2e test cases for plugin "referer-restriction".

Firstsawyou avatar Apr 12 '21 08:04 Firstsawyou

I'd like to write e2e test cases for plugin "server-info".

fhuzero avatar Apr 18 '21 16:04 fhuzero

Help needed: is there any way to run test cases for just one plugin? I want to run test cases I wrote for plugin "server-info". Modifying ginkgo command under PHONY e2e-test in Makefile seems to have no effect, ginkgo still runs all test cases.

fhuzero avatar Apr 23 '21 07:04 fhuzero

Help needed: is there any way to run test cases for just one plugin? I want to run test cases I wrote for plugin "server-info". Modifying ginkgo command under PHONY e2e-test in Makefile seems to have no effect, ginkgo still runs all test cases.

Yep, please read the issue description.

tokers avatar Apr 23 '21 09:04 tokers

Thanks for your reply!

Help needed: is there any way to run test cases for just one plugin? I want to run test cases I wrote for plugin "server-info". Modifying ginkgo command under PHONY e2e-test in Makefile seems to have no effect, ginkgo still runs all test cases.

Yep, please read the issue description.

Thanks! It's done by changing Describe to FDescribe. Sorry for not examining the issue description carefully. Just went through a hard time configuring the environment.

fhuzero avatar Apr 23 '21 11:04 fhuzero

Thanks for your reply!

Help needed: is there any way to run test cases for just one plugin? I want to run test cases I wrote for plugin "server-info". Modifying ginkgo command under PHONY e2e-test in Makefile seems to have no effect, ginkgo still runs all test cases.

Yep, please read the issue description.

Thanks! It's done by changing Describe to FDescribe. Sorry for not examining the issue description carefully. Just went through a hard time configuring the environment.

Feel free to ask any questions here.

tokers avatar Apr 24 '21 04:04 tokers

Now I have a workable version for "server-info" test cases. But as for implementation details and how the test is done I would like to raise some questions for discussion. Shall we create a dedicated issue for "server-info" plugin test cases or I just start a PR so we can discuss in that PR?

fhuzero avatar Apr 25 '21 15:04 fhuzero

Now I have a workable version for "server-info" test cases. But as for implementation details and how the test is done I would like to

raise some questions for discussion. Shall we create a dedicated issue for "server-info" plugin test cases or I just start a PR so we can discuss in that PR?

I think so, you can go ahead and create it.

tokers avatar Apr 26 '21 00:04 tokers

Now I have a workable version for "server-info" test cases. But as for implementation details and how the test is done I would like to raise some questions for discussion. Shall we create a dedicated issue for "server-info" plugin test cases or I just start a PR so we can discuss in that PR?

Merged #406 , thanks!

tokers avatar May 12 '21 10:05 tokers

I'd like to write e2e test cases for plugin "prometheus"

Belyenochi avatar Feb 17 '22 10:02 Belyenochi

@Belyenochi Thanks! We currently have it covered. But in the latest APISIX the Prometheus plugin needs to be exposed using the public-api plugin, it would be great if you could modify this part.

tao12345666333 avatar Feb 17 '22 17:02 tao12345666333

@Belyenochi Thanks! We currently have it covered. But in the latest APISIX the Prometheus plugin needs to be exposed using the public-api plugin, it would be great if you could modify this part.

OK, I'm willing to help and I'll check the documentation of the public-api plugin.

Belyenochi avatar Feb 18 '22 05:02 Belyenochi

@Belyenochi Thanks! We currently have it covered. But in the latest APISIX the Prometheus plugin needs to be exposed using the public-api plugin, it would be great if you could modify this part.

OK, I'm willing to help and I'll check the documentation of the public-api plugin.

FYI https://github.com/apache/apisix/issues/6276#issuecomment-1034431045

tao12345666333 avatar Feb 18 '22 07:02 tao12345666333

@Belyenochi Thanks! We currently have it covered. But in the latest APISIX the Prometheus plugin needs to be exposed using the public-api plugin, it would be great if you could modify this part.

OK, I'm willing to help and I'll check the documentation of the public-api plugin.

FYI apache/apisix#6276 (comment)

hi @tao12345666333, on which branch should I find the currently code for prometheus e2e tests?

Belyenochi avatar Feb 22 '22 07:02 Belyenochi

@Belyenochi you can just use master branch

tao12345666333 avatar Feb 23 '22 23:02 tao12345666333

Kind reminder, is there anything I can help you @Belyenochi

tao12345666333 avatar Mar 08 '22 06:03 tao12345666333

Hi, I want to continue this issues about adding test cases for prometheus plug-in. If you(@Belyenochi ) are still in this issues or finish it a while, please tell me in time. I plan to finish it next week. @tao12345666333

Chever-John avatar Mar 24 '22 10:03 Chever-John

Hi, I want to continue this issues about adding test cases for prometheus plug-in.

If you(@Belyenochi ) are still in this issues or finish it a while, please tell me in time.

I plan to finish this next week. @tao12345666333

👌 thanks

tao12345666333 avatar Mar 24 '22 10:03 tao12345666333

Hi, I want to continue this issues about adding test cases for prometheus plug-in. If you(@Belyenochi ) are still in this issues or finish it a while, please tell me in time. I plan to finish it next week. @tao12345666333

Thanks, please continue, sorry for not updating the status in time.

Belyenochi avatar Mar 24 '22 10:03 Belyenochi

@Belyenochi Don't worry, thanks for your continued contributions

tao12345666333 avatar Mar 24 '22 10:03 tao12345666333

This issue has been marked as stale due to 90 days of inactivity. It will be closed in 30 days if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.

github-actions[bot] avatar Aug 08 '22 01:08 github-actions[bot]