-
Notifications
You must be signed in to change notification settings - Fork 605
HDDS-15227. Add robot test for Lifecycle #10242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ChenSammi
wants to merge
5
commits into
apache:HDDS-8342
Choose a base branch
from
ChenSammi:HDDS-15227
base: HDDS-8342
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ecce837
HDDS-15227. Add lifecycle robot test
ChenSammi 0aa839e
add --service-id
ChenSammi 0f1f859
remove OM_SERVICE_ID redefinition
ChenSammi b8406c6
add back OM_SERVICE_ID definition
ChenSammi 23741ea
add new lifecycle directory and move robot test to it
ChenSammi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
hadoop-ozone/dist/src/main/compose/ozonesecure-ha/test-om-lifecycle.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #!/usr/bin/env bash | ||
| # 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. | ||
|
|
||
| #suite:HA-secure | ||
|
|
||
| set -u -o pipefail | ||
|
|
||
| COMPOSE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
| export COMPOSE_DIR | ||
|
|
||
| export SECURITY_ENABLED=true | ||
| export OM_SERVICE_ID="omservice" | ||
| export SCM=scm1.org | ||
|
|
||
| # shellcheck source=/dev/null | ||
| source "$COMPOSE_DIR/../testlib.sh" | ||
|
|
||
| start_docker_env | ||
|
|
||
| execute_robot_test s3g kinit.robot | ||
|
|
||
| execute_robot_test s3g lifecycle/om-lifecycle.robot | ||
|
|
||
| execute_robot_test s3g s3/bucketlifecycle.robot |
119 changes: 119 additions & 0 deletions
119
hadoop-ozone/dist/src/main/smoketest/lifecycle/om-lifecycle.robot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| # 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 Ozone admin om lifecycle commands | ||
| Library OperatingSystem | ||
| Resource ../commonlib.robot | ||
| Test Timeout 5 minutes | ||
|
|
||
| *** Variables *** | ||
| ${OM_SERVICE_ID} %{OM_SERVICE_ID} | ||
|
|
||
| *** Test Cases *** | ||
| Test Lifecycle Status | ||
| ${output} = Execute ozone admin om lifecycle status --service-id '${OM_SERVICE_ID}' | ||
| Should Contain ${output} IsEnabled | ||
| Should Contain ${output} IsSuspended | ||
|
|
||
| Test Lifecycle Suspend And Resume | ||
| ${output} = Execute ozone admin om lifecycle suspend --service-id '${OM_SERVICE_ID}' | ||
| Should Contain ${output} Lifecycle Service has been suspended | ||
|
|
||
| ${output} = Execute ozone admin om lifecycle status --service-id '${OM_SERVICE_ID}' | ||
| Should Contain ${output} IsSuspended: true | ||
|
|
||
| ${output} = Execute ozone admin om lifecycle resume --service-id '${OM_SERVICE_ID}' | ||
| Should Contain ${output} Lifecycle Service has been resumed | ||
|
|
||
| ${output} = Execute ozone admin om lifecycle status --service-id '${OM_SERVICE_ID}' | ||
| Should Contain ${output} IsSuspended: false | ||
|
|
||
| Test Lifecycle Status After Leader Transfer | ||
| ${output} = Execute ozone admin om roles --service-id '${OM_SERVICE_ID}' | ||
| ${is_ha} = Run Keyword And Return Status Should Contain ${output} FOLLOWER | ||
| IF ${is_ha} | ||
| ${output} = Execute ozone admin om lifecycle suspend --service-id '${OM_SERVICE_ID}' | ||
| Should Contain ${output} Lifecycle Service has been suspended | ||
|
|
||
| ${output} = Execute ozone admin om transfer --service-id '${OM_SERVICE_ID}' -r | ||
| Should Contain ${output} Transfer leadership successfully | ||
|
|
||
| ${output} = Execute ozone admin om lifecycle status --service-id '${OM_SERVICE_ID}' | ||
| Should Contain ${output} IsSuspended: true | ||
|
|
||
| ${output} = Execute ozone admin om lifecycle resume --service-id '${OM_SERVICE_ID}' | ||
| Should Contain ${output} Lifecycle Service has been resumed | ||
|
|
||
| ${output} = Execute ozone admin om lifecycle status --service-id '${OM_SERVICE_ID}' | ||
| Should Contain ${output} IsSuspended: false | ||
| ELSE | ||
| Pass Execution Cluster is not HA, skipping leader transfer test | ||
| END | ||
|
|
||
| Test Lifecycle Suspend And Resume Requires Admin | ||
| # This test verifies that suspend and resume commands require admin privileges | ||
| # while the status command does not. | ||
| # The Requires admin privilege keyword automatically switches to testuser2 via kinit | ||
| # in secure environments and verifies access is denied. | ||
|
|
||
| Get Security Enabled From Config | ||
| IF '${SECURITY_ENABLED}' == 'true' | ||
| # First switch to non-admin user | ||
| Kinit test user testuser2 testuser2.keytab | ||
|
|
||
| # Status should work for non-admin | ||
| ${output} = Execute and checkrc ozone admin om lifecycle status --service-id '${OM_SERVICE_ID}' 0 | ||
| Should Contain ${output} IsEnabled | ||
|
|
||
| # Suspend should fail for non-admin | ||
| Access should be denied ozone admin om lifecycle suspend --service-id '${OM_SERVICE_ID}' | ||
|
|
||
| # Resume should fail for non-admin | ||
| Access should be denied ozone admin om lifecycle resume --service-id '${OM_SERVICE_ID}' | ||
|
|
||
| # Switch back to admin user for subsequent tests | ||
| Kinit test user testuser testuser.keytab | ||
|
|
||
| # Verify admin can suspend and resume | ||
| ${output} = Execute and checkrc ozone admin om lifecycle suspend --service-id '${OM_SERVICE_ID}' 0 | ||
| Should Contain ${output} Lifecycle Service has been suspended | ||
|
|
||
| ${output} = Execute and checkrc ozone admin om lifecycle resume --service-id '${OM_SERVICE_ID}' 0 | ||
| Should Contain ${output} Lifecycle Service has been resumed | ||
| ELSE | ||
| # In non-secure environments, we can test by passing a different user via HADOOP_USER_NAME | ||
|
|
||
| # Status should work for non-admin | ||
| ${output} = Execute and checkrc env HADOOP_USER_NAME=testuser2 ozone admin om lifecycle status --service-id '${OM_SERVICE_ID}' 0 | ||
| Should Contain ${output} IsEnabled | ||
|
|
||
| # Suspend should fail for non-admin | ||
| ${output} = Execute and checkrc env HADOOP_USER_NAME=testuser2 ozone admin om lifecycle suspend --service-id '${OM_SERVICE_ID}' 255 | ||
| Should Contain ${output} Access denied | ||
| Should Contain ${output} Superuser privilege is required | ||
|
|
||
| # Resume should fail for non-admin | ||
| ${output} = Execute and checkrc env HADOOP_USER_NAME=testuser2 ozone admin om lifecycle resume --service-id '${OM_SERVICE_ID}' 255 | ||
| Should Contain ${output} Access denied | ||
| Should Contain ${output} Superuser privilege is required | ||
|
|
||
| # Verify admin (default user) can suspend and resume | ||
| ${output} = Execute and checkrc ozone admin om lifecycle suspend --service-id '${OM_SERVICE_ID}' 0 | ||
| Should Contain ${output} Lifecycle Service has been suspended | ||
|
|
||
| ${output} = Execute and checkrc ozone admin om lifecycle resume --service-id '${OM_SERVICE_ID}' 0 | ||
| Should Contain ${output} Lifecycle Service has been resumed | ||
| END |
53 changes: 53 additions & 0 deletions
53
hadoop-ozone/dist/src/main/smoketest/s3/bucketlifecycle.robot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # 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 S3 gateway test with aws cli for bucket lifecycle | ||
| Library OperatingSystem | ||
| Library String | ||
| Resource ../commonlib.robot | ||
| Resource commonawslib.robot | ||
| Test Timeout 5 minutes | ||
| Suite Setup Setup s3 tests | ||
|
|
||
| *** Variables *** | ||
| ${ENDPOINT_URL} http://s3g:9878 | ||
| ${BUCKET} generated | ||
|
|
||
| *** Test Cases *** | ||
|
|
||
| Set bucket lifecycle configuration | ||
| ${bucket} = Create bucket | ||
| ${lifecycle_json} = Set Variable {"Rules": [{"ID": "Rule1", "Prefix": "prefix1/", "Status": "Enabled", "Expiration": {"Days": 1}}]} | ||
| ${result} = Execute AWSS3APICli put-bucket-lifecycle-configuration --bucket ${bucket} --lifecycle-configuration '${lifecycle_json}' | ||
| Should Be Empty ${result} | ||
|
|
||
| Get bucket lifecycle configuration | ||
| ${bucket} = Create bucket | ||
| ${lifecycle_json} = Set Variable {"Rules": [{"ID": "Rule1", "Prefix": "prefix1/", "Status": "Enabled", "Expiration": {"Days": 1}}]} | ||
| ${result} = Execute AWSS3APICli put-bucket-lifecycle-configuration --bucket ${bucket} --lifecycle-configuration '${lifecycle_json}' | ||
| ${result} = Execute AWSS3APICli get-bucket-lifecycle-configuration --bucket ${bucket} | ||
| Should contain ${result} Rule1 | ||
| Should contain ${result} prefix1/ | ||
| Should contain ${result} Enabled | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can add |
||
|
|
||
| Delete bucket lifecycle configuration | ||
| ${bucket} = Create bucket | ||
| ${lifecycle_json} = Set Variable {"Rules": [{"ID": "Rule1", "Prefix": "prefix1/", "Status": "Enabled", "Expiration": {"Days": 1}}]} | ||
| ${result} = Execute AWSS3APICli put-bucket-lifecycle-configuration --bucket ${bucket} --lifecycle-configuration '${lifecycle_json}' | ||
| ${result} = Execute AWSS3APICli delete-bucket-lifecycle --bucket ${bucket} | ||
| Should Be Empty ${result} | ||
| ${result} = Execute AWSS3APICli and checkrc get-bucket-lifecycle-configuration --bucket ${bucket} 255 | ||
| Should contain ${result} NoSuchLifecycleConfiguration | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test will be run multiple times here.
We can add
no-bucket-typeor use the${BUCKET}to execute this by different bucket Layout