You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ke...@apache.org on 2021/10/20 03:08:44 UTC

[skywalking-infra-e2e] 01/01: Fix that trigger is not continuously triggered when running `e2e trigger`

This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch bug/trigger
in repository https://gitbox.apache.org/repos/asf/skywalking-infra-e2e.git

commit aa46dee75a61528df60455c6e55bc4eaa4ab191b
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Wed Oct 20 11:08:05 2021 +0800

    Fix that trigger is not continuously triggered when running `e2e trigger`
---
 commands/trigger/trigger.go | 14 +++++++++++++-
 examples/compose/e2e.yaml   |  2 +-
 internal/util/os.go         | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/commands/trigger/trigger.go b/commands/trigger/trigger.go
index fd1a006..b610f56 100644
--- a/commands/trigger/trigger.go
+++ b/commands/trigger/trigger.go
@@ -19,7 +19,9 @@ package trigger
 
 import (
 	"fmt"
+	"sync"
 
+	"github.com/apache/skywalking-infra-e2e/internal/util"
 	"github.com/spf13/cobra"
 
 	"github.com/apache/skywalking-infra-e2e/internal/components/trigger"
@@ -38,7 +40,17 @@ var Trigger = &cobra.Command{
 		if action == nil {
 			return nil
 		}
-		return <-action.Do()
+		if err := <-action.Do(); err != nil {
+			return err
+		}
+
+		wg := sync.WaitGroup{}
+		wg.Add(1)
+		util.AddShutDownHook(wg.Done)
+		wg.Wait()
+
+		action.Stop()
+		return nil
 	},
 }
 
diff --git a/examples/compose/e2e.yaml b/examples/compose/e2e.yaml
index 7b2b159..fd6348e 100644
--- a/examples/compose/e2e.yaml
+++ b/examples/compose/e2e.yaml
@@ -57,4 +57,4 @@ verify:
     - actual: ../../test/verify/2.actual.yaml
       expected: ../../test/verify/2.expected.yaml
     - query: swctl --display yaml --base-url=http://127.0.0.1:${oap_12800}/graphql service ls
-      expected: ../../test/verify/3.expected.yaml
\ No newline at end of file
+      expected: ../../test/verify/3.expected.yaml
diff --git a/internal/util/os.go b/internal/util/os.go
new file mode 100644
index 0000000..d7b8293
--- /dev/null
+++ b/internal/util/os.go
@@ -0,0 +1,34 @@
+// 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 util
+
+import (
+	"os"
+	"os/signal"
+	"syscall"
+)
+
+func AddShutDownHook(stopFunc func()) {
+	c := make(chan os.Signal, 1)
+	signal.Notify(c, os.Interrupt, syscall.SIGTERM)
+	go func() {
+		<-c
+		stopFunc()
+	}()
+}