ssulav commented on code in PR #8783:
URL: https://github.com/apache/ozone/pull/8783#discussion_r2242424367


##########
hadoop-ozone/dist/src/main/smoketest/debug/container-state-verifier.robot:
##########
@@ -0,0 +1,54 @@
+# 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.
+
+*** Settings ***
+Documentation       Test container state on a UNHEALTHY, DELETED and INVALID 
container
+Resource            ../ozone-fi/BytemanKeywords.robot
+Resource            ozone-debug-keywords.robot
+
+*** Variables ***
+${PREFIX}               ${EMPTY}
+${DATANODE}             ${EMPTY}
+${FAULT_INJ_DATANODE}   ${EMPTY}
+${VOLUME}               cli-debug-volume${PREFIX}
+${BUCKET}               cli-debug-bucket
+${TESTFILE}             testfile
+${CHECK_TYPE}           containerState
+
+${UNHEALTHY_RULE}       
/opt/hadoop/share/ozone/byteman/unhealthy-container-state.btm

Review Comment:
   Have a single rule file
   `${TEMPLATE_RULE}        
/opt/hadoop/share/ozone/byteman/container-state-template.btm`



##########
dev-support/byteman/deleted-container-state.btm:
##########
@@ -0,0 +1,24 @@
+# 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.
+
+RULE Change container state to DELETED
+CLASS org.apache.hadoop.ozone.container.common.impl.ContainerData
+METHOD getState
+AT ENTRY
+IF TRUE
+DO

Review Comment:
   We can try this instead to have a single template file for the state return
   ```
   RULE Change container state to STATE_PLACEHOLDER
   ...
   DO
     traceln("BYTEMAN RULE: Overriding getState() to return STATE_PLACEHOLDER 
state");
     return 
org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos$ContainerDataProto$State.valueOf("STATE_PLACEHOLDER")
   ENDRULE
   ```



##########
hadoop-ozone/dist/src/main/smoketest/debug/container-state-verifier.robot:
##########
@@ -0,0 +1,54 @@
+# 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.
+
+*** Settings ***
+Documentation       Test container state on a UNHEALTHY, DELETED and INVALID 
container
+Resource            ../ozone-fi/BytemanKeywords.robot
+Resource            ozone-debug-keywords.robot
+
+*** Variables ***
+${PREFIX}               ${EMPTY}
+${DATANODE}             ${EMPTY}
+${FAULT_INJ_DATANODE}   ${EMPTY}
+${VOLUME}               cli-debug-volume${PREFIX}
+${BUCKET}               cli-debug-bucket
+${TESTFILE}             testfile
+${CHECK_TYPE}           containerState
+
+${UNHEALTHY_RULE}       
/opt/hadoop/share/ozone/byteman/unhealthy-container-state.btm
+${DELETED_RULE}         
/opt/hadoop/share/ozone/byteman/deleted-container-state.btm
+${INVALID_RULE}         
/opt/hadoop/share/ozone/byteman/invalid-container-state.btm
+
+*** Keywords ***
+Verify Container State with Rule

Review Comment:
   Used sed to replace the template with desired state.
   
   ```
   Create Container State Rule
       [Arguments]          ${state}
       ${rule_file} =        Set Variable    /tmp/container-state-${state}.btm
       Execute               sed 's/STATE_PLACEHOLDER/${state}/g' 
${TEMPLATE_RULE} > ${rule_file}
       Return From Keyword   ${rule_file}
   
   Verify Container State with State
       [Arguments]          ${expected_state}
       ${rule_file} =        Create Container State Rule    ${expected_state}
       Add Byteman Rule     ${FAULT_INJ_DATANODE}    ${rule_file}
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to