[GitHub] [apisix-dashboard] nic-chen commented on a change in pull request #958: feat: implement API to get apisix instances status
nic-chen commented on a change in pull request #958: URL: https://github.com/apache/apisix-dashboard/pull/958#discussion_r545603109 ## File path: api/test/docker/apisix_config2.yaml ## @@ -93,4 +93,5 @@ plugin_attr: server-info: report_interval: 10 -report_ttl: 3600 \ No newline at end of file +report_ttl: 3600 + Review comment: `plugins` can't be removed, because we have e2e test cases for skywalking which is not enable by default. 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: us...@infra.apache.org
[GitHub] [apisix-dashboard] nic-chen commented on a change in pull request #958: feat: implement API to get apisix instances status
nic-chen commented on a change in pull request #958: URL: https://github.com/apache/apisix-dashboard/pull/958#discussion_r545140026 ## File path: api/test/docker/docker-compose.yaml ## @@ -149,14 +150,15 @@ services: ipv4_address: 172.16.238.30 apisix2: +hostname: apisix_server2 build: context: ../../ dockerfile: test/docker/Dockerfile-apisix args: - APISIX_VERSION=2.1 Review comment: we should use `master` as APISIX_VERSION here. `server-info` is new plugin that not in APISIX 2.1. 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: us...@infra.apache.org
[GitHub] [apisix-dashboard] nic-chen commented on a change in pull request #958: feat: implement API to get apisix instances status
nic-chen commented on a change in pull request #958: URL: https://github.com/apache/apisix-dashboard/pull/958#discussion_r542085785 ## File path: api/test/e2e/server_info_test.go ## @@ -0,0 +1,147 @@ +/* + * 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 e2e + +import ( + "context" + "encoding/json" + "fmt" + "math/rand" + "net/http" + "testing" + "time" + + "github.com/stretchr/testify/assert" +) + +const ( + ServerInfoPrefix = "/apisix/data_plane/server_info" +) + +var ( + s = &EtcdV3Storage{} +) + +type ServerInfo struct { + ID string `json:"id"` + LastReportTime int64 `json:"last_report_time,omitempty"` + UpTime int64 `json:"up_time,omitempty"` + BootTime int64 `json:"boot_time,omitempty"` + EtcdVersionstring `json:"etcd_version,omitempty"` + Hostname string `json:"hostname,omitempty"` + Versionstring `json:"version,omitempty"` +} + +func putServerInfo(id, val string) error { + ctx, _ := context.WithTimeout(context.Background(), 2*time.Second) + key := fmt.Sprintf("%s/%s", ServerInfoPrefix, id) + return s.Create(ctx, key, val) +} + +func deleteServerInfo(ids []string) error { + ctx, _ := context.WithTimeout(context.Background(), 2*time.Second) + + var keys []string + for _, id := range ids { + keys = append(keys, fmt.Sprintf("%s/%s", ServerInfoPrefix, id)) + } + + return s.BatchDelete(ctx, keys) +} + +func genServerInfo(id, hostname string) string { Review comment: We should let APISIX generate server info instead of directly operating ETCD to simulate. 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: us...@infra.apache.org
[GitHub] [apisix-dashboard] nic-chen commented on a change in pull request #958: feat: implement API to get apisix instances status
nic-chen commented on a change in pull request #958: URL: https://github.com/apache/apisix-dashboard/pull/958#discussion_r542085107 ## File path: api/internal/handler/server_info/server_info_test.go ## @@ -0,0 +1,156 @@ +/* + * 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 server_info + +import ( + "strings" + "testing" + "time" + + "github.com/shiningrush/droplet" + "github.com/stretchr/testify/assert" + + "github.com/apisix/manager-api/internal/core/entity" + "github.com/apisix/manager-api/internal/core/storage" + "github.com/apisix/manager-api/internal/core/store" +) + +const ( + SleepTime = 100 * time.Millisecond +) + +var serverInfoHandler *Handler + +func init() { + err := storage.InitETCDClient([]string{"127.0.0.1:2379"}) + + if err != nil { + panic(err) + } + err = store.InitStores() + if err != nil { + panic(err) + } + + serverInfoHandler = &Handler{ + serverInfoStore: store.GetStore(store.HubKeyServerInfo), + } +} + +func create(t *testing.T, ctx droplet.Context, info *entity.ServerInfo) { Review comment: @starsz we have started to refactor the unit test cases. you can refer : https://github.com/apache/apisix-dashboard/blob/master/api/internal/handler/consumer/consumer_test.go 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: us...@infra.apache.org