<commit_before>/*pipeline {
    agent none
    stages {
        stage('test init') {
    	    steps {
    	        script {
	                openshift.setLockName('openshift-dls-test')
    	        }
    	    }
        }
        stage('Run tests') {
            parallel {
                stage('Test run 1') {
                    steps {
                        script {
                            actualTest()
                        }
                    }
                }
      
                stage('Test run 2') {
                    steps {
                        script {
                            actualTest()
                        }
                    }
                }
            }
        }
    }
}

void actualTest() {*/
    /**
     * This script does nothing in particular,
     * but is meant to show actual usage of most of the API.
     */
    
    try {
        timeout(time: 20, unit: 'MINUTES') {
            // Select the default cluster
            openshift.withCluster() {
                // Test openshift.patch and selector.patch
                /*openshift.withProject() {
                    openshift.create("https://raw.githubusercontent.com/openshift/nodejs-ex/master/openshift/templates/nodejs.json")
                    openshift.newApp("nodejs-example")
                    openshift.patch("dc/nodejs-example", '\'{"spec":{"strategy":{"type":"Recreate"}}}\'')
                    def mySelector = openshift.selector("bc/nodejs-example")
                    mySelector.patch('\'{"spec":{"source":{"git":{"ref": "development"}}}}\'')
                }*/
                // Select the default project
                openshift.withProject() {
    
                    // Output the url of the currently selected cluster
                    echo "Using project ${openshift.project()} in cluster with url ${openshift.cluster()}"
    
                    // Test selector.annotate
                    //def railsTemplate = openshift.create("https://raw.githubusercontent.com/openshift/rails-ex/master/openshift/templates/rails-postgresql.json")
                    //railsTemplate.annotate([key1:"value1", key2:"value2"])
                    //railsTemplate.delete()
    
                    def saSelector1 = openshift.selector( "serviceaccount" )
                    saSelector1.describe()
    
                    def templateSelector = openshift.selector( "template", "mongodb-ephemeral")
    
                    def templateExists = templateSelector.exists()
    
                    def templateGeneratedSelector = openshift.selector(["dc/mongodb", "service/mongodb", "secret/mongodb"])
    
                    def objectsGeneratedFromTemplate = templateGeneratedSelector.exists()
                    
                    // create single object in array
                    def bc = [[
                        "kind":"BuildConfig",
                        "apiVersion":"v1",
                        "metadata":[
                            "name":"test",
                            "labels":[
                                "name":"test"
                            ]
                        ],
                        "spec":[
                            "triggers":[],
                            "source":[
                                "type":"Binary"
                            ],
                            "strategy":[
                                "type":"Source",
                                "sourceStrategy":[
                                    "from":[
                                        "kind":"DockerImage",
                                        "name":"centos/ruby-22-centos7"
                                    ]
                                ]
                            ],
                            "output":[
                                "to":[
                                    "kind":"ImageStreamTag",
                                    "name":"test:latest"
                                ]
                            ]
                        ]
                      ]
                    ]    
                    def objs = openshift.create( bc )
                    objs.describe()
                    openshift.delete("bc", "test")
                    // switch to delete below when v1.0.10 is available in the image
                    //openshift.delete(bc)
                    openshift.create("configmap", "foo")
                    openshift.create("configmap", "bar")
                    openshift.delete("configmap/foo", "configmap/bar")
                    openshift.create("configmap", "foo")
                    openshift.delete("configmap/foo")

                    def template
                    if (!templateExists) {
                        template = openshift.create('https://raw.githubusercontent.com/openshift/origin/master/examples/db-templates/mongodb-ephemeral-template.json').object()
                    } else {
                        template = templateSelector.object()
                    }
    
                    // Explore the Groovy object which models the OpenShift template as a Map
                    echo "Template contains ${template.parameters.size()} parameters"
    
                    // For fun, modify the template easily while modeled in Groovy
                    template.labels["mylabel"] = "myvalue"

                    // verify we can handle unquoted param values with spaces
                    def muser = "All Users"
                    openshift.process( template, '-p', "MONGODB_USER=${muser}")
    
                    // Process the modeled template. We could also pass JSON/YAML, a template name, or a url instead.
                    // note: -p option for oc process not in the oc version that we currently ship with openshift jenkins images
                    def objectModels = openshift.process( template )//, "-p", "MEMORY_LIMIT=600Mi")<commit_msg>revert latest template param test; something is up with the jenkins image version used with the overnight tests (#187)<commit_after>/*pipeline {
    agent none
    stages {
        stage('test init') {
    	    steps {
    	        script {
	                openshift.setLockName('openshift-dls-test')
    	        }
    	    }
        }
        stage('Run tests') {
            parallel {
                stage('Test run 1') {
                    steps {
                        script {
                            actualTest()
                        }
                    }
                }
      
                stage('Test run 2') {
                    steps {
                        script {
                            actualTest()
                        }
                    }
                }
            }
        }
    }
}

void actualTest() {*/
    /**
     * This script does nothing in particular,
     * but is meant to show actual usage of most of the API.
     */
    
    try {
        timeout(time: 20, unit: 'MINUTES') {
            // Select the default cluster
            openshift.withCluster() {
                // Test openshift.patch and selector.patch
                /*openshift.withProject() {
                    openshift.create("https://raw.githubusercontent.com/openshift/nodejs-ex/master/openshift/templates/nodejs.json")
                    openshift.newApp("nodejs-example")
                    openshift.patch("dc/nodejs-example", '\'{"spec":{"strategy":{"type":"Recreate"}}}\'')
                    def mySelector = openshift.selector("bc/nodejs-example")
                    mySelector.patch('\'{"spec":{"source":{"git":{"ref": "development"}}}}\'')
                }*/
                // Select the default project
                openshift.withProject() {
    
                    // Output the url of the currently selected cluster
                    echo "Using project ${openshift.project()} in cluster with url ${openshift.cluster()}"
    
                    // Test selector.annotate
                    //def railsTemplate = openshift.create("https://raw.githubusercontent.com/openshift/rails-ex/master/openshift/templates/rails-postgresql.json")
                    //railsTemplate.annotate([key1:"value1", key2:"value2"])
                    //railsTemplate.delete()
    
                    def saSelector1 = openshift.selector( "serviceaccount" )
                    saSelector1.describe()
    
                    def templateSelector = openshift.selector( "template", "mongodb-ephemeral")
    
                    def templateExists = templateSelector.exists()
    
                    def templateGeneratedSelector = openshift.selector(["dc/mongodb", "service/mongodb", "secret/mongodb"])
    
                    def objectsGeneratedFromTemplate = templateGeneratedSelector.exists()
                    
                    // create single object in array
                    def bc = [[
                        "kind":"BuildConfig",
                        "apiVersion":"v1",
                        "metadata":[
                            "name":"test",
                            "labels":[
                                "name":"test"
                            ]
                        ],
                        "spec":[
                            "triggers":[],
                            "source":[
                                "type":"Binary"
                            ],
                            "strategy":[
                                "type":"Source",
                                "sourceStrategy":[
                                    "from":[
                                        "kind":"DockerImage",
                                        "name":"centos/ruby-22-centos7"
                                    ]
                                ]
                            ],
                            "output":[
                                "to":[
                                    "kind":"ImageStreamTag",
                                    "name":"test:latest"
                                ]
                            ]
                        ]
                      ]
                    ]    
                    def objs = openshift.create( bc )
                    objs.describe()
                    openshift.delete("bc", "test")
                    // switch to delete below when v1.0.10 is available in the image
                    //openshift.delete(bc)
                    openshift.create("configmap", "foo")
                    openshift.create("configmap", "bar")
                    openshift.delete("configmap/foo", "configmap/bar")
                    openshift.create("configmap", "foo")
                    openshift.delete("configmap/foo")

                    def template
                    if (!templateExists) {
                        template = openshift.create('https://raw.githubusercontent.com/openshift/origin/master/examples/db-templates/mongodb-ephemeral-template.json').object()
                    } else {
                        template = templateSelector.object()
                    }
    
                    // Explore the Groovy object which models the OpenShift template as a Map
                    echo "Template contains ${template.parameters.size()} parameters"
    
                    // For fun, modify the template easily while modeled in Groovy
                    template.labels["mylabel"] = "myvalue"

                    // verify we can handle unquoted param values with spaces
                    //def muser = "All Users"
                    //openshift.process( template, '-p', "MONGODB_USER=${muser}")
    
                    // Process the modeled template. We could also pass JSON/YAML, a template name, or a url instead.
                    // note: -p option for oc process not in the oc version that we currently ship with openshift jenkins images
                    def objectModels = openshift.process( template )//, "-p", "MEMORY_LIMIT=600Mi")
{'fraction_non_alphanumeric': 0.09944012701596056, 'fraction_numerical': 0.0037603409375783405, 'mean_word_length': 1.0056980056980056, 'pattern_counts': {'":': 54, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '507266', 'n_tokens_mistral': 2840, 'n_tokens_neox': 2519, 'n_words': 557}