-
Notifications
You must be signed in to change notification settings - Fork 895
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for most resources (#87)
* Add unit tests for most resources Signed-off-by: Torsten Walter <[email protected]> * removed helm.sh/chart label from pod template Signed-off-by: Torsten Walter <[email protected]> * Add tests for deployment and AlertingRule Signed-off-by: Torsten Walter <[email protected]> * Renamed tests Signed-off-by: Torsten Walter <[email protected]> * Align deployment test Signed-off-by: Torsten Walter <[email protected]> * Removed helm.sh/chart label from ConfigMap Checksum of the configmap is used as annotation on the jenkins pod to trigger a restart on config changes. If the chart version is part of the label then it triggers a restart whenever a newer chart version is used. Signed-off-by: Torsten Walter <[email protected]>
- Loading branch information
1 parent
6259c19
commit acb51f5
Showing
23 changed files
with
1,968 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
suite: ConfigMap | ||
templates: | ||
- config.yaml | ||
tests: | ||
- it: default config | ||
asserts: | ||
- isKind: | ||
of: ConfigMap | ||
- hasDocuments: | ||
count: 1 | ||
- equal: | ||
path: data.apply_config\.sh | ||
value: |- | ||
echo "applying Jenkins configuration" | ||
echo "disable Setup Wizard" | ||
# Prevent Setup Wizard when JCasC is enabled | ||
echo $JENKINS_VERSION > /var/jenkins_home/jenkins.install.UpgradeWizard.state | ||
echo $JENKINS_VERSION > /var/jenkins_home/jenkins.install.InstallUtil.lastExecVersion | ||
echo "download plugins" | ||
# Install missing plugins | ||
cp /var/jenkins_config/plugins.txt /var/jenkins_home; | ||
rm -rf /usr/share/jenkins/ref/plugins/*.lock | ||
/usr/local/bin/install-plugins.sh `echo $(cat /var/jenkins_home/plugins.txt)`; | ||
echo "copy plugins to shared volume" | ||
# Copy plugins to shared volume | ||
yes n | cp -i /usr/share/jenkins/ref/plugins/* /var/jenkins_plugins/; | ||
echo "finished initialization" | ||
- equal: | ||
path: data.plugins\.txt | ||
value: |- | ||
kubernetes:1.25.7 | ||
workflow-job:2.39 | ||
workflow-aggregator:2.6 | ||
credentials-binding:1.23 | ||
git:4.2.2 | ||
configuration-as-code:1.43 | ||
- it: no plugins | ||
set: | ||
master.installPlugins: [] | ||
asserts: | ||
- equal: | ||
path: data.apply_config\.sh | ||
value: |- | ||
echo "applying Jenkins configuration" | ||
echo "disable Setup Wizard" | ||
# Prevent Setup Wizard when JCasC is enabled | ||
echo $JENKINS_VERSION > /var/jenkins_home/jenkins.install.UpgradeWizard.state | ||
echo $JENKINS_VERSION > /var/jenkins_home/jenkins.install.InstallUtil.lastExecVersion | ||
echo "finished initialization" | ||
- equal: | ||
path: data.plugins\.txt | ||
value: "" | ||
- it: additional plugins config | ||
set: | ||
master: | ||
additionalPlugins: | ||
- kubernetes-credentials-provider | ||
asserts: | ||
- equal: | ||
path: data.apply_config\.sh | ||
value: |- | ||
echo "applying Jenkins configuration" | ||
echo "disable Setup Wizard" | ||
# Prevent Setup Wizard when JCasC is enabled | ||
echo $JENKINS_VERSION > /var/jenkins_home/jenkins.install.UpgradeWizard.state | ||
echo $JENKINS_VERSION > /var/jenkins_home/jenkins.install.InstallUtil.lastExecVersion | ||
echo "download plugins" | ||
# Install missing plugins | ||
cp /var/jenkins_config/plugins.txt /var/jenkins_home; | ||
rm -rf /usr/share/jenkins/ref/plugins/*.lock | ||
/usr/local/bin/install-plugins.sh `echo $(cat /var/jenkins_home/plugins.txt)`; | ||
echo "copy plugins to shared volume" | ||
# Copy plugins to shared volume | ||
yes n | cp -i /usr/share/jenkins/ref/plugins/* /var/jenkins_plugins/; | ||
echo "finished initialization" | ||
- equal: | ||
path: data.plugins\.txt | ||
value: |- | ||
kubernetes:1.25.7 | ||
workflow-job:2.39 | ||
workflow-aggregator:2.6 | ||
credentials-binding:1.23 | ||
git:4.2.2 | ||
configuration-as-code:1.43 | ||
kubernetes-credentials-provider |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
suite: PersistentVolumeClaim | ||
release: | ||
name: my-release | ||
namespace: my-namespace | ||
templates: | ||
- home-pvc.yaml | ||
tests: | ||
- it: tests defaults | ||
asserts: | ||
- isKind: | ||
of: PersistentVolumeClaim | ||
- equal: | ||
path: apiVersion | ||
value: v1 | ||
- equal: | ||
path: metadata.name | ||
value: my-release-jenkins | ||
- equal: | ||
path: metadata.namespace | ||
value: my-namespace | ||
- isNull: | ||
path: metadata.annotations | ||
- contains: | ||
path: spec.accessModes | ||
content: ReadWriteOnce | ||
- equal: | ||
path: spec.resources.requests | ||
value: | ||
storage: 8Gi | ||
- isNull: | ||
path: spec.storageClassName | ||
|
||
- it: test different values | ||
set: | ||
persistence: | ||
annotations: | ||
my-annotation: value | ||
accessMode: ReadWriteMany | ||
size: 20Gi | ||
storageClass: gp2 | ||
asserts: | ||
- equal: | ||
path: metadata.annotations | ||
value: | ||
my-annotation: value | ||
- contains: | ||
path: spec.accessModes | ||
content: ReadWriteMany | ||
- equal: | ||
path: spec.resources.requests | ||
value: | ||
storage: 20Gi | ||
- equal: | ||
path: spec.storageClassName | ||
value: gp2 | ||
|
||
- it: existing claim | ||
set: | ||
persistence: | ||
existingClaim: my-pvc | ||
asserts: | ||
- hasDocuments: | ||
count: 0 |
Oops, something went wrong.