@@ -35,6 +35,7 @@ type JenkinsRef struct {
35
35
36
36
const (
37
37
useLocalPluginSnapshotEnvVarName = "USE_SNAPSHOT_JENKINS_IMAGE"
38
+ disableJenkinsMemoryStats = "DISABLE_JENKINS_MEMORY_MONITORING"
38
39
localPluginSnapshotImage = "openshift/jenkins-plugin-snapshot-test:latest"
39
40
)
40
41
@@ -63,7 +64,7 @@ func (j *JenkinsRef) buildURI(resourcePathFormat string, a ...interface{}) strin
63
64
// Returns a response body and status code or an error.
64
65
func (j * JenkinsRef ) getResource (resourcePathFormat string , a ... interface {}) (string , int , error ) {
65
66
uri := j .buildURI (resourcePathFormat , a ... )
66
- ginkgolog ("Retrieving Jekins resource: %q" , uri )
67
+ ginkgolog ("Retrieving Jenkins resource: %q" , uri )
67
68
req , err := http .NewRequest ("GET" , uri , nil )
68
69
if err != nil {
69
70
return "" , 0 , fmt .Errorf ("Unable to build request for uri %q: %v" , uri , err )
@@ -433,6 +434,22 @@ func initExecPod(oc *exutil.CLI) *kapi.Pod {
433
434
return targetPod
434
435
}
435
436
437
+ type apiObjJob struct {
438
+ jobName string
439
+ create bool
440
+ }
441
+
442
+ // Validate create/delete of objects
443
+ func validateCreateDelete (create bool , key , out string , err error ) {
444
+ ginkgolog ("\n OBJ: %s\n " , out )
445
+ if create {
446
+ o .Expect (err ).NotTo (o .HaveOccurred ())
447
+ o .Expect (strings .Contains (out , key )).To (o .BeTrue ())
448
+ } else {
449
+ o .Expect (err ).To (o .HaveOccurred ())
450
+ }
451
+ }
452
+
436
453
// Designed to match if RSS memory is greater than 500000000 (i.e. > 476MB)
437
454
var memoryOverragePattern = regexp .MustCompile (`\s+rss\s+5\d\d\d\d\d\d\d\d` )
438
455
@@ -446,7 +463,9 @@ var _ = g.Describe("[image_ecosystem][jenkins][Slow] openshift pipeline plugin",
446
463
447
464
g .AfterEach (func () {
448
465
449
- ticker .Stop ()
466
+ if os .Getenv (disableJenkinsMemoryStats ) == "" {
467
+ ticker .Stop ()
468
+ }
450
469
451
470
oc .SetNamespace (j .namespace )
452
471
ginkgolog ("Jenkins DC description follows. If there were issues, check to see if there were any restarts in the jenkins pod." )
@@ -565,42 +584,44 @@ var _ = g.Describe("[image_ecosystem][jenkins][Slow] openshift pipeline plugin",
565
584
566
585
jenkinsPod := findJenkinsPod (oc )
567
586
568
- ticker = time .NewTicker (10 * time .Second )
569
- go func () {
570
- for t := range ticker .C {
571
- memstats , err := oc .Run ("exec" ).Args ("--namespace" , jenkinsNamespace , jenkinsPod .Name , "--" , "cat" , "/sys/fs/cgroup/memory/memory.stat" ).Output ()
572
- if err != nil {
573
- ginkgolog ("\n Unable to acquire Jenkins cgroup memory.stat" )
574
- }
575
- ps , err := oc .Run ("exec" ).Args ("--namespace" , jenkinsNamespace , jenkinsPod .Name , "--" , "ps" , "faux" ).Output ()
576
- if err != nil {
577
- ginkgolog ("\n Unable to acquire Jenkins ps information" )
578
- }
579
- ginkgolog ("\n Jenkins memory statistics at %v\n %s\n %s\n \n " , t , ps , memstats )
580
-
581
- // This is likely a temporary measure in place to extract diagnostic information during unexpectedly
582
- // high memory utilization within the Jenkins image. If Jenkins is using
583
- // a large amount of RSS, extract JVM information from the pod.
584
- if memoryOverragePattern .MatchString (memstats ) {
585
- histogram , err := oc .Run ("rsh" ).Args ("--namespace" , jenkinsNamespace , jenkinsPod .Name , "jmap" , "-histo" , "1" ).Output ()
586
- if err == nil {
587
- ginkgolog ("\n \n Jenkins histogram:\n %s\n \n " , histogram )
588
- } else {
589
- ginkgolog ("Unable to acquire Jenkins histogram: %v" , err )
587
+ if os .Getenv (disableJenkinsMemoryStats ) == "" {
588
+ ticker = time .NewTicker (10 * time .Second )
589
+ go func () {
590
+ for t := range ticker .C {
591
+ memstats , err := oc .Run ("exec" ).Args ("--namespace" , jenkinsNamespace , jenkinsPod .Name , "--" , "cat" , "/sys/fs/cgroup/memory/memory.stat" ).Output ()
592
+ if err != nil {
593
+ ginkgolog ("\n Unable to acquire Jenkins cgroup memory.stat" )
590
594
}
591
- stack , err := oc .Run ("exec" ).Args ("--namespace" , jenkinsNamespace , jenkinsPod .Name , "--" , "jstack" , "1" ).Output ()
592
- if err == nil {
593
- ginkgolog ("\n \n Jenkins thread dump:\n %s\n \n " , stack )
594
- } else {
595
- ginkgolog ("Unable to acquire Jenkins thread dump: %v" , err )
595
+ ps , err := oc .Run ("exec" ).Args ("--namespace" , jenkinsNamespace , jenkinsPod .Name , "--" , "ps" , "faux" ).Output ()
596
+ if err != nil {
597
+ ginkgolog ("\n Unable to acquire Jenkins ps information" )
598
+ }
599
+ ginkgolog ("\n Jenkins memory statistics at %v\n %s\n %s\n \n " , t , ps , memstats )
600
+
601
+ // This is likely a temporary measure in place to extract diagnostic information during unexpectedly
602
+ // high memory utilization within the Jenkins image. If Jenkins is using
603
+ // a large amount of RSS, extract JVM information from the pod.
604
+ if memoryOverragePattern .MatchString (memstats ) {
605
+ histogram , err := oc .Run ("rsh" ).Args ("--namespace" , jenkinsNamespace , jenkinsPod .Name , "jmap" , "-histo" , "1" ).Output ()
606
+ if err == nil {
607
+ ginkgolog ("\n \n Jenkins histogram:\n %s\n \n " , histogram )
608
+ } else {
609
+ ginkgolog ("Unable to acquire Jenkins histogram: %v" , err )
610
+ }
611
+ stack , err := oc .Run ("exec" ).Args ("--namespace" , jenkinsNamespace , jenkinsPod .Name , "--" , "jstack" , "1" ).Output ()
612
+ if err == nil {
613
+ ginkgolog ("\n \n Jenkins thread dump:\n %s\n \n " , stack )
614
+ } else {
615
+ ginkgolog ("Unable to acquire Jenkins thread dump: %v" , err )
616
+ }
596
617
}
597
- }
598
618
599
- }
600
- }()
619
+ }
620
+ }()
621
+ }
601
622
602
623
// Start capturing logs from this deployment config.
603
- // This command will terminate if the Jekins instance crashes. This
624
+ // This command will terminate if the Jenkins instance crashes. This
604
625
// ensures that even if the Jenkins DC restarts, we should capture
605
626
// logs from the crash.
606
627
dcLogFollow , dcLogStdOut , dcLogStdErr , err = oc .Run ("logs" ).Args ("-f" , "dc/jenkins" ).Background ()
@@ -675,6 +696,31 @@ var _ = g.Describe("[image_ecosystem][jenkins][Slow] openshift pipeline plugin",
675
696
676
697
})
677
698
699
+ g .It ("jenkins-plugin test create obj delete obj" , func () {
700
+
701
+ jobsToCreate := map [string ]string {"test-create-obj" : "create-job.xml" , "test-delete-obj" : "delete-job.xml" , "test-delete-obj-labels" : "delete-job-labels.xml" , "test-delete-obj-keys" : "delete-job-keys.xml" }
702
+ for jobName , jobConfig := range jobsToCreate {
703
+ data := j .readJenkinsJob (jobConfig , oc .Namespace ())
704
+ j .createItem (jobName , data )
705
+ }
706
+
707
+ jobsToRun := []apiObjJob {{"test-create-obj" , true }, {"test-delete-obj" , false }, {"test-create-obj" , true }, {"test-delete-obj-labels" , false }, {"test-create-obj" , true }, {"test-delete-obj-keys" , false }}
708
+ for _ , job := range jobsToRun {
709
+ jmon := j .startJob (job .jobName )
710
+ jmon .await (10 * time .Minute )
711
+
712
+ g .By ("get build console logs and see if succeeded" )
713
+ logs , err := j .waitForContent ("Finished: SUCCESS" , 200 , 10 * time .Minute , "job/%s/lastBuild/consoleText" , job .jobName )
714
+ ginkgolog ("\n \n Jenkins logs>\n %s\n \n " , logs )
715
+ o .Expect (err ).NotTo (o .HaveOccurred ())
716
+ out , err := oc .Run ("get" ).Args ("bc" , "forcepull-bldr" ).Output ()
717
+ validateCreateDelete (job .create , "forcepull-bldr" , out , err )
718
+ out , err = oc .Run ("get" ).Args ("is" , "forcepull-extended-test-builder" ).Output ()
719
+ validateCreateDelete (job .create , "forcepull-extended-test-builder" , out , err )
720
+ }
721
+
722
+ })
723
+
678
724
g .It ("jenkins-plugin test trigger build with envs" , func () {
679
725
680
726
jobName := "test-build-with-env-job"
0 commit comments