Skip to content

Commit

Permalink
Fix nightly issues and upgrade docker
Browse files Browse the repository at this point in the history
Save base image for API tests in E2E image, it will be loaded every time
when building a local image, and all images will be cleared right after
they were pulled or pushed.

Signed-off-by: danfengliu <[email protected]>
  • Loading branch information
danfengliu committed Feb 23, 2021
1 parent a09235d commit d738117
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import absolute_import

import unittest
import time

from testutils import ADMIN_CLIENT, suppress_urllib3_warning
from testutils import harbor_server
Expand Down Expand Up @@ -72,14 +73,14 @@ def testProjectLevelPolicyContentTrust(self):
docker_image_clean_all()
#5. Pull image(IA) successfully;
pull_harbor_image(harbor_server, admin_name, admin_password, TestProjects.repo_name, tag)

docker_image_clean_all()
self.project.get_project(TestProjects.project_content_trust_id)
#6. Enable content trust in project(PA) configuration;
self.project.update_project(TestProjects.project_content_trust_id, metadata = {"enable_content_trust": "true"}, **TestProjects.USER_CONTENT_TRUST_CLIENT)
self.project.get_project(TestProjects.project_content_trust_id)

#7. Pull image(IA) failed and the reason is "The image is not signed in Notary".
docker_image_clean_all()
time.sleep(30)
pull_harbor_image(harbor_server, admin_name, admin_password, TestProjects.repo_name, tag, expected_error_message = "The image is not signed in Notary")

if __name__ == '__main__':
Expand Down
23 changes: 23 additions & 0 deletions tests/resources/Docker-Util.robot
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,29 @@ Start Docker Daemon Locally
Sleep 2s
[Return] ${handle}
Restart Docker Daemon Locally
FOR ${IDX} IN RANGE 5
${pid}= Run pidof dockerd
Exit For Loop If '${pid}' == '${EMPTY}'
${result}= Run Process kill ${pid} shell=True
Log To Console Kill docker process: ${result}
Sleep 2s
END
${pid}= Run pidof dockerd
Should Be Equal As Strings '${pid}' '${EMPTY}'
OperatingSystem.File Should Exist /usr/local/bin/dockerd-entrypoint.sh
${result}= Run Process rm -rf /var/lib/docker/* shell=True
Log To Console Clear /var/lib/docker: ${result}
${handle}= Start Process /usr/local/bin/dockerd-entrypoint.sh dockerd>./daemon-local.log 2>&1 shell=True
Process Should Be Running ${handle}
FOR ${IDX} IN RANGE 5
${pid}= Run pidof dockerd
Exit For Loop If '${pid}' != '${EMPTY}'
Sleep 2s
END
Sleep 2s
[Return] ${handle}
Start Containerd Daemon Locally
${handle}= Start Process containerd > ./daemon-local.log 2>&1 & shell=True
FOR ${IDX} IN RANGE 5
Expand Down
16 changes: 8 additions & 8 deletions tests/resources/Harbor-Pages/Project.robot
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ Navigate To Projects
Project Should Display
[Arguments] ${projectname}
Retry Wait Element xpath=//projects//list-project//clr-dg-cell/a[contains(.,'${projectname}')]
Retry Wait Element xpath=//project//list-project//clr-dg-cell/a[contains(.,'${projectname}')]
Project Should Not Display
[Arguments] ${projectname}
Retry Wait Until Page Not Contains Element xpath=//projects//list-project//clr-dg-cell/a[contains(.,'${projectname}')]
Retry Wait Until Page Not Contains Element xpath=//project//list-project//clr-dg-cell/a[contains(.,'${projectname}')]
Search Private Projects
Retry Element Click xpath=//select
Expand Down Expand Up @@ -334,27 +334,27 @@ Retry Get Statics
[Return] ${ret}
Get Statics Private Repo
${privaterepo}= Retry Get Statics //projects/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[2]/div[2]/statistics/div/span[1]
${privaterepo}= Retry Get Statics //project/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[2]/div[2]/statistics/div/span[1]
[Return] ${privaterepo}
Get Statics Private Project
${privateproj}= Retry Get Statics //projects/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[2]/div[1]/statistics/div/span[1]
${privateproj}= Retry Get Statics //project/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[2]/div[1]/statistics/div/span[1]
[Return] ${privateproj}
Get Statics Public Repo
${publicrepo}= Retry Get Statics //projects/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[3]/div[2]/statistics/div/span[1]
${publicrepo}= Retry Get Statics //project/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[3]/div[2]/statistics/div/span[1]
[Return] ${publicrepo}
Get Statics Public Project
${publicproj}= Retry Get Statics //projects/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[3]/div[1]/statistics/div/span[1]
${publicproj}= Retry Get Statics //project/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[3]/div[1]/statistics/div/span[1]
[Return] ${publicproj}
Get Statics Total Repo
${totalrepo}= Retry Get Statics //projects/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[4]/div[2]/statistics/div/span[1]
${totalrepo}= Retry Get Statics //project/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[4]/div[2]/statistics/div/span[1]
[Return] ${totalrepo}
Get Statics Total Project
${totalproj}= Retry Get Statics //projects/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[4]/div[1]/statistics/div/span[1]
${totalproj}= Retry Get Statics //project/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[4]/div[1]/statistics/div/span[1]
[Return] ${totalproj}
Input Count Quota
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/Harbor-Pages/Project_Elements.robot
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ${project_tag_immutability_switch} //project-detail/app-tag-feature-integration
${create_project_CANCEL_button_xpath} xpath=//button[contains(.,'CANCEL')]
${create_project_OK_button_xpath} xpath=//button[contains(.,'OK')]
${delete_confirm_btn} xpath=//button[contains(.,'DELETE')]
${project_statistics_private_repository_icon} xpath=//projects/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[2]/div[2]/statistics/div/span[1]
${project_statistics_private_repository_icon} xpath=//project/div/div/div[1]/div/statistics-panel/div/div[2]/div[1]/div[2]/div[2]/statistics/div/span[1]
${project_statistics_total_projects_icon} xpath=//div[contains(@class, 'statistic-column-block') and contains(., 'TOTAL')]//div[1]/statistics//span[contains(@class, 'statistic-data')]
${repo_delete_confirm_btn} xpath=//clr-modal//button[2]
${repo_retag_confirm_dlg} css=${modal-dialog}
Expand Down
9 changes: 5 additions & 4 deletions tests/robot-cases/Group0-BAT/API_DB.robot
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ Test Case - Garbage Collection
[Tags] gc
Harbor API Test ./tests/apitests/python/test_garbage_collection.py

Test Case - Project Level Policy Content Trust
[Tags] content_trust
Restart Docker Daemon Locally
Harbor API Test ./tests/apitests/python/test_project_level_policy_content_trust.py

Test Case - Add Private Project Member and Check User Can See It
[Tags] private_member
Harbor API Test ./tests/apitests/python/test_add_member_to_private_project.py
Expand Down Expand Up @@ -156,7 +161,3 @@ Test Case - P2P
Test Case - Metrics
[Tags] metrics
Harbor API Test ./tests/apitests/python/test_verify_metrics_enabled.py

Test Case - Project Level Policy Content Trust
[Tags] content_trust
Harbor API Test ./tests/apitests/python/test_project_level_policy_content_trust.py

0 comments on commit d738117

Please sign in to comment.