SAP / jenkins-library

Jenkins shared library for Continuous Delivery pipelines.
https://www.project-piper.io
Apache License 2.0
779 stars 590 forks source link

step npmExecuteEndToEndTests to use param virtualFrameBuffer from config #4731

Closed navinkrishnan closed 5 months ago

navinkrishnan commented 10 months ago

Hi Team,

I wanted to run my wdi5 tests part of the pipeline. The step npmExecuteEndToEndTests seems to fit my use case as it does the appropriate credential and baseUrl setup for my wdi5 tests. But unfortunate I run into some failures because of the parameter virtualFrameBuffer.

failed to start virtual frame bufferstarting command 'Xvfb' failed: starting command failed: exec: "Xvfb": executable file not found in $PATH

In the npmExecuteEndToEndTests.groovy, npmExecuteScripts is called with strict virtualFrameBuffer: true. Could this value be instead applied from the config ? https://github.com/SAP/jenkins-library/blob/2d56e3f4dc339d523e1f8c692c3d151212849034/vars/npmExecuteEndToEndTests.groovy#L147

Following are the error messages I see by having the strict virtualFrameBuffer: true

java.lang.IllegalStateException: Jenkins.instance is missing. Read the documentation of Jenkins.getInstanceOrNull to see what you are doing wrong.
    at jenkins.model.Jenkins.get(Jenkins.java:816)
    at jenkins.model.GlobalConfiguration.all(GlobalConfiguration.java:75)
    at jenkins.plugins.logstash.LogstashConfiguration.getInstance(LogstashConfiguration.java:289)
    at jenkins.plugins.logstash.LogstashWriter.getIndexerDao(LogstashWriter.java:162)
    at jenkins.plugins.logstash.LogstashWriter.getDaoOrNull(LogstashWriter.java:201)
    at jenkins.plugins.logstash.LogstashWriter.<init>(LogstashWriter.java:82)
    at jenkins.plugins.logstash.pipeline.GlobalDecorator.decorate(GlobalDecorator.java:41)
    at org.jenkinsci.plugins.workflow.log.TaskListenerDecorator.decorateAll(TaskListenerDecorator.java:230)
    at org.jenkinsci.plugins.workflow.log.TaskListenerDecorator$DecoratedTaskListener.getOutputStream(TaskListenerDecorator.java:267)
    at org.jenkinsci.plugins.workflow.log.OutputStreamTaskListener.getOutputStream(OutputStreamTaskListener.java:63)
    at org.jenkinsci.plugins.workflow.log.TaskListenerDecorator$CloseableTaskListener.getOutputStream(TaskListenerDecorator.java:302)
    at org.jenkinsci.plugins.workflow.log.OutputStreamTaskListener.getOutputStream(OutputStreamTaskListener.java:63)
    at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution$NewlineSafeTaskListener.getOutputStream(DurableTaskStep.java:459)
    at org.jenkinsci.plugins.workflow.log.OutputStreamTaskListener$Default.getLogger(OutputStreamTaskListener.java:116)
    at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1386)
    at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1337)
    at hudson.remoting.UserRequest.perform(UserRequest.java:211)
    at hudson.remoting.UserRequest.perform(UserRequest.java:54)
    at hudson.remoting.Request$2.run(Request.java:376)
    at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78)
    at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:121)
    at java.base/java.lang.Thread.run(Unknown Source)
17:50:33  + ./piper readPipelineEnv
17:50:33  time="2023-12-19T12:20:33Z" level=info msg="Version 13a97c8aea91a805ccbce63930651045ad02e028" library=SAP/jenkins-library

