You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/04/26 18:29:49 UTC

[GitHub] [apisix-ingress-controller] fhuzero opened a new pull request #406: test: add e2e test cases for server-info plugin

fhuzero opened a new pull request #406:
URL: https://github.com/apache/apisix-ingress-controller/pull/406


   This PR added some e2e test cases to cover the usage of `server-info` plugin. A new k8s tunnel `apisixControlTunnel` is added to support the retrieval of server info from `/v1/server_info` through Control API.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] tokers commented on pull request #406: test: add e2e test cases for server-info plugin

Posted by GitBox <gi...@apache.org>.
tokers commented on pull request #406:
URL: https://github.com/apache/apisix-ingress-controller/pull/406#issuecomment-839403078


   @fhuzero Also, please resolve the conflicts.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] tokers merged pull request #406: test: add e2e test cases for server-info plugin

Posted by GitBox <gi...@apache.org>.
tokers merged pull request #406:
URL: https://github.com/apache/apisix-ingress-controller/pull/406


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] codecov-commenter edited a comment on pull request #406: test: add e2e test cases for server-info plugin

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #406:
URL: https://github.com/apache/apisix-ingress-controller/pull/406#issuecomment-827370564


   # [Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#406](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (96a0b95) into [master](https://codecov.io/gh/apache/apisix-ingress-controller/commit/98555210326c02db4c2c4ca8e2a8e0a27b17c92b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (9855521) will **decrease** coverage by `0.01%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406/graphs/tree.svg?width=650&height=150&src=pr&token=WPLQXPY3V0&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master     #406      +/-   ##
   ==========================================
   - Coverage   39.20%   39.18%   -0.02%     
   ==========================================
     Files          41       40       -1     
     Lines        3301     3300       -1     
   ==========================================
   - Hits         1294     1293       -1     
     Misses       1846     1846              
     Partials      161      161              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [test/e2e/e2e.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-dGVzdC9lMmUvZTJlLmdv) | | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [9855521...96a0b95](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] tokers commented on pull request #406: test: add e2e test cases for server-info plugin

