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/03/04 15:10:04 UTC

[skywalking-infra-e2e] branch fix/relative-path updated (b4970a8 -> d896190)

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

kezhenxu94 pushed a change to branch fix/relative-path
in repository https://gitbox.apache.org/repos/asf/skywalking-infra-e2e.git.


 discard b4970a8  Fix relative paths to e2e.yaml
     new d896190  Fix relative paths to e2e.yaml

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (b4970a8)
            \
             N -- N -- N   refs/heads/fix/relative-path (d896190)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 internal/config/e2eConfig.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


[skywalking-infra-e2e] 01/01: Fix relative paths to e2e.yaml

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d8961908390af3bd5b2dab20d04d911e9e67a288
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Thu Mar 4 23:04:51 2021 +0800

    Fix relative paths to e2e.yaml
---
 commands/root.go                    |  6 ++----
 commands/setup/setup.go             |  7 -------
 commands/verify/verify.go           |  4 ++--
 internal/components/cleanup/kind.go |  7 +++----
 internal/components/setup/kind.go   |  4 ++--
 internal/config/e2eConfig.go        | 18 ++++++++++++++++++
 internal/config/globalConfig.go     | 36 ++++++++++++++++++++++++++++--------
 7 files changed, 55 insertions(+), 27 deletions(-)

diff --git a/commands/root.go b/commands/root.go
index d378f0c..8616080 100644
--- a/commands/root.go
+++ b/commands/root.go
@@ -29,8 +29,6 @@ import (
 	"github.com/apache/skywalking-infra-e2e/internal/constant"
 )
 
