Skip to content

Commit

Permalink
fix: e2e test case and comment and license header
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengziyi0117 committed Nov 8, 2024
1 parent f31af0c commit c012243
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/e2e-native.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:
config: test/e2e/case/native-protocols/e2e.yaml
- name: Native Process/EBPF Profiling
config: test/e2e/case/native-ebpf/e2e.yaml
- name: Native Process/Async Profiler
config: test/e2e/case/native-asyncprofiler/e2e.yaml
fail-fast: true
name: Native E2E test
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion internal/satellite/module/api/sync_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ import (
)

type SyncInvoker interface {
// SyncInvoke means synchronized process event
// SyncInvoke means synchronized process event. The returned result grpc.ClientStream is the stream initiated by satellite to oap server, which is used to provide bidirectional stream support
SyncInvoke(d *v1.SniffData) (*v1.SniffData, grpc.ClientStream, error)
}
4 changes: 3 additions & 1 deletion plugins/client/grpc/client_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import (
"google.golang.org/grpc/metadata"
)

const BidirectionalStreamKey = "BidirectionalStream"

// loadConfig use the client params to build the grpc client config.
func (c *Client) loadConfig() (*[]grpc.DialOption, error) {
options := make([]grpc.DialOption, 0)
Expand Down Expand Up @@ -69,7 +71,7 @@ func (c *Client) loadConfig() (*[]grpc.DialOption, error) {
ctx = metadata.NewOutgoingContext(ctx, authHeader)
}
supportBidirectionalStream := false
if b := ctx.Value("BidirectionalStream"); b != nil {
if b := ctx.Value(BidirectionalStreamKey); b != nil {
supportBidirectionalStream = b.(bool)
}
timeout, timeoutFunc := context.WithTimeout(ctx, streamRequestTimeout)
Expand Down
20 changes: 19 additions & 1 deletion plugins/forwarder/grpc/nativeasyncprofiler/forwarder.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
// 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 nativeasyncprofiler

import (
"context"
"fmt"
client_grpc "github.com/apache/skywalking-satellite/plugins/client/grpc"
server_grpc "github.com/apache/skywalking-satellite/plugins/server/grpc"
"reflect"

Expand Down Expand Up @@ -67,7 +85,7 @@ func (f *Forwarder) SyncForward(e *v1.SniffData) (*v1.SniffData, grpc.ClientStre
return &v1.SniffData{Data: &v1.SniffData_Commands{Commands: commands}}, nil, nil
case *v1.SniffData_AsyncProfilerData:
// metadata
ctx := context.WithValue(context.Background(), "BidirectionalStream", true)
ctx := context.WithValue(context.Background(), client_grpc.BidirectionalStreamKey, true)

Check failure on line 88 in plugins/forwarder/grpc/nativeasyncprofiler/forwarder.go

View workflow job for this annotation

GitHub Actions / CI (1.21, ubuntu)

should not use basic type string as key in context.WithValue (golint)
stream, err := f.profilingClient.Collect(ctx)
if err != nil {
log.Logger.Errorf("%s open collect stream error: %v", f.Name(), err)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
// 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 nativeasyncprofiler

import (
Expand All @@ -13,8 +30,6 @@ import (
v1 "skywalking.apache.org/repo/goapi/satellite/data/v1"
)

const eventName = "grpc-async-profiler-event"

type AsyncProfilerService struct {
receiveChannel chan *v1.SniffData

Expand Down
17 changes: 17 additions & 0 deletions plugins/receiver/grpc/nativeasyncprofiler/receiver.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
// 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 nativeasyncprofiler

import (
Expand Down
17 changes: 1 addition & 16 deletions test/e2e/case/native-asyncprofiler/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ services:
SW_LOG_LAL_FILES: test
SW_CLUSTER: etcd
SW_CONFIGURATION: etcd
volumes:
- ./lal.yaml:/skywalking/config/lal/test.yaml
ports:
- 12800
depends_on:
Expand All @@ -73,23 +71,10 @@ services:
extends:
file: ../../base/base-compose.yml
service: provider
ports:
- 9090
privileged: true
depends_on:
satellite:
condition: service_healthy

consumer:
extends:
file: ../../base/base-compose.yml
service: consumer
ports:
- 9090
depends_on:
satellite:
condition: service_healthy
provider:
condition: service_healthy

networks:
e2e:
7 changes: 3 additions & 4 deletions test/e2e/case/native-asyncprofiler/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ setup:
env: compose
file: docker-compose.yml
timeout: 20m
init-system-environment: ../../../../script/env
init-system-environment: ../../base/env
steps:
- name: set PATH
command: export PATH=/tmp/skywalking-infra-e2e/bin:$PATH
- name: install yq
command: bash test/e2e-v2/script/prepare/setup-e2e-shell/install.sh yq
command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh yq
- name: install swctl
command: bash test/e2e-v2/script/prepare/setup-e2e-shell/install.sh swctl
command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh swctl

verify:
retry:
Expand Down Expand Up @@ -64,4 +64,3 @@ verify:
--instance-name-list=provider1 \
--task-id=$(swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profiling async list --service-name=e2e-service-provider | yq e '.tasks[0].id')
expected: expected/analysis.yml

0 comments on commit c012243

Please sign in to comment.