mirror of
https://github.com/jenkinsci/kubernetes-operator.git
synced 2026-10-09 01:21:12 +02:00
Grand Christmas Patch
Fixed helm not creating role permissions #424 Added ability to use custom k8s cluster domain #461 Fixed propagation of JENKINS_OPTS to seed-job agent #462 Fixed updating last backup #421
This commit is contained in:
@@ -137,8 +137,8 @@ func TestPlugins(t *testing.T) {
|
||||
require.NoError(t, err, job)
|
||||
i, err := job.InvokeSimple(map[string]string{})
|
||||
require.NoError(t, err, i)
|
||||
|
||||
waitForJobToFinish(t, job, 2*time.Second, 2*time.Minute)
|
||||
// FIXME: waitForJobToFinish use
|
||||
time.Sleep(80 * time.Second) // wait for the build to complete
|
||||
|
||||
job, err = jenkinsClient.GetJob(jobID)
|
||||
require.NoError(t, err, job)
|
||||
|
||||
+4
-4
@@ -116,10 +116,10 @@ func createJenkinsCR(t *testing.T, name, namespace string, seedJob *[]v1alpha2.S
|
||||
},
|
||||
},
|
||||
Plugins: []v1alpha2.Plugin{
|
||||
{Name: "audit-trail", Version: "2.4"},
|
||||
{Name: "simple-theme-plugin", Version: "0.5.1"},
|
||||
{Name: "github", Version: "1.29.4"},
|
||||
{Name: "devoptics", Version: "1.1863", DownloadURL: "https://jenkins-updates.cloudbees.com/download/plugins/devoptics/1.1863/devoptics.hpi"},
|
||||
{Name: "audit-trail", Version: "3.7"},
|
||||
{Name: "simple-theme-plugin", Version: "0.6"},
|
||||
{Name: "github", Version: "1.32.0"},
|
||||
{Name: "devoptics", Version: "1.1905", DownloadURL: "https://jenkins-updates.cloudbees.com/download/plugins/devoptics/1.1905/devoptics.hpi"},
|
||||
},
|
||||
PriorityClassName: priorityClassName,
|
||||
NodeSelector: map[string]string{"kubernetes.io/os": "linux"},
|
||||
|
||||
@@ -42,13 +42,24 @@ func TestBackupAndRestore(t *testing.T) {
|
||||
// FIXME: waitForJobToFinish use
|
||||
time.Sleep(60 * time.Second) // wait for the build to complete
|
||||
|
||||
jenkins = getJenkins(t, jenkins.Namespace, jenkins.Name)
|
||||
lastDoneBackup := jenkins.Status.LastBackup
|
||||
restartJenkinsMasterPod(t, jenkins)
|
||||
waitForRecreateJenkinsMasterPod(t, jenkins)
|
||||
waitForJenkinsUserConfigurationToComplete(t, jenkins)
|
||||
jenkins = getJenkins(t, jenkins.Namespace, jenkins.Name)
|
||||
assert.Equal(t, lastDoneBackup, jenkins.Status.RestoredBackup)
|
||||
jenkinsClient2, cleanUpFunc2 := verifyJenkinsAPIConnection(t, jenkins, namespace)
|
||||
defer cleanUpFunc2()
|
||||
waitForJob(t, jenkinsClient2, jobID)
|
||||
verifyJobBuildsAfterRestoreBackup(t, jenkinsClient2, jobID)
|
||||
|
||||
jenkins = getJenkins(t, jenkins.Namespace, jenkins.Name)
|
||||
lastDoneBackup = jenkins.Status.LastBackup
|
||||
resetJenkinsStatus(t, jenkins)
|
||||
waitForJenkinsUserConfigurationToComplete(t, jenkins)
|
||||
jenkins = getJenkins(t, jenkins.Namespace, jenkins.Name)
|
||||
assert.Equal(t, lastDoneBackup, jenkins.Status.RestoredBackup)
|
||||
}
|
||||
|
||||
func waitForJob(t *testing.T, jenkinsClient client.Jenkins, jobID string) {
|
||||
@@ -106,6 +117,11 @@ func createJenkinsWithBackupAndRestoreConfigured(t *testing.T, name, namespace s
|
||||
},
|
||||
Restore: v1alpha2.Restore{
|
||||
ContainerName: containerName,
|
||||
GetLatestAction: v1alpha2.Handler{
|
||||
Exec: &corev1.ExecAction{
|
||||
Command: []string{"/home/user/bin/get-latest.sh"},
|
||||
},
|
||||
},
|
||||
Action: v1alpha2.Handler{
|
||||
Exec: &corev1.ExecAction{
|
||||
Command: []string{"/home/user/bin/restore.sh"},
|
||||
@@ -125,7 +141,7 @@ func createJenkinsWithBackupAndRestoreConfigured(t *testing.T, name, namespace s
|
||||
},
|
||||
{
|
||||
Name: containerName,
|
||||
Image: "virtuslab/jenkins-operator-backup-pvc:v0.0.6",
|
||||
Image: "virtuslab/jenkins-operator-backup-pvc:v0.1.0",
|
||||
ImagePullPolicy: corev1.PullIfNotPresent,
|
||||
Env: []corev1.EnvVar{
|
||||
{
|
||||
@@ -191,3 +207,10 @@ func createJenkinsWithBackupAndRestoreConfigured(t *testing.T, name, namespace s
|
||||
|
||||
return jenkins
|
||||
}
|
||||
|
||||
func resetJenkinsStatus(t *testing.T, jenkins *v1alpha2.Jenkins) {
|
||||
jenkins = getJenkins(t, jenkins.Namespace, jenkins.Name)
|
||||
jenkins.Status = v1alpha2.JenkinsStatus{}
|
||||
err := framework.Global.Client.Update(context.TODO(), jenkins)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
jenkinsclient "github.com/jenkinsci/kubernetes-operator/pkg/client"
|
||||
"github.com/jenkinsci/kubernetes-operator/pkg/configuration/base/resources"
|
||||
|
||||
"github.com/bndr/gojenkins"
|
||||
framework "github.com/operator-framework/operator-sdk/pkg/test"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -34,28 +33,6 @@ var (
|
||||
// checkConditionFunc is used to check if a condition for the jenkins CR is set
|
||||
type checkConditionFunc func(*v1alpha2.Jenkins, error) bool
|
||||
|
||||
func waitForJobToFinish(t *testing.T, job *gojenkins.Job, tick, timeout time.Duration) {
|
||||
err := try.Until(func() (end bool, err error) {
|
||||
t.Logf("Waiting for job `%s` to finish", job.GetName())
|
||||
running, err := job.IsRunning()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
queued, err := job.IsQueued()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if !running && !queued {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}, tick, timeout)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func waitForJenkinsBaseConfigurationToComplete(t *testing.T, jenkins *v1alpha2.Jenkins) {
|
||||
t.Log("Waiting for Jenkins base configuration to complete")
|
||||
_, err := WaitUntilJenkinsConditionSet(retryInterval, 170, jenkins, func(jenkins *v1alpha2.Jenkins, err error) bool {
|
||||
|
||||
Reference in New Issue
Block a user