CodePrometheus commented on code in PR #176:
URL: https://github.com/apache/skywalking-go/pull/176#discussion_r1527204555


##########
test/plugins/scenarios/segmentio-kafka/main.go:
##########
@@ -0,0 +1,149 @@
+// Licensed to 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. Apache Software Foundation (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 main
+
+import (
+       "context"
+       "fmt"
+       "log"
+       "net"
+       "net/http"
+       "strconv"
+       "time"
+
+       "github.com/segmentio/kafka-go"
+
+       _ "github.com/apache/skywalking-go"
+)
+
+type testFunc func() error
+
+var (
+       url    = "kafka-server:9092"
+       topic  = "sw-topic"
+       msg    = "I love skywalking 3 thousand"
+       ctx    = context.Background()
+       writer *kafka.Writer
+       reader *kafka.Reader
+)
+
+func main() {
+       writer = newKafkaWriter(topic)
+       defer writer.Close()
+       reader = newKafkaReader()
+       defer reader.Close()
+
+       route := http.NewServeMux()
+       route.HandleFunc("/execute", func(res http.ResponseWriter, req 
*http.Request) {
+               testProduceConsume()
+               _, _ = res.Write([]byte("execute success"))
+       })
+       route.HandleFunc("/health", func(writer http.ResponseWriter, request 
*http.Request) {
+               _, _ = writer.Write([]byte("ok"))
+       })
+       fmt.Println("start client")
+       err := http.ListenAndServe(":8080", route)
+       if err != nil {
+               fmt.Printf("client start error: %v \n", err)
+       }
+}
+
+func testProduceConsume() {
+       tests := []struct {
+               name string
+               fn   testFunc
+       }{
+               {"simpleMsg", simpleMsg},
+       }
+       for _, test := range tests {
+               fmt.Printf("excute test case: %s\n", test.name)
+               if subErr := test.fn(); subErr != nil {
+                       fmt.Printf("test case %s failed: %v", test.name, subErr)
+               }
+       }
+}
+
+func simpleMsg() error {
+       consumerHelper()

Review Comment:
   Since I want the overall display to flow to http->produce->consume and be 
displayed in a segmentId, so I made some control logic for the test code.
   And I found some examples that confuse me a bit, 
[kafka-java](https://github.com/apache/skywalking-java/blob/main/test/plugin/scenarios/kafka-scenario/config/expectedData.yaml)
 and 
[activemq-java](https://github.com/apache/skywalking-java/blob/main/test/plugin/scenarios/activemq-artemis-2.x-scenario/config/expectedData.yaml),
 the order here is sorted by the time span was collected, am I understanding it 
correctly?



-- 
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.

To unsubscribe, e-mail: notifications-unsubscr...@skywalking.apache.org

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

Reply via email to