Skip to content

Commit

Permalink
test: move driver deployment into e2e.test
Browse files Browse the repository at this point in the history
The immediate advantage is that we can get rid of the logic in the
Jenkinsfile which tries to determine whether the running cluster can
be reused. It also becomes shorter.

Retries get removed because we should get to a point where tests are
so reliable that we don't need them.

The long-term advantage is that we can add tests for various kinds of
deploying PMEM-CSI more easily.
  • Loading branch information
pohly committed Mar 19, 2020
1 parent 0eeb2e2 commit df17bda
Show file tree
Hide file tree
Showing 44 changed files with 1,159 additions and 280 deletions.
100 changes: 14 additions & 86 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ pipeline {
stage('Build test image') {
options {
timeout(time: 60, unit: "MINUTES")
retry(2)
}

steps {
Expand All @@ -244,104 +243,41 @@ pipeline {
}
}

stage('testing 1.16 LVM') {
stage('testing 1.16') {
options {
timeout(time: 90, unit: "MINUTES")
retry(2)
timeout(time: 120, unit: "MINUTES")
}
steps {
TestInVM("lvm", "testing", "fedora", "", "1.16")
TestInVM("fedora", "", "1.16")
}
}

stage('testing 1.16 direct') {
options {
timeout(time: 180, unit: "MINUTES")
retry(2)
}
steps {
TestInVM("direct", "testing", "fedora", "", "1.16")
}
}

stage('testing 1.14 LVM') {
when { not { changeRequest() } }
options {
timeout(time: 90, unit: "MINUTES")
retry(2)
}
steps {
TestInVM("lvm", "testing", "fedora", "", "1.14")
}
}

stage('testing 1.14 direct') {
when { not { changeRequest() } }
options {
timeout(time: 180, unit: "MINUTES")
retry(2)
}
steps {
TestInVM("direct", "testing", "fedora", "", "1.14")
}
}

/*
In production we can only run E2E testing, no sanity testing.
Therefore it is faster.
*/

stage('production 1.14 LVM') {
when { not { changeRequest() } }
options {
timeout(time: 45, unit: "MINUTES")
retry(2)
}
steps {
TestInVM("lvm", "production", "fedora", "", "1.14")
}
}

stage('production 1.14 direct') {
when { not { changeRequest() } }
options {
timeout(time: 45, unit: "MINUTES")
retry(2)
}
steps {
TestInVM("direct", "production", "fedora", "", "1.14")
}
}

stage('production 1.15 LVM') {
stage('testing 1.15') {
when { not { changeRequest() } }
options {
timeout(time: 45, unit: "MINUTES")
retry(2)
timeout(time: 120, unit: "MINUTES")
}
steps {
TestInVM("lvm", "production", "fedora", "", "1.15")
TestInVM("fedora", "", "1.15")
}
}

stage('production 1.15 direct') {
stage('testing 1.14') {
when { not { changeRequest() } }
options {
timeout(time: 45, unit: "MINUTES")
retry(2)
timeout(time: 120, unit: "MINUTES")
}
steps {
TestInVM("direct", "production", "fedora", "", "1.15")
TestInVM("fedora", "", "1.14")
}
}

stage('production 1.17, Clear Linux') {
stage('Clear Linux') {
options {
timeout(time: 90, unit: "MINUTES")
retry(2)
timeout(time: 120, unit: "MINUTES")
}
steps {
TestInVM("lvm", "production", "clear", "${env.CLEAR_LINUX_VERSION_1_17}", "")
TestInVM("clear", "${env.CLEAR_LINUX_VERSION_1_17}", "")
}
}

Expand Down Expand Up @@ -443,7 +379,7 @@ String RunInBuilder() {
"
}

void TestInVM(deviceMode, deploymentMode, distro, distroVersion, kubernetesVersion) {
void TestInVM(distro, distroVersion, kubernetesVersion) {
try {
/*
We have to run "make start" in the current directory
Expand Down Expand Up @@ -481,8 +417,6 @@ void TestInVM(deviceMode, deploymentMode, distro, distroVersion, kubernetesVersi
${RunInBuilder()} \
-e CLUSTER=${env.CLUSTER} \
-e TEST_LOCAL_REGISTRY=\$(ip addr show dev docker0 | grep ' inet ' | sed -e 's/.* inet //' -e 's;/.*;;'):5000 \
-e TEST_DEVICEMODE=${deviceMode} \
-e TEST_DEPLOYMENTMODE=${deploymentMode} \
-e TEST_CHECK_SIGNED_FILES=false \
-e TEST_CHECK_KVM=false \
-e TEST_QEMU_CPU=host,-vmx \
Expand All @@ -495,13 +429,7 @@ void TestInVM(deviceMode, deploymentMode, distro, distroVersion, kubernetesVersi
loggers=; \
atexit () { set -x; kill \$loggers; kill \$( ps --no-header -o %p ); }; \
trap atexit EXIT; \
echo CLUSTER=\$CLUSTER TEST_LOCAL_REGISTRY=\$TEST_LOCAL_REGISTRY TEST_DISTRO=\$TEST_DISTRO TEST_DISTRO_VERSION=\$TEST_DISTRO_VERSION TEST_KUBERNETES_VERSION=\$TEST_KUBERNETES_VERSION >_work/new-cluster-config && \
if [ -e _work/\$CLUSTER/cluster-config ] && ! diff _work/\$CLUSTER/cluster-config _work/new-cluster-config; then \
echo QEMU cluster configuration has changed, need to stop old cluster. && \
make stop; \
fi && \
make start && \
mv _work/new-cluster-config _work/\$CLUSTER/cluster-config && \
_work/${env.CLUSTER}/ssh.0 kubectl get pods --all-namespaces -o wide && \
for pod in ${env.LOGGING_PODS}; do \
_work/${env.CLUSTER}/ssh.0 kubectl logs -f -n kube-system \$pod-pmem-csi-${env.CLUSTER}-master | sed -e \"s/^/\$pod: /\" & \
Expand All @@ -520,7 +448,7 @@ void TestInVM(deviceMode, deploymentMode, distro, distroVersion, kubernetesVersi
done | sed -e \"s/^/\$hostname: /\" ) & \
loggers=\"\$loggers \$!\"; \
done && \
testrun=\$(echo '${distro}-${distroVersion}-${kubernetesVersion}-${deviceMode}-${deploymentMode}' | sed -e s/--*/-/g | tr . _ ) && \
testrun=\$(echo '${distro}-${distroVersion}-${kubernetesVersion}' | sed -e s/--*/-/g | tr . _ ) && \
make test_e2e TEST_E2E_REPORT_DIR=${WORKSPACE}/build/reports.tmp/\$testrun \
TEST_E2E_SKIP=\$(if [ \"${env.CHANGE_ID}\" ] && [ \"${env.CHANGE_ID}\" != null ]; then echo \\\\[Slow\\\\]; fi) \
' \
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1127,11 +1127,6 @@ Once `make start` completes, the cluster is ready for interactive use via
set `KUBECONFIG` as shown at the end of the `make start` output
and use `kubectl` binary on the host running VMs.
When the cluster is already running, `make start` will re-deploy the
PMEM-CSI driver without recreating the virtual machines. `kubectl
apply` is used for this, which may limit the kind of changes that can
be made on-the-fly.
Use `make stop` to stop and remove the virtual machines.
`make restart` can be used to cleanly reboot all virtual
Expand All @@ -1149,6 +1144,13 @@ the master node.
`_work/pmem-govm/ssh.1` starts a shell on the first worker node.
### Deploying PMEM-CSI on a test cluster
After `make start`, PMEM-CSI is *not* installed yet. Either install
manually as [described for a normal
cluster](#run-pmem-csi-on-kubernetes) or use the
[setup-deployment.sh](./test/setup-deployment.sh) script.
### Configuration options
Several aspects of the cluster and build setup can be configured by overriding
Expand All @@ -1161,10 +1163,10 @@ Multiple different clusters can be brought up in parallel by changing
the default `pmem-govm` cluster name via the `CLUSTER` env variable.
For example, this invocation sets up a cluster using the non-default
direct device mode:
Fedora distro:
``` sh
TEST_DEVICEMODE=direct CLUSTER=clear-govm-direct make start
TEST_DISTRO=fedora CLUSTER=fedora-govm make start
```
### Running E2E tests
Expand Down
6 changes: 6 additions & 0 deletions cmd/pmem-csi-driver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ import (
"flag"
"os"

"k8s.io/klog"

"github.com/intel/pmem-csi/pkg/pmem-csi-driver"
)

func init() {
klog.InitFlags(nil)
}

func main() {
flag.Parse()
os.Exit(pmemcsidriver.Main())
Expand Down
29 changes: 29 additions & 0 deletions deploy/kubernetes-1.14/direct/pmem-csi.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
pmem-csi.intel.com/deployment: direct-production
name: pmem-csi-controller
namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
labels:
pmem-csi.intel.com/deployment: direct-production
name: pmem-csi-external-provisioner-cfg
namespace: default
rules:
Expand Down Expand Up @@ -36,6 +40,8 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
pmem-csi.intel.com/deployment: direct-production
name: pmem-csi-external-provisioner-runner
rules:
- apiGroups:
Expand Down Expand Up @@ -109,6 +115,8 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
labels:
pmem-csi.intel.com/deployment: direct-production
name: pmem-csi-csi-provisioner-role-cfg
namespace: default
roleRef:
Expand All @@ -123,6 +131,8 @@ subjects:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
pmem-csi.intel.com/deployment: direct-production
name: pmem-csi-csi-provisioner-role
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand All @@ -136,39 +146,51 @@ subjects:
apiVersion: v1
kind: Service
metadata:
labels:
pmem-csi.intel.com/deployment: direct-production
name: pmem-csi-controller
namespace: default
spec:
ports:
- port: 10000
selector:
app: pmem-csi-controller
pmem-csi.intel.com/deployment: direct-production
---
apiVersion: v1
kind: Service
metadata:
labels:
pmem-csi.intel.com/deployment: direct-production
name: pmem-csi-metrics
namespace: default
spec:
ports:
- port: 10010
selector:
app: pmem-csi-controller
pmem-csi.intel.com/deployment: direct-production
type: NodePort
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
pmem-csi.intel.com/deployment: direct-production
name: pmem-csi-controller
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: pmem-csi-controller
pmem-csi.intel.com/deployment: direct-production
serviceName: pmem-csi-controller
template:
metadata:
labels:
app: pmem-csi-controller
pmem-csi.intel.com/deployment: direct-production
pmem-csi.intel.com/webhook: ignore
spec:
containers:
Expand Down Expand Up @@ -226,15 +248,20 @@ spec:
apiVersion: apps/v1
kind: DaemonSet
metadata:
labels:
pmem-csi.intel.com/deployment: direct-production
name: pmem-csi-node
namespace: default
spec:
selector:
matchLabels:
app: pmem-csi-node
pmem-csi.intel.com/deployment: direct-production
template:
metadata:
labels:
app: pmem-csi-node
pmem-csi.intel.com/deployment: direct-production
pmem-csi.intel.com/webhook: ignore
spec:
containers:
Expand Down Expand Up @@ -334,6 +361,8 @@ spec:
apiVersion: storage.k8s.io/v1beta1
kind: CSIDriver
metadata:
labels:
pmem-csi.intel.com/deployment: direct-production
name: pmem-csi.intel.com
spec:
attachRequired: false
Expand Down
Loading

0 comments on commit df17bda

Please sign in to comment.