webdriverio-community / wdio-video-reporter

Reporter for WebdriverIO that makes videos of failed tests and has optional allure integration
https://webdriver.io/docs/wdio-video-reporter
MIT License
58 stars 46 forks source link

Get error ffmpeg when running wdio-video-reporter in jenkins and centos #162

Open mpermperpisang opened 7 months ago

mpermperpisang commented 7 months ago

Describe the bug i got error when i run wdio-video-reporter on jenkins and the OS is centos 8

Log There is no wdio log because it failed from start But here is the error

file:///var/data/jenkins-slave/workspace/QE_Playground/web-testing-pr-only/test/support/wdio.conf.chrome.js: undefined Could not find ffmpeg executable, tried "/var/data/jenkins-slave/workspace/QE_Playground/web-testing-pr-only/node_modules/@ffmpeg-installer/linux-x64/ffmpeg", "/var/data/jenkins-slave/workspace/QE_Playground/web-testing-pr-only/node_modules/@ffmpeg-installer/ffmpeg/node_modules/@ffmpeg-installer/linux-x64/ffmpeg" and "/var/data/jenkins-slave/workspace/QE_Playground/web-testing-pr-only/node_modules/@ffmpeg-installer/linux-x64/ffmpeg"

To Reproduce

  1. Install "wdio-video-reporter": "^4.0.5" (i have to use this version only)
  2. Setup wdio config
    reporters: [
    [video, {
      saveAllVideos: true,
      videoSlowdownMultiplier: 3,
      outputDir: './allure-results',
      onlyRecordLastFailure: true,
    }],
    ['allure', {
      outputDir: './allure-results',
      disableWebdriverStepsReporting: true,
      disableWebdriverScreenshotsReporting: false,
      useCucumberStepReporter: true,
      addConsoleLogs: true,
    }],
    ],
  3. Run wdio scenario

Expected behavior I want the video to be accessable in the jenkins builder with spec Centos 8

Desktop (please complete the following information):

Additional context I've tried many ways to import ffmpeg

  1. Put jenkins env => PATH=/usr/bin/ffmpeg
  2. Put wdio config => ffmpegPath: ${process.cwd()}/node_modules/@ffmpeg-installer/linux-x64/ffmpeg

Please help and thanks in advance

seanpoulter commented 6 months ago

Sorry to hear you're having trouble @mpermperpisang. It looks like the path to ffmpeg is set using @ffmpeg-installer/ffmpeg. Could you have a look if it supports your platform and processor architecture? If it does, can you install one of the optionalDependency npm packages in your build to ensure the binary is installed?

If that works we'd appreciate any contribution to improve our docs.

mpermperpisang commented 6 months ago

hi @seanpoulter already tried that on the previous attempt, but still no hope i even put this config ffmpegPath: '/usr/bin/ffmpeg',

full reporter config

reporters: [
    ['video', {
      saveAllVideos: true,
      videoSlowdownMultiplier: 3,
      ffmpegPath: '/usr/bin/ffmpeg',
      outputDir: './allure-results',
      onlyRecordLastFailure: true,
    }],
    ['allure', {
      outputDir: './allure-results',
      disableWebdriverStepsReporting: true,
      disableWebdriverScreenshotsReporting: false,
      useCucumberStepReporter: true,
      addConsoleLogs: true,
    }],
  ],

and also i tried the config from the repository

Screenshot 2024-03-07 at 09 36 27
seanpoulter commented 6 months ago

To offer some feedback on what you've shared:

I was able to install and run ffmpeg in a centos8 container with no problems after installing @ffmpeg-installer/ffmpeg. This leads me to believe there's a problem installing the npm packages and downloading the binary in your environment. I'd suggest checking the logs, or trying to reproduce the issue with only @ffmpeg-installer/ffmpeg as a dependency:

mkdir issue-162
cd issue-162
npm init -y
npm install --save @ffmpeg-installer/ffmpeg
# => Should install with warnings about optional dependencies.

node -e 'console.log(require("@ffmpeg-installer/ffmpeg"))'
# => Should print the path to ffmpeg in node_modules and not say unsupported architecture.

I believe you'll see the same error as your original post. That means the binary isn't being found in these locations: https://github.com/kribblo/node-ffmpeg-installer/blob/3c38a9573b2eb5dc6030977cbf1011896e262e31/index.js#L42

What package manager are you using? Is it a monorepo, or an old version of Node and npm?

mpermperpisang commented 6 months ago

i'm using node v18.19.0 & npm 10.4.0, @seanpoulter

seanpoulter commented 6 months ago

i'm using node v18.19.0 & npm 10.4.0

Oh, interesting. As you'll see below, ffmpeg installed and ran OK for me. We'll need more information, or a minimal example including complete steps to create the environment, to help you any further.

--

Here's what I tried:

$ docker run -it centos:centos8 bash
[Evidence that bash has started]

$ dnf install nodejs
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

It sounds like this is an expected error because CentOS 8 reached end-of-life at the end of 2021. I've followed the instructions from https://stackoverflow.com/a/70930049.

$ dnf module install nodejs:18/common
[Evidence Node.js is installed]

$ node -v
v18.9.1

$ npm -v
v8.19.1

These versions don't match what you provided so I've followed these docs to install Node.js using the binaries from NodeSource.

And to repeat the example from above:

$ npm init -y
$ npm install --save @ffmpeg-installer/ffmpeg
[No warnings[

$ node -e 'console.log(require("@ffmpeg-installer/ffmpeg").path)'
<directory>/node_modules/@ffmpeg-installer/linux-arm64/ffmpeg

$ ./node_modules/@ffmpeg-installer/linux-arm64/ffmpeg -v
ffmpeg version N-49006-...

ffmpeg is installed and found. I believe yours would say x64 instead of arm64:

mpermperpisang commented 6 months ago

hi @seanpoulter i see you're using docker(?) but i don't..i literally run the jenkins in centos8 vm but i'll try to use the same method as you

seanpoulter commented 6 months ago

I used Docker since it was the fastest way to run CentOS 8 and don't have steps to reproduce your environment.

Good luck. Hopefully you find something interesting!