bump jest and fix integration test (#55)

This commit is contained in:
David Gamero 2022-06-21 08:54:22 -04:00 committed by GitHub
parent 09392910a9
commit d893f27da9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 226 additions and 2787 deletions

View file

@ -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'

2911
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -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"
} }
} }

View file

@ -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 def get_latest_version():
PASSED = False response = None
time_to_sleep = 2
for _ in range(10):
response = requests.get(
'https://storage.googleapis.com/kubernetes-release/release/stable.txt')
if response.status_code == 200:
break
print('Failed to obtain latest version info, retrying.')
time.sleep(time_to_sleep)
time_to_sleep *= 2
return response.content.decode('utf-8')
version_arg = sys.argv[1]
installed_version_info = None
PASSED = True
try: try:
print('kubectl version --client -o json') print('kubectl version --client -o json')
version_info = json.load(os.popen('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: except Exception as ex:
sys.exit('kubectl not installed') sys.exit('kubectl not installed')
try: try:
if version_to_check == 'latest': installed_version = installed_version_info['clientVersion']['gitVersion']
response = None # NOT Match
time_to_sleep = 2 if version_arg[0] == '!':
for _ in range(10): undesired_version = version_arg[1:]
response = requests.get('https://storage.googleapis.com/kubernetes-release/release/stable.txt') print(f'undesired version: {undesired_version}')
if response.status_code == 200: if installed_version == undesired_version:
break print(
print('Failed to obtain latest version info, retrying.') f'installed version ({installed_version}) matches undesire {undesired_version} - FAIL')
time.sleep(time_to_sleep) PASSED = False
time_to_sleep *= 2 # Exact Match
version_to_check = response.content.decode('utf-8') else:
PASSED = True if version_info['clientVersion']['gitVersion'] == version_to_check else False if version_arg == 'latest':
except: 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()