You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/03/03 13:07:23 UTC

[GitHub] [skywalking-infra-e2e] kezhenxu94 commented on a change in pull request #10: Implement the verification of query

kezhenxu94 commented on a change in pull request #10:
URL: https://github.com/apache/skywalking-infra-e2e/pull/10#discussion_r586400995



##########
File path: commands/verify/verify.go
##########
@@ -41,10 +44,62 @@ var Verify = &cobra.Command{
 	Use:   "verify",
 	Short: "verify if the actual data match the expected data",
 	RunE: func(cmd *cobra.Command, args []string) error {
-		if actual != "" && expected != "" {
-			return verifier.VerifyDataFile(actual, expected)
+		if expected != "" {
+			return verifySingleCase(expected, actual, query)
 		}
-		fmt.Println("Not implemented.")
-		return nil
+		// If there is no given flags.
+		return verifyAccordingConfig()
 	},
 }
+
+func verifySingleCase(expectedFile, actualFile, query string) error {
+	expectedData, err := util.ReadFileContent(expectedFile)
+	if err != nil {
+		return fmt.Errorf("failed to read the expected data file: %v", err)
+	}
+
+	var actualData, sourceName string
+	if actualFile != "" {
+		sourceName = actualFile
+		actualData, err = util.ReadFileContent(actualFile)
+		if err != nil {
+			return fmt.Errorf("failed to read the actual data file: %v", err)
+		}
+	} else if query != "" {
+		sourceName = query
+		actualData, err = util.ExecuteCommand(query)
+		if err != nil {
+			return fmt.Errorf("failed to execute the query: %v", err)
+		}
+	}
+
+	if err = verifier.Verify(actualData, expectedData); err != nil {
+		logger.Log.Warnf("failed to verify the output: %s\n", sourceName)
+		if me, ok := err.(*verifier.MismatchError); ok {
+			fmt.Println(me.Error())

Review comment:
       Can we use `logger.Log.Errorf` to print the error?




----------------------------------------------------------------
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:
users@infra.apache.org