...
 
Commits (3)
......@@ -14,7 +14,6 @@ stages:
- test_clean
- deploy
- deploy_test
- cleanup
# ===========================================
# Generate the static website
......@@ -24,7 +23,7 @@ generate hugo:
- git submodule sync --recursive
- git submodule update --init --recursive
stage: generate
image: jojomi/hugo:0.69.0
image: jojomi/hugo:0.71.0
tags:
#- asksven-homelab-prd-public
- asksven-homelab-dev
......@@ -47,15 +46,6 @@ lint_dockerfile:
script:
- hadolint Dockerfile
# show env:
# stage: env
# image: docker:19.03.11
# variables:
# PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7"
# DOCKER_CLI_EXPERIMENTAL: "enabled"
# script:
# - env
docker buildx:
stage: build
image: docker:19.03.11
......@@ -105,7 +95,7 @@ docker buildx:
- ops
.test_template: &test_template
image: joyzoursky/python-chromedriver:3.6
image: joyzoursky/python-chromedriver:3.8-selenium
before_script:
- pip install -r tests/webtests_1/requirements.txt
tags:
......@@ -118,16 +108,11 @@ docker buildx:
paths:
- tests/output
.cleanup_template: &cleanup_template
image: codemelter/docker-kubernetes-deploy
script:
- echo We are going to delete namespace $NAMESPACE
- kubectl delete ns ${NAMESPACE}
.status_template: &status_template
image: codemelter/docker-kubernetes-deploy
script:
- kubectl describe pods,deployment,ing --namespace=${NAMESPACE}
- kubectl get pods,deployment,ing --namespace=${NAMESPACE}
- kubectl describe pods,deployment,ing --namespace=${NAMESPACE}
# ===========================================
# Test stage:
......@@ -170,18 +155,6 @@ ui test temp deployment:
# we need to pass the URL to test
BASE_URL: https://blog-${CI_BUILD_REF}.asksven.io
cleanup temp deployment:
stage: test_clean
<<: *cleanup_template
tags:
- asksven-homelab-prd-public
#- asksven-homelab-dev
variables:
DEPLOY_ENV: temp
# we deployed to a temp name
NAMESPACE: ${CI_PROJECT_NAME}-${CI_BUILD_REF}
# ===========================================
# Deployment stage, either:
......@@ -249,18 +222,3 @@ status namespace:
tags:
- asksven-homelab-prd-public
#- asksven-homelab-dev
# ===========================================
# manual clean-up stage for !prd namespaces
# ===========================================
cleanup:
stage: cleanup
<<: *cleanup_template
tags:
- asksven-homelab-prd-public
#- asksven-homelab-dev
when: manual
except:
- master
\ No newline at end of file
......@@ -14,8 +14,7 @@ We have switched to multi-arch builds, that are run by `./local.sh`
## Run tests locally
1. Run container: `docker run -it -v $(pwd):/usr/workspace joyzoursky/python-chromedriver:3.6 /bin/bash`
2. Set `BASE_URL` env var: `export BASE_URL="https://blog-stage.asksven.io"`
3. Go to directory: `cd /usr/workspace/webtests_1`
4. Run tests: `python -u selenium-python.py`
1. Run container: `docker run -it -v $(pwd):/usr/workspace joyzoursky/python-chromedriver:3.8-selenium /bin/bash`
1. Set `BASE_URL` env var: `export BASE_URL="https://blog-stage.asksven.io"`
1. Go to directory: `cd /usr/workspace/webtests_1`
1. Run tests: `python -u selenium-python.py`
......@@ -10,7 +10,6 @@
# $CI_BUILD_REF is the sha of the build, e.g. 1ecfd275763eff1d6b4844ea3168962458c9f27a and is used to tag the image
# $CI_COMMIT_REF_SLUG is the branch name
echo '---$TESTING:' ${TESTING}
echo '---$DEPLOY_ENV:' ${DEPLOY_ENV}
echo '---$NAMESPACE:' ${NAMESPACE}
echo '---$CI_COMMIT_REF_SLUG:' ${CI_COMMIT_REF_SLUG}
......@@ -35,14 +34,12 @@ echo '---$HOST1:' ${HOST1}
# $NAMESPACE is defined in .gitlab-ci.yaml
kubectl create namespace $NAMESPACE
COMMAND="kubectl create namespace $NAMESPACE"
if [ "$TESTING" = "1" ]
# Label temp namespaces with TTL 1d
if [ "$DEPLOY_ENV" = "temp" ]
then
echo '>>>would execute command:' ${COMMAND}
else
eval $COMMAND
kubectl annotate namespace $NAMESPACE janitor/ttl=1d
fi
K8S_DIR=./manifests
......@@ -59,12 +56,4 @@ do
done
COMMAND1="kubectl --namespace=$NAMESPACE apply -f ${TARGET_DIR}"
if [ "$TESTING" = "1" ]
then
echo '>>>would execute command:' ${COMMAND1}
else
eval $COMMAND1
fi
kubectl --namespace=$NAMESPACE apply -f ${TARGET_DIR}
\ No newline at end of file
#!/bin/bash
export TESTING=0
export NAMESPACE=blog-asksven-io
export DEPLOY_ENV=homelab # is either "production"or "development"
export CI_COMMIT_REF_SLUG=new
......
#!/bin/bash
export TESTING=1
export NAMESPACE=blog-asksven-io
export DEPLOY_ENV=production # is either "production"or "development"
export CI_COMMIT_REF_SLUG=master
......
......@@ -16,7 +16,7 @@ class TestTemplate(unittest.TestCase):
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
self.driver = webdriver.Chrome(chrome_options=chrome_options)
self.driver = webdriver.Chrome(options=chrome_options)
self.driver.implicitly_wait(10)
def tearDown(self):
......@@ -27,19 +27,22 @@ class TestTemplate(unittest.TestCase):
"""Open website"""
try:
self.driver.get(baseUrl)
self.driver.save_screenshot('../output/setup.png')
except NoSuchElementException as ex:
self.fail(ex.msg)
def test_case_1(self):
"""Find and click tags link"""
try:
self.driver.get(baseUrl)
el = self.driver.find_element_by_xpath("/html/body/section[1]/div/nav[2]/div/a[2]/h2")
el.click()
self.driver.save_screenshot('../output/tags.png')
self.driver.find_element_by_xpath("/html/body/section[1]")
except NoSuchElementException as ex:
self.fail(ex.msg)
# def test_case_1(self):
# """Find and click tags link"""
# try:
# self.driver.get(baseUrl)
# el = self.driver.find_element_by_xpath("/html/body/section[1]/div/nav[2]/div/a[2]/h2")
# el.click()
# self.driver.save_screenshot('../output/tags.png')
# except NoSuchElementException as ex:
# self.fail(ex.msg)
def test_case_2(self):
......@@ -58,11 +61,23 @@ class TestTemplate(unittest.TestCase):
self.driver.get(baseUrl)
el = self.driver.find_element_by_xpath("/html/body/section[1]/div/nav[1]/div[2]/nav/a[2]")
el.click()
self.driver.switch_to_window(self.driver.window_handles[1])
self.driver.switch_to.window(self.driver.window_handles[1])
self.driver.save_screenshot('../output/github.png')
except NoSuchElementException as ex:
self.fail(ex.msg)
def test_case_4(self):
"""Find and click about link"""
try:
self.driver.get(baseUrl)
el = self.driver.find_element_by_xpath("/html/body/section[1]/div/nav[1]/div[2]/nav/a[4]")
el.click()
self.driver.switch_to.window(self.driver.window_handles[1])
self.driver.save_screenshot('../output/about.png')
except NoSuchElementException as ex:
self.fail(ex.msg)
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(TestTemplate)
unittest.TextTestRunner(verbosity=2).run(suite)
\ No newline at end of file