Posted by GitBox <gi...@apache.org>.
tokers commented on pull request #406:
URL: https://github.com/apache/apisix-ingress-controller/pull/406#issuecomment-828965208


   > > @fhuzero Hi! Does this PR ready to review?
   > 
   > Sad that the code failed to pass some ci checks so probably it's not ready to be merged. When I run test cases in Minikube on my local machine, though the test for retrieving server info succeed most times, it fails randomly because of some errors such as `waiting for apisix ready`, `no etcd`, `TLS handshake timeout`, etc. These errors will recover later without intervention. It would be great if someone can give me guidance on how to avoid the random failure.
   
   We recommend you to use [Kind](https://kind.sigs.k8s.io/) as the Cluster to run e2e test suites, also, you may need to push these images to minikube before you start to run them, too long time for pulling images might lead to some timeout assertions failed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] tokers commented on a change in pull request #406: test: add e2e test cases for server-info plugin

Posted by GitBox <gi...@apache.org>.
tokers commented on a change in pull request #406:
URL: https://github.com/apache/apisix-ingress-controller/pull/406#discussion_r630847807



##########
File path: test/e2e/scaffold/k8s.go
##########
@@ -184,6 +184,30 @@ func (s *Scaffold) EnsureNumApisixUpstreamsCreated(desired int) error {
 	return ensureNumApisixCRDsCreated(u.String(), desired)
 }
 
+// GetServerInfo collect server info from "/v1/server_info" (Control API) exposed by server-info plugin
+func (s *Scaffold) GetServerInfo() (map[string]interface{}, error) {
+	u := url.URL{
+		Scheme: "http",
+		Host:   s.apisixControlTunnel.Endpoint(),
+		Path:   "/v1/server_info",
+	}
+	resp, err := http.Get(u.String())

Review comment:
       deferred to close the body.

##########
File path: test/e2e/plugins/server-info.go
##########
@@ -0,0 +1,47 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package plugins
+
+import (
+	"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
+	"github.com/onsi/ginkgo"
+	"github.com/stretchr/testify/assert"
+)
+
+var _ = ginkgo.Describe("server-info plugin", func() {
+	opts := &scaffold.Options{
+		Name:                    "default",
+		Kubeconfig:              scaffold.GetKubeconfig(),
+		APISIXConfigPath:        "testdata/apisix-gw-config.yaml",
+		APISIXDefaultConfigPath: "testdata/apisix-gw-config-default.yaml",
+		IngressAPISIXReplicas:   1,
+		HTTPBinServicePort:      80,
+		APISIXRouteVersion:      "apisix.apache.org/v2alpha1",
+	}
+	s := scaffold.NewScaffold(opts)
+
+	ginkgo.It("enable server-info plugin", func() {
+		serverInfoKey := [...]string{"etcd_version", "up_time", "last_report_time", "id", "hostname", "version", "boot_time"}
+		serverInfo, err := s.GetServerInfo()
+		assert.Nil(ginkgo.GinkgoT(), err)
+		if assert.NotNil(ginkgo.GinkgoT(), serverInfo) {

Review comment:
       Actually `serverInfo` must not empty. So here should not use such a conditional check.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] fhuzero commented on pull request #406: test: add e2e test cases for server-info plugin

Posted by GitBox <gi...@apache.org>.
fhuzero commented on pull request #406:
URL: https://github.com/apache/apisix-ingress-controller/pull/406#issuecomment-839499963


   > @fhuzero Maybe you can simply this PR, as we always enable `server-info` plugin, we may just enable it and check its output.
   
   Cool. Actually I have been doubting the need of disabling the plugin and spent a lot of time dealing with the case when the plugin is disabled. Seems that I'd better raise this question and discuss it earlier :P


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] codecov-commenter edited a comment on pull request #406: test: add e2e test cases for server-info plugin

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #406:
URL: https://github.com/apache/apisix-ingress-controller/pull/406#issuecomment-827370564


   # [Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#406](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (fd25c4d) into [master](https://codecov.io/gh/apache/apisix-ingress-controller/commit/d269a01fe69c287cf13a3574d8ce6566c18a306c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (d269a01) will **increase** coverage by `0.42%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406/graphs/tree.svg?width=650&height=150&src=pr&token=WPLQXPY3V0&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master     #406      +/-   ##
   ==========================================
   + Coverage   36.60%   37.02%   +0.42%     
   ==========================================
     Files          44       44              
     Lines        3800     3800              
   ==========================================
   + Hits         1391     1407      +16     
   + Misses       2230     2216      -14     
   + Partials      179      177       -2     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [pkg/apisix/route.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2FwaXNpeC9yb3V0ZS5nbw==) | `35.29% <0.00%> (+2.20%)` | :arrow_up: |
   | [pkg/apisix/cluster.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2FwaXNpeC9jbHVzdGVyLmdv) | `32.90% <0.00%> (+5.62%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [d269a01...fd25c4d](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] fhuzero commented on pull request #406: test: add e2e test cases for server-info plugin

Posted by GitBox <gi...@apache.org>.
fhuzero commented on pull request #406:
URL: https://github.com/apache/apisix-ingress-controller/pull/406#issuecomment-828921271


   > @fhuzero Hi! Does this PR ready to review?
   
   Sad that the code failed to pass some ci checks so probably it's not ready to be merged. When I run test cases in Minikube on my local machine, though the test for retrieving server info succeed most times, it fails randomly because of some errors such as `waiting for apisix ready`, `no etcd`, `TLS handshake timeout`, etc. These errors will recover later without intervention. It would be great if someone can give me guidance on how to avoid the random failure.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] codecov-commenter commented on pull request #406: test: add e2e test cases for server-info plugin

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #406:
URL: https://github.com/apache/apisix-ingress-controller/pull/406#issuecomment-827370564


   # [Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#406](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (fca2316) into [master](https://codecov.io/gh/apache/apisix-ingress-controller/commit/98555210326c02db4c2c4ca8e2a8e0a27b17c92b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (9855521) will **decrease** coverage by `0.01%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406/graphs/tree.svg?width=650&height=150&src=pr&token=WPLQXPY3V0&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master     #406      +/-   ##
   ==========================================
   - Coverage   39.20%   39.18%   -0.02%     
   ==========================================
     Files          41       40       -1     
     Lines        3301     3300       -1     
   ==========================================
   - Hits         1294     1293       -1     
     Misses       1846     1846              
     Partials      161      161              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [test/e2e/e2e.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-dGVzdC9lMmUvZTJlLmdv) | | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [9855521...fca2316](https://codecov.io/gh/apache/apisix-ingress-controller/pull/406?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] fhuzero commented on a change in pull request #406: test: add e2e test cases for server-info plugin

Posted by GitBox <gi...@apache.org>.
fhuzero commented on a change in pull request #406:
URL: https://github.com/apache/apisix-ingress-controller/pull/406#discussion_r630865652



##########
File path: test/e2e/plugins/server-info.go
##########
@@ -0,0 +1,47 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package plugins
+
+import (
+	"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
+	"github.com/onsi/ginkgo"
+	"github.com/stretchr/testify/assert"
+)
+
+var _ = ginkgo.Describe("server-info plugin", func() {
+	opts := &scaffold.Options{
+		Name:                    "default",
+		Kubeconfig:              scaffold.GetKubeconfig(),
+		APISIXConfigPath:        "testdata/apisix-gw-config.yaml",
+		APISIXDefaultConfigPath: "testdata/apisix-gw-config-default.yaml",
+		IngressAPISIXReplicas:   1,
+		HTTPBinServicePort:      80,
+		APISIXRouteVersion:      "apisix.apache.org/v2alpha1",
+	}
+	s := scaffold.NewScaffold(opts)
+
+	ginkgo.It("enable server-info plugin", func() {
+		serverInfoKey := [...]string{"etcd_version", "up_time", "last_report_time", "id", "hostname", "version", "boot_time"}
+		serverInfo, err := s.GetServerInfo()
+		assert.Nil(ginkgo.GinkgoT(), err)
+		if assert.NotNil(ginkgo.GinkgoT(), serverInfo) {

Review comment:
       I have removed the conditional check in the new commit.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] tokers commented on pull request #406: test: add e2e test cases for server-info plugin

Posted by GitBox <gi...@apache.org>.
tokers commented on pull request #406:
URL: https://github.com/apache/apisix-ingress-controller/pull/406#issuecomment-839402958


   @fhuzero Maybe you can simply this PR, as we always enable `server-info` plugin, we may just enable it and check its output.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] fhuzero commented on a change in pull request #406: test: add e2e test cases for server-info plugin

Posted by GitBox <gi...@apache.org>.
fhuzero commented on a change in pull request #406:
URL: https://github.com/apache/apisix-ingress-controller/pull/406#discussion_r630866562



##########
File path: test/e2e/scaffold/k8s.go
##########
@@ -184,6 +184,30 @@ func (s *Scaffold) EnsureNumApisixUpstreamsCreated(desired int) error {
 	return ensureNumApisixCRDsCreated(u.String(), desired)
 }
 
+// GetServerInfo collect server info from "/v1/server_info" (Control API) exposed by server-info plugin
+func (s *Scaffold) GetServerInfo() (map[string]interface{}, error) {
+	u := url.URL{
+		Scheme: "http",
+		Host:   s.apisixControlTunnel.Endpoint(),
+		Path:   "/v1/server_info",
+	}
+	resp, err := http.Get(u.String())

Review comment:
       I added a `defer` statement if no error is returned.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] tokers commented on pull request #406: test: add e2e test cases for server-info plugin

Posted by GitBox <gi...@apache.org>.
tokers commented on pull request #406:
URL: https://github.com/apache/apisix-ingress-controller/pull/406#issuecomment-828889104


   @fhuzero Hi! Does this PR ready to review?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] fhuzero commented on pull request #406: test: add e2e test cases for server-info plugin

Posted by GitBox <gi...@apache.org>.
fhuzero commented on pull request #406:
URL: https://github.com/apache/apisix-ingress-controller/pull/406#issuecomment-829008252


   > > > @fhuzero Hi! Does this PR ready to review?
   > > 
   > > 
   > > Sad that the code failed to pass some ci checks so probably it's not ready to be merged. When I run test cases in Minikube on my local machine, though the test for retrieving server info succeed most times, it fails randomly because of some errors such as `waiting for apisix ready`, `no etcd`, `TLS handshake timeout`, etc. These errors will recover later without intervention. It would be great if someone can give me guidance on how to avoid the random failure.
   > 
   > We recommend you to use [Kind](https://kind.sigs.k8s.io/) as the Cluster to run e2e test suites, also, you may need to push these images to minikube before you start to run them, too long time for pulling images might lead to some timeout assertions failed.
   
   Thanks for your recommendation! I did follow three steps listed in [Quick Start](https://github.com/apache/apisix-ingress-controller/tree/master/test/e2e#quick-start) in Apisix ingress controller e2e test suites Readme file. When running test for the first time, I created a cluster by Kind and all test cases passed. After that, I used `E2E_SKIP_BUILD=1` to skip the first two steps. Then the aforementioned errors occurred randomly. Please let me know if I overlooked anything.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] tokers commented on pull request #406: test: add e2e test cases for server-info plugin

Posted by GitBox <gi...@apache.org>.
tokers commented on pull request #406:
URL: https://github.com/apache/apisix-ingress-controller/pull/406#issuecomment-839544170


   > > @fhuzero Maybe you can simply this PR, as we always enable `server-info` plugin, we may just enable it and check its output.
   > 
   > Cool. Actually I have been doubting the need of disabling the plugin and spent a lot of time dealing with the case when the plugin is disabled. Seems that I'd better raise this question and discuss it earlier :P
   
   Just take your time :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] tokers commented on a change in pull request #406: test: add e2e test cases for server-info plugin

Posted by GitBox <gi...@apache.org>.
tokers commented on a change in pull request #406:
URL: https://github.com/apache/apisix-ingress-controller/pull/406#discussion_r627044476



##########
File path: test/e2e/plugins/server-info.go
##########
@@ -0,0 +1,109 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package plugins
+
+import (
+	"io/ioutil"
+	"strings"
+	"errors"
+
+	"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
+	"github.com/onsi/ginkgo"
+	"github.com/stretchr/testify/assert"
+)
+
+var serverInfoKey = [...]string{"etcd_version", "up_time", "last_report_time", "id", "hostname", "version", "boot_time"}
+
+var _ = ginkgo.FDescribe("server-info plugin", func() {
+	opts := &scaffold.Options{
+		Name:                    "default",
+		Kubeconfig:              scaffold.GetKubeconfig(),
+		APISIXConfigPath:        "testdata/apisix-gw-config.yaml",
+		APISIXDefaultConfigPath: "testdata/apisix-gw-config-default.yaml",
+		IngressAPISIXReplicas:   1,
+		HTTPBinServicePort:      80,
+		APISIXRouteVersion:      "apisix.apache.org/v2alpha1",
+	}
+	s := scaffold.NewScaffold(opts)
+	ginkgo.It("check server info", func() {
+		err := setServerInfoPluginStatus(opts.APISIXConfigPath, true)

Review comment:
       Timing is too late, apisix deployment was created already before the `It` block running.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org