Fix tests
This commit is contained in:
parent
f1815e10aa
commit
ab1d3fb59b
|
|
@ -168,6 +168,7 @@ import jenkins.model.GlobalConfiguration
|
|||
GlobalConfiguration.all().get(GlobalJobDslSecurityConfiguration.class).useScriptSecurity=false
|
||||
GlobalConfiguration.all().get(GlobalJobDslSecurityConfiguration.class).save()
|
||||
`
|
||||
|
||||
// GetBaseConfigurationConfigMapName returns name of Kubernetes config map used to base configuration
|
||||
func GetBaseConfigurationConfigMapName(jenkins *v1alpha2.Jenkins) string {
|
||||
return fmt.Sprintf("%s-base-configuration-%s", constants.OperatorName, jenkins.ObjectMeta.Name)
|
||||
|
|
|
|||
|
|
@ -8,21 +8,21 @@ import (
|
|||
"reflect"
|
||||
|
||||
"github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2"
|
||||
jenkinsclient "github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/client"
|
||||
"github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/configuration/base/resources"
|
||||
"github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/constants"
|
||||
"github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/jobs"
|
||||
"github.com/jenkinsci/kubernetes-operator/pkg/log"
|
||||
jenkinsclient "github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/client"
|
||||
|
||||
"github.com/go-logr/logr"
|
||||
stackerr "github.com/pkg/errors"
|
||||
apps "k8s.io/api/apps/v1"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
k8s "sigs.k8s.io/controller-runtime/pkg/client"
|
||||
apps "k8s.io/api/apps/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
k8s "sigs.k8s.io/controller-runtime/pkg/client"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -47,8 +47,10 @@ const (
|
|||
// credential type
|
||||
JenkinsCredentialTypeLabelName = "jenkins.io/credentials-type"
|
||||
|
||||
// AgentName is the name of seed job
|
||||
// AgentName is the name of seed job agent
|
||||
AgentName = "seed-job-agent"
|
||||
|
||||
// AgentNamespace is the namespace of seed job agent
|
||||
AgentNamespace = "default"
|
||||
)
|
||||
|
||||
|
|
@ -259,6 +261,7 @@ func (s *SeedJobs) isRecreatePodNeeded(jenkins v1alpha2.Jenkins) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// CreateAgent deploys Jenkins agent to Kubernetes cluster
|
||||
func CreateAgent(jenkinsClient jenkinsclient.Jenkins, k8sClient client.Client, jenkinsManifest *v1alpha2.Jenkins, namespace string, agentName string) error {
|
||||
var exists bool
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,19 @@ func TestEnsureSeedJobs(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
buildNumber := int64(1)
|
||||
|
||||
agentName := "seed-job-agent"
|
||||
secret := "test-secret"
|
||||
testNode := &gojenkins.Node{
|
||||
Raw: &gojenkins.NodeResponse{
|
||||
DisplayName: agentName,
|
||||
},
|
||||
}
|
||||
|
||||
jenkinsClient.EXPECT().GetNodeSecret(agentName).Return(secret, nil)
|
||||
jenkinsClient.EXPECT().GetAllNodes().Return([]*gojenkins.Node{}, nil)
|
||||
jenkinsClient.EXPECT().CreateNode(agentName, 1, "The jenkins-operator generated agent", "/home/jenkins", agentName).Return(testNode, nil)
|
||||
jenkinsClient.EXPECT().GetNode(agentName).Return(testNode, nil).AnyTimes()
|
||||
|
||||
for reconcileAttempt := 1; reconcileAttempt <= 2; reconcileAttempt++ {
|
||||
logger.Info(fmt.Sprintf("Reconcile attempt #%d", reconcileAttempt))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue