Skip to content

Commit

Permalink
Add jenkins e2e jobs (#20)
Browse files Browse the repository at this point in the history
Add jenkins e2e jobs for Theia

* Update ci git settings
* Adjust timeout settings for e2e ci
* Remove unused code in e2e script
* Update ci settings for github
* Remove unused code in e2e script
* Add image pre-load for e2e test
* Update e2e job settings
* Fix markdown lint error
* Use yq to update config values in e2e config
* Add doc for cred on jenkins server
* Update doc and script for e2e config
* Update doc for e2e jobs
* Update jenkins ci script
* Remove unused code in jenkins ci script
* Update ci jobs config
  • Loading branch information
hangyan authored May 20, 2022
1 parent 0e0ecd3 commit a7c4af3
Show file tree
Hide file tree
Showing 10 changed files with 937 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ bin
plugins/grafana-custom-plugins/grafana-sankey-plugin/node_modules/
plugins/grafana-custom-plugins/grafana-sankey-plugin/dist/
plugins/grafana-custom-plugins/grafana-sankey-plugin/coverage/
ci/jenkins/jobs/defaults.yaml
.idea/
207 changes: 207 additions & 0 deletions ci/cluster-api/vsphere/templates/cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
labels:
cluster.x-k8s.io/cluster-name: CLUSTERNAME
name: CLUSTERNAME
namespace: CLUSTERNAMESPACE
spec:
clusterNetwork:
pods:
cidrBlocks:
- 192.168.0.0/16
controlPlaneRef:
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: KubeadmControlPlane
name: CLUSTERNAME
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: VSphereCluster
name: CLUSTERNAME
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: VSphereCluster
metadata:
name: CLUSTERNAME
namespace: CLUSTERNAMESPACE
spec:
controlPlaneEndpoint:
host: CONTROLVIP
port: 6443
identityRef:
kind: Secret
name: CLUSTERNAME
server: VCENTERNAME
thumbprint: THUMBPRINTVALUE
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: VSphereMachineTemplate
metadata:
name: CLUSTERNAME
namespace: CLUSTERNAMESPACE
spec:
template:
spec:
cloneMode: linkedClone
datacenter: DATACENTERNAME
datastore: DATASTORE
diskGiB: 25
folder: VMFOLDERNAME
memoryMiB: 8192
network:
devices:
- dhcp4: true
networkName: NETWORKNAME
numCPUs: 4
resourcePool: RESOURCEPOOLPATH
server: VCENTERNAME
storagePolicyName: ""
template: OVATEMPLATENAME
thumbprint: THUMBPRINTVALUE
---
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: KubeadmControlPlane
metadata:
name: CLUSTERNAME
namespace: CLUSTERNAMESPACE
spec:
kubeadmConfigSpec:
files:
- content: |
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
name: kube-vip
namespace: kube-system
spec:
containers:
- args:
- start
env:
- name: vip_arp
value: "true"
- name: vip_leaderelection
value: "true"
- name: vip_address
value: CONTROLVIP
- name: vip_interface
value: eth0
- name: vip_leaseduration
value: "15"
- name: vip_renewdeadline
value: "10"
- name: vip_retryperiod
value: "2"
image: ghcr.io/kube-vip/kube-vip:v0.3.5
imagePullPolicy: IfNotPresent
name: kube-vip
resources: {}
securityContext:
capabilities:
add:
- NET_ADMIN
- SYS_TIME
volumeMounts:
- mountPath: /etc/kubernetes/admin.conf
name: kubeconfig
hostNetwork: true
volumes:
- hostPath:
path: /etc/kubernetes/admin.conf
type: FileOrCreate
name: kubeconfig
status: {}
owner: root:root
path: /etc/kubernetes/manifests/kube-vip.yaml
initConfiguration:
nodeRegistration:
criSocket: /var/run/containerd/containerd.sock
name: '{{ ds.meta_data.hostname }}'
joinConfiguration:
nodeRegistration:
criSocket: /var/run/containerd/containerd.sock
name: '{{ ds.meta_data.hostname }}'
preKubeadmCommands:
- hostname "{{ ds.meta_data.hostname }}"
- echo "::1 ipv6-localhost ipv6-loopback" >/etc/hosts
- echo "127.0.0.1 localhost" >>/etc/hosts
- echo "127.0.0.1 {{ ds.meta_data.hostname }}" >>/etc/hosts
- echo "{{ ds.meta_data.hostname }}" >/etc/hostname
- ip link set eth0 mtu 1442
useExperimentalRetryJoin: true
users:
- name: capv
sshAuthorizedKeys:
- SSHAUTHORIZEDKEYS
sudo: ALL=(ALL) NOPASSWD:ALL
machineTemplate:
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: VSphereMachineTemplate
name: CLUSTERNAME
replicas: 1
version: K8SVERSION
---
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
metadata:
name: CLUSTERNAME-md-0
namespace: CLUSTERNAMESPACE
spec:
template:
spec:
joinConfiguration:
nodeRegistration:
criSocket: /var/run/containerd/containerd.sock
name: '{{ ds.meta_data.hostname }}'
preKubeadmCommands:
- hostname "{{ ds.meta_data.hostname }}"
- echo "::1 ipv6-localhost ipv6-loopback" >/etc/hosts
- echo "127.0.0.1 localhost" >>/etc/hosts
- echo "127.0.0.1 {{ ds.meta_data.hostname }}" >>/etc/hosts
- echo "{{ ds.meta_data.hostname }}" >/etc/hostname
- ip link set eth0 mtu 1442
users:
- name: capv
sshAuthorizedKeys:
- SSHAUTHORIZEDKEYS
sudo: ALL=(ALL) NOPASSWD:ALL
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
labels:
cluster.x-k8s.io/cluster-name: CLUSTERNAME
name: CLUSTERNAME-md-0
namespace: CLUSTERNAMESPACE
spec:
clusterName: CLUSTERNAME
replicas: 2
selector:
matchLabels: {}
template:
metadata:
labels:
cluster.x-k8s.io/cluster-name: CLUSTERNAME
spec:
bootstrap:
configRef:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
name: CLUSTERNAME-md-0
clusterName: CLUSTERNAME
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: VSphereMachineTemplate
name: CLUSTERNAME
version: K8SVERSION
---
apiVersion: v1
kind: Secret
metadata:
name: CLUSTERNAME
namespace: CLUSTERNAMESPACE
stringData:
password: CLUSTERPASSWORD
username: CLUSTERUSERNAME
10 changes: 10 additions & 0 deletions ci/cluster-api/vsphere/templates/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": {
"name": "CLUSTERNAMESPACE",
"labels": {
"theia-ci": "true"
}
}
}
1 change: 1 addition & 0 deletions ci/docker-registry
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
projects.registry.vmware.com
63 changes: 63 additions & 0 deletions ci/jenkins/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Theia CI: Jenkins

## Reasons for Jenkins

We have tests as Github Actions but Jenkins allows tests running on a cluster of
multiple nodes and offers better environment setup options.

## List of Jobs

| Job Name | Description | Trigger Phase |
|----------|------------------------------------------------|-----------------|
| theia-e2e-for-pull-request | Run e2e test for pull request | `/theia-test-e2e` |

## Requirements

Yaml files under [ci/jenkins/jobs](/ci/jenkins/jobs) can be generated via
jenkins-job-builder. If you want to try out the tests on your local jenkins
setup, please notice the following requirements:

* Jenkins setup
* Plugins: ghprb, throttle-concurrents
* Install
[jenkins-job-builder](https://docs.openstack.org/infra/jenkins-job-builder/index.html)
* Define your `ANTREA_GIT_CREDENTIAL` which is the credential for your private
repo
* Define your `ghpr_auth`, `antrea_admin_list`, `antrea_org_list` and
`antrea_white_list` as
[defaults](https://docs.openstack.org/infra/jenkins-job-builder/definition.html#defaults)
variables in a separate file

### Credentials

The following credentials on jenkins server should also be present for the jobs to work:

| Name | Description |
|--------------|-----------------------------------|
| VMC_NETWORK_0 | vSphere Network name for VMs |
| VMC_NETWORK_1 | vSphere Network name for VMs |
| VCENTERNAME | vCenter IP address |
| DATACENTERNAME | Datacenter name |
| RESOURCEPOOLPATH | CI resource pool path |
| CAPVC_USERNAME | vCenter username |
| CAPVC_PASSWORD | vCenter password |
| DATASTORE | Datastore name |
| VMFOLDERNAME | Folder name for VM |

### Apply the jobs

Run the command to test if jobs can be generated correctly.

```bash
jenkins-jobs test -r ci/jenkins/jobs
```

Run the command to apply these jobs.

```bash
jenkins-jobs update -r ci/jenkins/jobs
```

## Tips for Developer

* [macro.yaml](/ci/jenkins/jobs/macros.yaml): Use "{{}}" instead of "{}" in your builder when you pass jenkins-job variable to the builder from projects.yaml
48 changes: 48 additions & 0 deletions ci/jenkins/jobs/job-templates.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
- job-template:
name: '{name}-{test_name}-for-pull-request'
node: '{node}'
block-downstream: false
block-upstream: false
builders: '{builders}'
concurrent: false
description: '{description}'
project-type: freestyle
properties:
- build-discarder:
artifact-days-to-keep: -1
artifact-num-to-keep: -1
days-to-keep: 7
num-to-keep: 30
- github:
url: 'https://github.com/{org_repo}'
publishers: '{publishers}'
scm:
- git:
branches: '{branches}'
credentials-id: '{git_credentials_id}'
name: origin
refspec: +refs/heads/*:refs/remotes/origin/* +refs/pull/${{ghprbPullId}}/*:refs/remotes/origin/pr/${{ghprbPullId}}/*
url: 'https://github.com/{org_repo}'
wipe-workspace: true
triggers:
- github-pull-request:
admin-list: '{admin_list}'
allow-whitelist-orgs-as-admins: '{allow_whitelist_orgs_as_admins}'
auth-id: '{ghpr_auth}'
auto-close-on-fail: false
build-desc-template: null
github-hooks: true
only-trigger-phrase: '{only_trigger_phrase}'
org-list: '{org_list}'
permit-all: '{trigger_permit_all}'
trigger-phrase: '{trigger_phrase}'
white-list-target-branches: '{white_list_target_branches}'
white-list: '{white_list}'
status-context: '{status_context}'
status-url: '{status_url}'
success-status: '{success_status}'
failure-status: '{failure_status}'
error-status: '{error_status}'
triggered-status: '{triggered_status}'
started-status: '{started_status}'
wrappers: '{wrappers}'
9 changes: 9 additions & 0 deletions ci/jenkins/jobs/macros.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- builder:
name: builder-e2e
builders:
- shell: |-
#!/usr/bin/env bash
set -ex
DOKCER_REGISTRY="$(head -n1 ci/docker-registry)"
chmod a+x ci/jenkins/test-vmc.sh
./ci/jenkins/test-vmc.sh --cluster-name "$BUILD_TAG" --registry "${DOCKER_REGISTRY}" --username "${CAPVC_USERNAME}" --password "${CAPVC_PASSWORD}" --testcase e2e
Loading

0 comments on commit a7c4af3

Please sign in to comment.