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"`
+       EtcdVersion    string `json:"etcd_version,omitempty"`
+       Hostname       string `json:"hostname,omitempty"`
+       Version        string `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


Reply via email to