Skip to content

Commit

Permalink
Use mage target instead of nosetests on Windows jenkins CI (#16141)
Browse files Browse the repository at this point in the history
Replaces use of nosetests with mage wrapper in script for Windows CI workers.

Mage manages their own python virtual environments, this is preferred to directly
call python commands.

Installs python 3 using chocolatey, as it is still not available in Windows CI workers.

future was failing to install in Windows, but we don't actually need it anymore,
so it is removed.
  • Loading branch information
jsoriano committed Feb 11, 2020
1 parent 91f7ea8 commit 1d2252d
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 11 deletions.
9 changes: 7 additions & 2 deletions dev-tools/jenkins_ci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ $packages = ($packages|group|Select -ExpandProperty Name) -join ","
exec { go test -race -c -cover -covermode=atomic -coverpkg $packages } "go test -race -cover FAILURE"

if (Test-Path "tests\system") {
Set-Location -Path tests\system
exec { nosetests --with-timer --with-xunit --xunit-file=../../build/TEST-system.xml } "System test FAILURE"
echo "Running python tests"
choco install python -y -r --no-progress --version 3.8.1.20200110
refreshenv
$env:PATH = "C:\Python38;C:\Python38\Scripts;$env:PATH"
$env:PYTHON_ENV = "$env:TEMP\python-env"
python --version
exec { mage pythonUnitTest } "System test FAILURE"
}
3 changes: 1 addition & 2 deletions filebeat/tests/open-file-handlers/log_stdout.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from past.utils import old_div
import time
import sys

Expand All @@ -19,5 +18,5 @@
# Setup python log handler
handler = logging.handlers.RotatingFileHandler(
log_file, maxBytes=line_length * lines_per_file + 1,
backupCount=old_div(total_lines, lines_per_file) + 1)
backupCount=int(total_lines/lines_per_file) + 1)
logger.addHandler(handler)
4 changes: 2 additions & 2 deletions filebeat/tests/system/test_crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def test_utf8(self):
max_timeout=15)

# Add utf-8 Chars for the first time
with codecs.open(testfile, "w", "utf-8") as f:
with codecs.open(testfile, "w", "utf_8") as f:
# Write lines before registrar started

# Special encoding needed?!?
Expand All @@ -528,7 +528,7 @@ def test_utf8(self):
lambda: self.output_has(lines=1), max_timeout=10)

# Append utf-8 chars to check if it keeps reading
with codecs.open(testfile, "a") as f:
with codecs.open(testfile, "a", "utf_8") as f:
# write additional lines
f.write("Hello\n")
f.write("薩科Ruflin" + "\n")
Expand Down
3 changes: 1 addition & 2 deletions filebeat/tests/system/test_load.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from past.utils import old_div
from filebeat import BaseTest
import os
import logging
Expand Down Expand Up @@ -41,7 +40,7 @@ def test_no_missing_events(self):
# Setup python log handler
handler = logging.handlers.RotatingFileHandler(
log_file, maxBytes=line_length * lines_per_file + 1,
backupCount=old_div(total_lines, lines_per_file) + 1)
backupCount=int(total_lines / lines_per_file) + 1)
logger.addHandler(handler)

self.render_config_template(
Expand Down
2 changes: 2 additions & 0 deletions heartbeat/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import (
"github.com/elastic/beats/dev-tools/mage/target/common"
// mage:import
_ "github.com/elastic/beats/dev-tools/mage/target/integtest/notests"
// mage:import
_ "github.com/elastic/beats/dev-tools/mage/target/unittest"
)

func init() {
Expand Down
2 changes: 2 additions & 0 deletions journalbeat/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import (
"github.com/elastic/beats/dev-tools/mage/target/common"
// mage:import
_ "github.com/elastic/beats/dev-tools/mage/target/integtest/notests"
// mage:import
_ "github.com/elastic/beats/dev-tools/mage/target/unittest"
)

func init() {
Expand Down
2 changes: 2 additions & 0 deletions libbeat/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (

// mage:import
_ "github.com/elastic/beats/dev-tools/mage/target/common"
// mage:import
_ "github.com/elastic/beats/dev-tools/mage/target/unittest"
)

// Build builds the Beat binary.
Expand Down
1 change: 0 additions & 1 deletion libbeat/tests/system/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ dockerpty==0.4.1
docopt==0.6.2
elasticsearch==7.1.0
enum34==1.1.6
future==0.18.2
idna==2.6
ipaddress==1.0.19
Jinja2==2.10.1
Expand Down
1 change: 0 additions & 1 deletion script/kibana-migration.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from past.builtins import basestring
import yaml
import glob

Expand Down
1 change: 0 additions & 1 deletion script/renamed_fields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from past.builtins import basestring
import yaml


Expand Down
2 changes: 2 additions & 0 deletions x-pack/libbeat/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
_ "github.com/elastic/beats/dev-tools/mage/target/common"
// mage:import
_ "github.com/elastic/beats/dev-tools/mage/target/integtest"
// mage:import
_ "github.com/elastic/beats/dev-tools/mage/target/unittest"
)

func init() {
Expand Down

0 comments on commit 1d2252d

Please sign in to comment.