Skip to content

Commit

Permalink
tests: make the custmozied chart tests consistent
Browse files Browse the repository at this point in the history
Signed-off-by: scnace <[email protected]>
  • Loading branch information
scbizu committed Oct 17, 2020
1 parent df7d422 commit 4d0417b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 61 deletions.
14 changes: 2 additions & 12 deletions acceptance_tests/helm.robot
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,11 @@ Test Helm integration
Upload test charts to ChartMuseum
Upload provenance files to ChartMuseum
Upload bad test charts to ChartMuseum
Upload test customized version charts to ChartMuseum
Upload bad provenance files to ChartMuseum
Able to update ChartMuseum repo
Helm search returns test charts
Able to fetch and verify test charts
Delete test charts from ChartMuseum
Delete customized version chart
Ensure customized version chart deleted
Able to update ChartMuseum repo
Helm search does not return test charts
Unable to fetch and verify test charts
Expand All @@ -79,21 +76,12 @@ Upload provenance files to ChartMuseum
Upload bad test charts to ChartMuseum
ChartMuseum.upload bad test charts

Upload test customized version charts to ChartMuseum
ChartMuseum.upload test more version charts

Upload bad provenance files to ChartMuseum
ChartMuseum.upload bad provenance files

Delete test charts from ChartMuseum
ChartMuseum.delete test charts

Delete customized version chart
ChartMuseum.delete test version charts

Ensure customized version chart deleted
ChartMuseum.delete get version chart

Able to add ChartMuseum as Helm chart repo
Helm.add chart repo
Helm.return code should be 0
Expand All @@ -110,6 +98,8 @@ Helm search returns test charts
Helm search does not return test charts
Helm.search for chart mychart
Helm.output does not contain mychart
Helm.search for chart mychart2
Helm.output does not contain mychart2

Able to fetch and verify test charts
Helm.fetch and verify chart mychart
Expand Down
49 changes: 1 addition & 48 deletions acceptance_tests/lib/ChartMuseum.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,6 @@ def upload_test_charts(self):
self.http_status_code_should_be(201, response.status_code)
os.chdir('../')

def upload_test_more_version_charts(self):
charts_endpoint = '%s/api/charts' % common.HELM_REPO_URL
testcharts_dir = os.path.join(self.rootdir, common.TESTMOREVERSIONCHARTS_DIR)
os.chdir(testcharts_dir)
for d in os.listdir('.'):
if not os.path.isdir(d):
continue
os.chdir(d)
tgzs = glob.glob('*.tgz')
for tgz in tgzs:
print(('Uploading more version chart package "%s"' % tgz))
with open(tgz, 'rb') as f:
response = requests.post(url=charts_endpoint, data=f.read())
print(('POST %s' % charts_endpoint))
print(('HTTP STATUS: %s' % response.status_code))
print(('HTTP CONTENT: %s' % response.content))
self.http_status_code_should_be(201, response.status_code)
os.chdir('../')

def upload_bad_test_charts(self):
charts_endpoint = '%s/api/charts' % common.HELM_REPO_URL
testcharts_dir = os.path.join(self.rootdir, common.TESTBADCHARTS_DIR)
Expand Down Expand Up @@ -170,6 +151,7 @@ def delete_test_charts(self):
testcharts_dir = os.path.join(self.rootdir, common.TESTCHARTS_DIR)
os.chdir(testcharts_dir)
for d in os.listdir('.'):
# delete all charts inside /mychart (also includes mychart2)
if not os.path.isdir(d):
continue
os.chdir(d)
Expand All @@ -186,32 +168,3 @@ def delete_test_charts(self):
print(('HTTP CONTENT: %s' % response.content))
self.http_status_code_should_be(200, response.status_code)
os.chdir('../')

def delete_test_version_charts(self):
endpoint = '%s/api/charts' % common.HELM_REPO_URL
testcharts_dir = os.path.join(self.rootdir, common.TESTMOREVERSIONCHARTS_DIR)
os.chdir(testcharts_dir)
f = open("Chart.yaml","r")
name = ''
version = ''
for lines in f:
v_prefix = 'version: '
name_prefix = 'name: '
if lines.startswith(v_prefix):
version = lines[len(v_prefix):]
elif lines.startswith(name_prefix):
name = lines[len(name_prefix):]
print(('Delete test chart "%s-%s"' % (name, version)))
epoint = '%s/%s/%s' % (endpoint, name, version)
response = requests.delete(url=epoint)
print(('HTTP STATUS: %s' % response.status_code))
print(('HTTP CONTENT: %s' % response.content))
self.http_status_code_should_be(200, response.status_code)
os.chdir('../')

def get_version_chart(self):
# checks if the chart still exists
endpoint = '%s/api/charts' % common.HELM_REPO_URL
epoint = '%s/%s/%s' % (endpoint,"mychart2", "0.1.0-SNAPSHOT-1")
response = requests.get(url=epoint)
self.http_status_code_should_be(404, response.status_code)
1 change: 0 additions & 1 deletion acceptance_tests/lib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
HELM_REPO_URL = 'http://localhost:%d' % PORT
TESTCHARTS_DIR = 'testdata/charts'
TESTBADCHARTS_DIR = 'testdata/badcharts'
TESTMOREVERSIONCHARTS_DIR = 'testdata/charts/mychart2'
ACCEPTANCE_DIR = '.acceptance/'
STORAGE_DIR = os.path.join(ACCEPTANCE_DIR, 'storage/')
KEYRING = 'testdata/pgp/helm-test-key.pub'
Expand Down

0 comments on commit 4d0417b

Please sign in to comment.