-var cfg string
-
 // Root represents the base command when called without any subcommands
 var Root = &cobra.Command{
 	Use:           "e2e command [flags]",
@@ -39,7 +37,7 @@ var Root = &cobra.Command{
 	SilenceErrors: true,
 	SilenceUsage:  true,
 	PersistentPreRun: func(cmd *cobra.Command, args []string) {
-		config.ReadGlobalConfigFile(cfg)
+		config.ReadGlobalConfigFile()
 	},
 }
 
@@ -52,7 +50,7 @@ func Execute() error {
 	Root.AddCommand(verify.Verify)
 	Root.AddCommand(cleanup.Cleanup)
 
-	Root.PersistentFlags().StringVarP(&cfg, "config", "c", constant.E2EDefaultFile, "the config file")
+	Root.PersistentFlags().StringVarP(&config.CfgFile, "config", "c", constant.E2EDefaultFile, "the config file")
 
 	return Root.Execute()
 }
diff --git a/commands/setup/setup.go b/commands/setup/setup.go
index a3eb3b9..146644f 100644
--- a/commands/setup/setup.go
+++ b/commands/setup/setup.go
@@ -25,7 +25,6 @@ import (
 	"github.com/apache/skywalking-infra-e2e/internal/config"
 	"github.com/apache/skywalking-infra-e2e/internal/constant"
 	"github.com/apache/skywalking-infra-e2e/internal/logger"
-	"github.com/apache/skywalking-infra-e2e/internal/util"
 
 	"github.com/spf13/cobra"
 )
@@ -33,12 +32,6 @@ import (
 var Setup = &cobra.Command{
 	Use:   "setup",
 	Short: "",
-	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
-		if err := util.CheckDockerDaemon(); err != nil {
-			return err
-		}
-		return nil
-	},
 	RunE: func(cmd *cobra.Command, args []string) error {
 		if err := setupAccordingE2E(); err != nil {
 			return fmt.Errorf("[Setup] %s", err)
diff --git a/commands/verify/verify.go b/commands/verify/verify.go
index 05ccbe0..0e700b9 100644
--- a/commands/verify/verify.go
+++ b/commands/verify/verify.go
@@ -93,8 +93,8 @@ func verifyAccordingConfig() error {
 	e2eConfig := config.GlobalConfig.E2EConfig
 
 	for _, v := range e2eConfig.Verify {
-		if v.Expected != "" {
-			if err := verifySingleCase(v.Expected, v.Actual, v.Query); err != nil {
+		if v.GetExpected() != "" {
+			if err := verifySingleCase(v.GetExpected(), v.GetActual(), v.Query); err != nil {
 				logger.Log.Errorf("%v", err)
 			}
 		} else {
diff --git a/internal/components/cleanup/kind.go b/internal/components/cleanup/kind.go
index 2fc4de2..1e19072 100644
--- a/internal/components/cleanup/kind.go
+++ b/internal/components/cleanup/kind.go
@@ -39,9 +39,9 @@ type KindClusterNameConfig struct {
 }
 
 func KindCleanUp(e2eConfig *config.E2EConfig) error {
-	kindConfigFilePath := e2eConfig.Setup.File
+	kindConfigFilePath := e2eConfig.Setup.GetFile()
 
-	logger.Log.Info("deleting kind cluster...")
+	logger.Log.Infof("deleting kind cluster...\n")
 	if err := cleanKindCluster(kindConfigFilePath); err != nil {
 		logger.Log.Error("delete kind cluster failed")
 		return err
@@ -52,8 +52,7 @@ func KindCleanUp(e2eConfig *config.E2EConfig) error {
 	logger.Log.Infof("deleting k8s cluster config file:%s", kubeConfigPath)
 	err := os.Remove(kubeConfigPath)
 	if err != nil {
-		logger.Log.Errorf("delete k8s cluster config file failed")
-		return err
+		logger.Log.Infoln("delete k8s cluster config file failed")
 	}
 
 	return nil
diff --git a/internal/components/setup/kind.go b/internal/components/setup/kind.go
index 9f7b156..4c7a715 100644
--- a/internal/components/setup/kind.go
+++ b/internal/components/setup/kind.go
@@ -52,7 +52,7 @@ var (
 
 // KindSetup sets up environment according to e2e.yaml.
 func KindSetup(e2eConfig *config.E2EConfig) error {
-	kindConfigPath = e2eConfig.Setup.File
+	kindConfigPath = e2eConfig.Setup.GetFile()
 
 	if kindConfigPath == "" {
 		return fmt.Errorf("no kind config file was provided")
@@ -187,7 +187,7 @@ func createManifestsAndWait(c *kubernetes.Clientset, dc dynamic.Interface, manif
 }
 
 func createByManifest(c *kubernetes.Clientset, dc dynamic.Interface, manifest config.Manifest) error {
-	files, err := util.GetManifests(manifest.Path)
+	files, err := util.GetManifests(manifest.GetPath())
 	if err != nil {
 		logger.Log.Error("get manifests from command line argument failed")
 		return err
diff --git a/internal/config/e2eConfig.go b/internal/config/e2eConfig.go
index c242947..f052c61 100644
--- a/internal/config/e2eConfig.go
+++ b/internal/config/e2eConfig.go
@@ -33,11 +33,19 @@ type Setup struct {
 	Timeout int   `yaml:"timeout"`
 }
 
+func (s *Setup) GetFile() string {
+	return ResolveAbs(s.File)
+}
+
 type Manifest struct {
 	Path  string `yaml:"path"`
 	Waits []Wait `yaml:"wait"`
 }
 
+func (m Manifest) GetPath() string {
+	return ResolveAbs(m.Path)
+}
+
 type Run struct {
 	Command string `yaml:"command"`
 	Waits   []Wait `yaml:"wait"`
@@ -55,3 +63,13 @@ type VerifyCase struct {
 	Actual   string `yaml:"actual"`
 	Expected string `yaml:"expected"`
 }
+
+// GetActual resolves the absolute file path of the actual data file.
+func (v *VerifyCase) GetActual() string {
+	return ResolveAbs(v.Actual)
+}
+
+// GetExpected resolves the absolute file path of the expected data file.
+func (v *VerifyCase) GetExpected() string {
+	return ResolveAbs(v.Expected)
+}
diff --git a/internal/config/globalConfig.go b/internal/config/globalConfig.go
index c796962..316c54c 100644
--- a/internal/config/globalConfig.go
+++ b/internal/config/globalConfig.go
@@ -21,6 +21,8 @@ package config
 import (
 	"fmt"
 	"io/ioutil"
+	"path"
+	"path/filepath"
 
 	"github.com/apache/skywalking-infra-e2e/internal/logger"
 	"github.com/apache/skywalking-infra-e2e/internal/util"
@@ -35,24 +37,23 @@ type GlobalE2EConfig struct {
 }
 
 var GlobalConfig GlobalE2EConfig
+var CfgFile string
 
-func ReadGlobalConfigFile(configFilePath string) {
-	e2eFile := configFilePath
-
-	if !util.PathExist(e2eFile) {
-		GlobalConfig.Error = fmt.Errorf("e2e config file %s not exist", e2eFile)
+func ReadGlobalConfigFile() {
+	if !util.PathExist(CfgFile) {
+		GlobalConfig.Error = fmt.Errorf("e2e config file %s not exist", CfgFile)
 		return
 	}
 
-	data, err := ioutil.ReadFile(e2eFile)
+	data, err := ioutil.ReadFile(CfgFile)
 	if err != nil {
-		GlobalConfig.Error = fmt.Errorf("read e2e config file %s error: %s", e2eFile, err)
+		GlobalConfig.Error = fmt.Errorf("read e2e config file %s error: %s", CfgFile, err)
 		return
 	}
 
 	e2eConfigObject := E2EConfig{}
 	if err := yaml.Unmarshal(data, &e2eConfigObject); err != nil {
-		GlobalConfig.Error = fmt.Errorf("unmarshal e2e config file %s error: %s", e2eFile, err)
+		GlobalConfig.Error = fmt.Errorf("unmarshal e2e config file %s error: %s", CfgFile, err)
 		return
 	}
 
@@ -60,3 +61,22 @@ func ReadGlobalConfigFile(configFilePath string) {
 	GlobalConfig.Error = nil
 	logger.Log.Info("load the e2e config successfully")
 }
+
+// ResolveAbs resolves the relative path (relative to CfgFile) to an absolute file path.
+func ResolveAbs(p string) string {
+	if p == "" {
+		return p
+	}
+
+	if path.IsAbs(p) {
+		return p
+	}
+
+	abs, err := filepath.Abs(CfgFile)
+	if err != nil {
+		logger.Log.Warnf("failed to resolve the absolute file path of %v\n", CfgFile)
+		return p
+	}
+
+	return filepath.Join(filepath.Dir(abs), p)
+}