npx playwright install
The instructions below assume Headlamp is running locally in-cluster with minikube.
# Determine if the headlamp addon is enabled
minikube addons list
# If the addon is not already enabled run the following command
minikube addons enable headlamp
# Generate the URL needed for the HEADLAMP_TEST_URL environment variable
# note: Make sure to use the URL created after the " Starting tunnel for service headlamp. " message
minikube service headlamp -n headlamp
# Open the browser to the URL generated above, it should direct you to a page waiting for a token
# run in a separate terminal...
export HEADLAMP_TEST_URL= # from the "minikube service headlamp -n headlamp" command directly above.
# Create a token for the tests to use
export HEADLAMP_TOKEN=$(kubectl create token headlamp --duration 24h -n headlamp)
# To see the token to login via the web browser
echo $HEADLAMP_TOKENNow with those two environment variables set we can run the tests.
IMPORTANT: Make sure that the following npx commands are ran in the same terminal session as the environment variables were set.
-
from the terminal navigate to the e2e-tests directory within the headlamp repository
cd headlamp/e2e-tests -
run the following command
npx playwright testYou can run a single test with the grep flag:
-
from the terminal navigate to the e2e-tests directory within the headlamp repository
cd headlamp/e2e-tests -
run the following command
npx playwright test -g "404 page is present"- You can run a single test in a real browser with the
--headedflag, this can be useful if you want to troubleshoot errors with a visual of the test.
npx playwright test -g "404 page is present" --headed-
The Playwright UI mode is similar to the VSCode extension where you are able to see the tests run in real-time and can be a great way to troubleshoot issues with the tests. (for more information see: https://playwright.dev/docs/test-ui-mode)
-
You can run the tests in UI mode by adding the
--uiflag to the command.- command
npx playwright test --ui
- command
-
This will open a browser window that will show the test running in real-time, this can be ran as a substitute or in pair with the VS code extension.
-
If you wish to see the test run in a real browser, you can add the
--headedflag to the command. -
You can also modify the playwright.config.ts file to change the browser that is used for the tests. You must be sure not to add this change to the repository when you push.
- within the playwright.config.ts file locate the
const config: PlaywrightTestConfigobject. within the object, modify the use object to contain a field for headless set to false ex.use: { ..., headless: false }property to run the tests in a real browser.
- within the playwright.config.ts file locate the
- You can modify the playwright.config.ts file to slow down the tests. You must be sure not to add this change to the repository when you push.
- within the playwright.config.ts file locate the
const config: PlaywrightTestConfigobject. within the object, modify the use object to contain a field forlaunchOptions: { slowMo: }set to a number of milliseconds ex.use: { ..., launchOptions: { slowMo: 1000 }property to slow down the tests to take 1 second between each step.
- within the playwright.config.ts file locate the
- Open a new Ubuntu terminal window.
- Verify the installation of Azure CLI on your machine by typing:
az version - Log into your Azure account with the following command:
az login
- Verify the installation of Azure CLI on your machine by typing:
-
Open another terminal window.
- Before running the script, replace
VM_NAMEandRESOURCE_GROUPwith your specific values. You can find the default script template or use a GitHub gist link.
- Before running the script, replace
-
Modify and run the script:
- Replace the placeholders in the script with actual values for
VM_NAMEandRESOURCE_GROUP. - Execute the script using the following command:
curl -sSfL https://headlamp.dev/blog/2024/04/user-added-cluster-support-in-shared-headlamp-deployments/create-azurevm.sh | bash
- Replace the placeholders in the script with actual values for
- Use a web browser to access the Azure portal.
- Navigate to the resource page and search for the
VM_NAMEyou used in the script to check if the VM was successfully created.
- Navigate to the resource page and search for the
-
SSH into the newly created VM.
- Use this command to connect:
ssh your-username@your-vm-ip
- Use this command to connect:
-
Install essential tools on the VM:
- Install Docker:
You can find more details on the official Docker installation guide.
sudo apt install docker.io - Install Git:
sudo apt install git - Clone the Headlamp repository:
git clone https://github.com/headlamp-k8s/headlamp
- Install Docker:
-
Navigate to the workflow file and build the Headlamp image:
- Inside
.github/workflows/build-container.ymlis the source line we need, locate the step for building the image and run in your terminal:DOCKER_IMAGE_VERSION=latest make image
- Inside
-
Tag and push the Docker image to a registry (e.g., ttl.sh):
- Tag your Docker image and push it using ttl.sh:
docker tag headlamp-k8s/headlamp ttl.sh/headlamp-k8s/headlamp docker push ttl.sh/headlamp-k8s/headlamp
- Tag your Docker image and push it using ttl.sh:
-
Pull the Docker image to your local machine:
- After pushing, exit back to your local machine and pull the image:
docker pull ttl.sh/headlamp-k8s/headlamp
- After pushing, exit back to your local machine and pull the image:
-
Ensure Minikube is running on your local machine.
-
Update the Kubernetes Headlamp CI configuration:
- Navigate to
e2e-tests/kubernetes-headlamp-ci.yml. - Change the
imagefield underspec.containersto match the Docker image you pulled:image: ttl.sh/headlamp-k8s/headlamp
- Navigate to
-
Deploy to the cluster and run end-to-end tests:
- Follow the steps outlined in
Deploy to clusterandRun e2e testssections to execute these actions on your local machine.
- Follow the steps outlined in