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 2022/11/17 05:38:32 UTC

[GitHub] [skywalking-agent-test-tool] nisiyong opened a new pull request, #47: Support `start with` and `end with`

nisiyong opened a new pull request, #47:
URL: https://github.com/apache/skywalking-agent-test-tool/pull/47

   Related to https://github.com/apache/skywalking-java/pull/382.
   
   Here are the brief changes:
   1. Introduce the enum `ExpressOperator` to refactor `ExpressParser`
   2. Support `start with` and `end with` operators
   3. Fix wrong spelling


-- 
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-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking-agent-test-tool] wu-sheng commented on pull request #47: Support `start with` and `end with`

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on PR #47:
URL: https://github.com/apache/skywalking-agent-test-tool/pull/47#issuecomment-1319429501

   I am going to revert this chcange. @nisiyong Please polish the logic.


-- 
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-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking-agent-test-tool] wu-sheng merged pull request #47: Support `start with` and `end with`

Posted by GitBox <gi...@apache.org>.
wu-sheng merged PR #47:
URL: https://github.com/apache/skywalking-agent-test-tool/pull/47


-- 
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-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking-agent-test-tool] wu-sheng commented on a diff in pull request #47: Support `start with` and `end with`

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #47:
URL: https://github.com/apache/skywalking-agent-test-tool/pull/47#discussion_r1025897233


##########
validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/ExpressParser.java:
##########
@@ -19,50 +19,50 @@
 
 import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.ElementAssertor;
 import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.EqualsAssertor;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.EndWithAssertor;
 import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.GreatThanAssertor;
-import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.GreetEqualAssertor;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.GreatEqualAssertor;
 import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.NoopAssertor;
 import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.NotBlankAssertor;
 import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.NotEqualsAssertor;
 import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.NotNullAssertor;
 import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.NullAssertor;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.StartWithAssertor;
 
 public class ExpressParser {
     public static ElementAssertor parse(String express) {
         if (express == null) {
             return new NoopAssertor();
         }
 
-        String expressTrim = express.trim();
-        if (expressTrim.equals("not null")) {
-            return new NotNullAssertor();
+        ExpressOperator expressOperator = ExpressOperator.parse(express);
+        if (expressOperator == null) {
+            return new EqualsAssertor(express);
         }
 
-        if (expressTrim.equals("not blank")) {
-            return new NotBlankAssertor();
-        }
-
-        if (expressTrim.equals("null")) {
-            return new NullAssertor();
-        }
+        String expectedValue = ExpressOperator.getExpectedValue(expressOperator, express);
 
-        String[] expressSegment = expressTrim.split(" ");
-        if (expressSegment.length == 1) {
-            return new EqualsAssertor(expressSegment[0]);
-        } else if (expressSegment.length == 2) {
-            String exceptedValue = expressSegment[1];
-            switch (expressSegment[0].trim()) {
-                case "nq":
-                    return new NotEqualsAssertor(exceptedValue);
-                case "eq":
-                    return new EqualsAssertor(exceptedValue);
-                case "gt":
-                    return new GreatThanAssertor(exceptedValue);
-                case "ge":
-                    return new GreetEqualAssertor(exceptedValue);
-            }
+        switch (expressOperator) {
+            case NULL:
+                return new NullAssertor();
+            case NOT_NULL:
+                return new NotNullAssertor();
+            case NOT_BLANK:
+                return new NotBlankAssertor();
+            case EQUALS:
+                return new EqualsAssertor(expectedValue);
+            case NOT_EQUALS:
+                return new NotEqualsAssertor(expectedValue);
+            case GREAT_THAN:
+                return new GreatThanAssertor(expectedValue);
+            case GREAT_EQUAL:
+                return new GreatEqualAssertor(expectedValue);
+            case START_WITH:
+                return new StartWithAssertor(expectedValue);
+            case END_WITH:
+                return new EndWithAssertor(expectedValue);
+            default:
+                return new EqualsAssertor(express);

Review Comment:
   This change seems wrong. KeyValuePair match drops into GreatEqualAssertor



-- 
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-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking-agent-test-tool] wu-sheng commented on a diff in pull request #47: Support `start with` and `end with`

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #47:
URL: https://github.com/apache/skywalking-agent-test-tool/pull/47#discussion_r1025898913


##########
validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/ExpressOperator.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the 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.
+ * The 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 org.apache.skywalking.plugin.test.agent.tool.validator.assertor;
+
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor(access = AccessLevel.PRIVATE)
+public enum ExpressOperator {
+    NULL("null", false),
+    NOT_NULL("not null", false),
+    NOT_BLANK("not blank", false),
+    NOT_EQUALS("nq",true),
+    EQUALS("eq",true),
+    GREAT_THAN("gt",true),
+    GREAT_EQUAL("ge",true),
+    START_WITH("start with",true),
+    END_WITH("end with",true),
+    ;
+    private final String prefix;
+    private final boolean hasValue;
+
+    public static ExpressOperator parse(String express) {
+        if (express == null) {
+            return null;
+        }
+
+        String expressTrim = express.trim();
+        for (ExpressOperator operator : ExpressOperator.values()) {
+            if (expressTrim.startsWith(operator.getPrefix())) {

Review Comment:
   `ge` will be a start of `GET` in the test case. Such as `- {key: http.method, value: GET}`. Then test breaks.



-- 
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-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking-agent-test-tool] nisiyong commented on pull request #47: Support `start with` and `end with`

Posted by GitBox <gi...@apache.org>.
nisiyong commented on PR #47:
URL: https://github.com/apache/skywalking-agent-test-tool/pull/47#issuecomment-1319436429

   Okay


-- 
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-unsubscribe@skywalking.apache.org

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