bump jest and fix integration test (#55)
This commit is contained in:
parent
09392910a9
commit
d893f27da9
4 changed files with 226 additions and 2787 deletions
10
.github/workflows/integration-tests.yml
vendored
10
.github/workflows/integration-tests.yml
vendored
|
@ -3,11 +3,11 @@ on: # rebuild any PRs and main branch changes
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- 'releases/*'
|
- "releases/*"
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- 'releases/*'
|
- "releases/*"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
run-integration-test:
|
run-integration-test:
|
||||||
|
@ -32,18 +32,18 @@ jobs:
|
||||||
- uses: actions/setup-python@v2
|
- uses: actions/setup-python@v2
|
||||||
name: Install Python
|
name: Install Python
|
||||||
with:
|
with:
|
||||||
python-version: '3.x'
|
python-version: "3.x"
|
||||||
|
|
||||||
- name: Install requests library
|
- name: Install requests library
|
||||||
run: pip install requests
|
run: pip install requests
|
||||||
|
|
||||||
- name: Validate kubectl setup
|
- name: Validate kubectl setup
|
||||||
run: python test/validate-kubectl.py latest
|
run: python test/validate-kubectl.py !v1.15.1
|
||||||
|
|
||||||
- name: Setup kubectl
|
- name: Setup kubectl
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
version: 'v1.15.1'
|
version: "v1.15.1"
|
||||||
|
|
||||||
- name: Validate kubectl setup
|
- name: Validate kubectl setup
|
||||||
run: python test/validate-kubectl.py 'v1.15.1'
|
run: python test/validate-kubectl.py 'v1.15.1'
|
||||||
|
|
2907
package-lock.json
generated
2907
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -24,8 +24,8 @@
|
||||||
"@types/node": "^12.0.4",
|
"@types/node": "^12.0.4",
|
||||||
"@vercel/ncc": "^0.33.1",
|
"@vercel/ncc": "^0.33.1",
|
||||||
"jest": "^26.0.1",
|
"jest": "^26.0.1",
|
||||||
"@types/jest": "^25.2.2",
|
"@types/jest": "^26.0.1",
|
||||||
"ts-jest": "^25.5.1",
|
"ts-jest": "^26.0.1",
|
||||||
"typescript": "3.9.2"
|
"typescript": "3.9.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,31 +1,65 @@
|
||||||
import os, sys, json, requests, time
|
import os
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
|
import requests
|
||||||
|
import time
|
||||||
|
|
||||||
version_to_check = sys.argv[1]
|
|
||||||
version_info = None
|
|
||||||
PASSED = False
|
|
||||||
|
|
||||||
try:
|
def get_latest_version():
|
||||||
print('kubectl version --client -o json')
|
|
||||||
version_info = json.load(os.popen('kubectl version --client -o json'))
|
|
||||||
except Exception as ex:
|
|
||||||
sys.exit('kubectl not installed')
|
|
||||||
|
|
||||||
try:
|
|
||||||
if version_to_check == 'latest':
|
|
||||||
response = None
|
response = None
|
||||||
time_to_sleep = 2
|
time_to_sleep = 2
|
||||||
for _ in range(10):
|
for _ in range(10):
|
||||||
response = requests.get('https://storage.googleapis.com/kubernetes-release/release/stable.txt')
|
response = requests.get(
|
||||||
|
'https://storage.googleapis.com/kubernetes-release/release/stable.txt')
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
break
|
break
|
||||||
print('Failed to obtain latest version info, retrying.')
|
print('Failed to obtain latest version info, retrying.')
|
||||||
time.sleep(time_to_sleep)
|
time.sleep(time_to_sleep)
|
||||||
time_to_sleep *= 2
|
time_to_sleep *= 2
|
||||||
version_to_check = response.content.decode('utf-8')
|
return response.content.decode('utf-8')
|
||||||
PASSED = True if version_info['clientVersion']['gitVersion'] == version_to_check else False
|
|
||||||
except:
|
|
||||||
|
version_arg = sys.argv[1]
|
||||||
|
installed_version_info = None
|
||||||
|
PASSED = True
|
||||||
|
|
||||||
|
try:
|
||||||
|
print('kubectl version --client -o json')
|
||||||
|
installed_version_info = json.load(
|
||||||
|
os.popen('kubectl version --client -o json'))
|
||||||
|
print(
|
||||||
|
f'installed version: {installed_version_info["clientVersion"]["gitVersion"]}')
|
||||||
|
except Exception as ex:
|
||||||
|
sys.exit('kubectl not installed')
|
||||||
|
|
||||||
|
try:
|
||||||
|
installed_version = installed_version_info['clientVersion']['gitVersion']
|
||||||
|
# NOT Match
|
||||||
|
if version_arg[0] == '!':
|
||||||
|
undesired_version = version_arg[1:]
|
||||||
|
print(f'undesired version: {undesired_version}')
|
||||||
|
if installed_version == undesired_version:
|
||||||
|
print(
|
||||||
|
f'installed version ({installed_version}) matches undesire {undesired_version} - FAIL')
|
||||||
|
PASSED = False
|
||||||
|
# Exact Match
|
||||||
|
else:
|
||||||
|
if version_arg == 'latest':
|
||||||
|
print('checking latest version')
|
||||||
|
desired_version = get_latest_version()
|
||||||
|
else:
|
||||||
|
desired_version = version_arg
|
||||||
|
|
||||||
|
print(f'desired version: {desired_version}')
|
||||||
|
if installed_version != desired_version:
|
||||||
|
print(
|
||||||
|
f'installed version ({installed_version}) does not match desired ({desired_version}) - FAIL')
|
||||||
|
PASSED = False
|
||||||
|
except Exception as ex:
|
||||||
|
print(f'Exception: {ex}')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if not PASSED:
|
if not PASSED:
|
||||||
sys.exit('Setting up of '+version_to_check+' kubectl failed')
|
sys.exit('Setting up of '+version_arg+' kubectl failed')
|
||||||
print('Test passed')
|
print('Test passed')
|
||||||
|
sys.exit()
|
||||||
|
|
Loading…
Reference in a new issue