17:50:39  Stash content: pipelineStepReports (includes: .pipeline/stepReports/**, excludes: , useDefaultExcludes: true, allowEmpty: true)
17:50:39  [Pipeline] stash
17:50:39  Warning: overwriting stash ‘pipelineStepReports’
17:50:39  Stashed 0 file(s)
17:50:39  [Pipeline] fileExists
17:50:39  [Pipeline] readJSON
17:50:40  [Pipeline] error
17:50:40  [Pipeline] libraryResource
17:50:40  [Pipeline] echo
17:50:40  ----------------------------------------------------------
17:50:40  --- An error occurred in the library step: dockerExecute
17:50:40  ----------------------------------------------------------
17:50:40  
17:50:40  The following parameters were available to the step:
17:50:40  ***
17:50:40  *** to show step parameters, set verbose:true in general pipeline configuration
17:50:40  *** WARNING: this may reveal sensitive information. ***
17:50:40  ***
17:50:40  
17:50:40  The error was:
17:50:40  ***
17:50:40  hudson.AbortException: [npmExecuteScripts] Step execution failed (category: build). Error: failed to start virtual frame bufferstarting command 'Xvfb' failed: starting command failed: exec: "Xvfb": executable file not found in $PATH
17:50:40  ***
srinikitha09 commented 10 months ago

Hi @navinkrishnan , which docker image did you use to run the npmExecuteEndToEndTestsstep? Seems like, the image does not have the Xvfb binary.

navinkrishnan commented 10 months ago

Hi @srinikitha09 I'm using the image ppiper/node-browsers:18-bookworm

I was able to use the npmExecuteScripts instead directly like this

npmExecuteScripts(
                script: this,
                virtualFrameBuffer: false,
                runScripts: ['wdi5'],
                dockerImage:'ppiper/node-browsers:18-bookworm'
            )

Tests are triggering. But ofcourse its failing as I need to setup credentials and base url in a custom way.

What is the significance of virtualFrameBuffer ? why is it not allowed to set to false for the step npmExecuteEndToEndTests ?

srinikitha09 commented 10 months ago

Hi @navinkrishnan , I am not sure about the significance of it but even though virtualFrameBuffer: true, it should be able to run the tests successfully with this image ppiper/node-browsers:18-bookworm. Did you give it a try?

navinkrishnan commented 10 months ago

Hi @srinikitha09 , Yes, I did give a try and with npmExecuteEndToEndTests and it fails with Xvfb binary. I suspect its because of virtualFrameBuffer, if we can make it as false it may run.

srinikitha09 commented 10 months ago

Hi @navinkrishnan, In that case, I would assume the docker image used by npmExecuteScripts step might be this image. If you set the following config and use npmExecuteEndToEndTests step, it should run fine.

steps:
 npmExecuteEndToEndTests: 
   dockerImage: ppiper/node-browsers:18-bookworm

  npmExecuteScripts: 
       dockerImage:  ppiper/node-browsers:18-bookworm
prajin-op commented 9 months ago

Hi @srinikitha09,

We have update the config file with the steps that you have suggested.

image

But still we are getting the same error like below

image

Could you please help us here to fix this issue?

Regards, Prajin

srinikitha09 commented 9 months ago

@prajin-op could you please provide the complete logs of the failed build? Also, in your .pipeline/config.yaml file, please configure additionally,

  npmExecuteScripts: 
       dockerImage:  ppiper/node-browsers:18-bookworm
navinkrishnan commented 9 months ago

npmExecuteEndToEndTests.log

@srinikitha09 Attached the log file for the step npmExecuteEndToEndTests.

srinikitha09 commented 9 months ago

@navinkrishnan Are you running the build on Kubernetes? AFAIU, the build is running on the master node which do not have the docker installed and hence it cannot connect to docker daemon and due to that the configured docker image is not used to execute the wdi5 tests. But if your build is running on the Kubernetes, then you should not face these issues any more.

github-actions[bot] commented 7 months ago

Thank you for your contribution! This issue is stale because it has been open 60 days with no activity. In order to keep it open, please remove stale label or add a comment within the next 10 days. If you need a Piper team member to remove the stale label make sure to add @SAP/jenkins-library-team to your comment.

navinkrishnan commented 7 months ago

Hi @srinikitha09 : Sorry, I missed to respond earlier. Build is running on a JaaS instance.

I have acheived my requirement with the following,

withEnv(["BASE_URL=${base_url}"]) {
            withCredentials([usernamePassword(credentialsId: 'pusercf1', usernameVariable: 'wdi5_username', passwordVariable: 'wdi5_password')]) {
                npmExecuteScripts(
                    script: this,
                    virtualFrameBuffer: false,
                    runScripts: ['wdi5'],
                    dockerImage:'ppiper/node-browsers:18-bookworm'
                )
            }    
        }

I would expect, this could be achieved with npmExecuteEndToEndTests as well, but this doesn't work

npmExecuteEndToEndTests(
            script: this,
            credentialsId: 'pusercf1',
            wdi5: true,
            runScript: 'wdi5',
            baseUrl: 'xxxx',
            dockerImage:'ppiper/node-browsers:18-bookworm',
            virtualFrameBuffer: false,
)
github-actions[bot] commented 5 months ago

Thank you for your contribution! This issue is stale because it has been open 60 days with no activity. In order to keep it open, please remove stale label or add a comment within the next 10 days. If you need a Piper team member to remove the stale label make sure to add @SAP/jenkins-library-team to your comment.

github-actions[bot] commented 5 months ago

Issue got stale and no further activity happened. It has automatically been closed. Please re-open in case you still consider it relevant.