Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate scripts to python 3 #14798

Merged
merged 58 commits into from
Feb 17, 2020
Merged

Migrate scripts to python 3 #14798

merged 58 commits into from
Feb 17, 2020

Commits on Nov 26, 2019

  1. Set PYTHON_EXE to python3

    jsoriano committed Nov 26, 2019
    Configuration menu
    Copy the full SHA
    34a0df8 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5fa5430 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c93c97f View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    f05d17e View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    f77869d View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    ce3dcc8 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    73fca9d View commit details
    Browse the repository at this point in the history

Commits on Nov 28, 2019

  1. Configuration menu
    Copy the full SHA
    933f1af View commit details
    Browse the repository at this point in the history
  2. Upgrade base image in travis

    jsoriano committed Nov 28, 2019
    Configuration menu
    Copy the full SHA
    c7b67d1 View commit details
    Browse the repository at this point in the history
  3. Revert "Upgrade base image in travis"

    This reverts commit c7b67d1.
    jsoriano committed Nov 28, 2019
    Configuration menu
    Copy the full SHA
    3f0aefd View commit details
    Browse the repository at this point in the history
  4. Revert "Set version of python for travis"

    This reverts commit 933f1af.
    jsoriano committed Nov 28, 2019
    Configuration menu
    Copy the full SHA
    5cc56aa View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    d46ac2c View commit details
    Browse the repository at this point in the history

Commits on Nov 29, 2019

  1. Typo

    jsoriano committed Nov 29, 2019
    Configuration menu
    Copy the full SHA
    4d0695a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    713c75f View commit details
    Browse the repository at this point in the history

Commits on Dec 2, 2019

  1. Configuration menu
    Copy the full SHA
    dd5ce17 View commit details
    Browse the repository at this point in the history
  2. Use future and pylint

    jsoriano committed Dec 2, 2019
    Configuration menu
    Copy the full SHA
    ca3958e View commit details
    Browse the repository at this point in the history
  3. Add future dependency

    jsoriano committed Dec 2, 2019
    Configuration menu
    Copy the full SHA
    28ffc35 View commit details
    Browse the repository at this point in the history

Commits on Dec 3, 2019

  1. Configuration menu
    Copy the full SHA
    20e1ecc View commit details
    Browse the repository at this point in the history
  2. Make independent python virtualenvs in docker (#14903)

    System tests running in docker are using the same virtual environment as
    the host. If version of python in the virtual environment is not available
    in the guest, it will use the default in the system, that is so far
    Python 2.
    jsoriano authored Dec 3, 2019
    Configuration menu
    Copy the full SHA
    360d5e1 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    21dd3d3 View commit details
    Browse the repository at this point in the history

Commits on Dec 9, 2019

  1. Migrate Functionbeat to Python3 (#14901)

    fix 'str' does not support the buffer interface
    kvch authored Dec 9, 2019
    Configuration menu
    Copy the full SHA
    cf84305 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e241826 View commit details
    Browse the repository at this point in the history

Commits on Dec 10, 2019

  1. Configuration menu
    Copy the full SHA
    8d9ce27 View commit details
    Browse the repository at this point in the history

Commits on Dec 13, 2019

  1. Configuration menu
    Copy the full SHA
    ee30315 View commit details
    Browse the repository at this point in the history

Commits on Dec 20, 2019

  1. Fix make check for python 3 (#15226)

    * Run autopep on script/update_golang_x.py to fix make check
    * Update travis to use Ubuntu Bionic
    mikemadden42 authored Dec 20, 2019
    Configuration menu
    Copy the full SHA
    b9629f9 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f2a3f84 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    66e2dc1 View commit details
    Browse the repository at this point in the history

Commits on Jan 15, 2020

  1. Listen explicitly on localhost on heartbeat TCP tests (#15583)

    Some tests were requiring localhost to resolve to 127.0.0.1, but this is
    not always the case. In some machines localhost resolve to other local
    addresses as 127.0.1.1, or to [::1] if ipv4 is not available.
    jsoriano authored Jan 15, 2020
    Configuration menu
    Copy the full SHA
    3c908d1 View commit details
    Browse the repository at this point in the history

Commits on Jan 16, 2020

  1. Regenerate test certificates to include 127.0.1.1 (#15591)

    Localhost in travis resolves to 127.0.1.1, include this IP as alternate
    name in certificates used for outputs testing.
    jsoriano authored Jan 16, 2020
    Configuration menu
    Copy the full SHA
    dd723d9 View commit details
    Browse the repository at this point in the history

Commits on Jan 17, 2020

  1. Configuration menu
    Copy the full SHA
    75ca56a View commit details
    Browse the repository at this point in the history

Commits on Jan 20, 2020

  1. Configuration menu
    Copy the full SHA
    8ad222f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ac9af57 View commit details
    Browse the repository at this point in the history

Commits on Jan 22, 2020

  1. Update script shebangs to python3 (#15701)

    Use python3 in the shebang for python scripts. python is going to be reserved for python2 in Ubuntu, and PEP394 mentions that python should be used in the shebang line only for scripts that are source compatible with both Python 2 and 3.
    andrewkroh authored Jan 22, 2020
    Configuration menu
    Copy the full SHA
    63c4b1c View commit details
    Browse the repository at this point in the history
  2. Update documented Python version to 3.7 (#15702)

    Document python requirement as >= 3.7.
    andrewkroh authored Jan 22, 2020
    Configuration menu
    Copy the full SHA
    2bd5181 View commit details
    Browse the repository at this point in the history
  3. Fix python sys.platform check for Linux (#15727)

    On Linux, sys.platform doesn’t contain the major version anymore. It is now always ‘linux’, instead of ‘linux2’ or ‘linux3’ depending on the Linux version used to build Python. Replace sys.platform == ‘linux2’ with sys.platform.startswith(‘linux’), or directly sys.platform == ‘linux’ if you don’t need to support older Python versions.
    
    Ref: https://docs.python.org/3.3/whatsnew/3.3.html#porting-python-code
    andrewkroh authored Jan 22, 2020
    Configuration menu
    Copy the full SHA
    d037668 View commit details
    Browse the repository at this point in the history
  4. Read hits.total.value to get number of hits (#15728)

    This should fix test_management.py under Python3. An object was being returned but
    the test was expecting to get a number. The format of the Elasticsearch response changed
    for the "track_total_hits" enhancement, but this wasn't updated.
    andrewkroh authored Jan 22, 2020
    Configuration menu
    Copy the full SHA
    1ceabf0 View commit details
    Browse the repository at this point in the history

Commits on Jan 23, 2020

  1. Libbeat test fixes (#15726)

    This has a few fixes to python system tests under libbeat/tests/system.
    
    assert_docs_written_to_alias had an invalid assertion ever since Elasticsearch
    changed the format of the hits count to allow for track_total_hits false. Many
    tests were using this assertion even when not indexing any events so the hit
    count would always be zero so I removed the assertion from those tests.
    
    In other tests I was getting spurious failures because _search was being called
    before the index was refreshed to allow the documents to be search able. So I
    added an explicit /_refresh to fix the issue.
    
    I changed create_kibana_space to allow a 409 response code so you can run the
    tests more than once against a Kibana instance.
    
    I fixed an assertion on the mode bits of a file since the format of octal numbers is
    always prefixed with '0o' now.
    
    And I fixed the libbeat keystore tests by encoding the secret string to binary
    before calling os.write. This fixed this error:
    
    ```
    ======================================================================
    ERROR: Add a secret to the store using stdin
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/Users/akroh/go/src/github.com/elastic/beats/libbeat/tests/system/test_cmd_keystore.py", line 130, in test_keystore_add_secret_from_stdin
        exit_code = self.add_secret("willnotdelete")
      File "/Users/akroh/go/src/github.com/elastic/beats/libbeat/tests/system/keystore.py", line 29, in add_secret
        os.write(proc.stdin_write, value)
    TypeError: a bytes-like object is required, not 'str'
    ```
    andrewkroh authored Jan 23, 2020
    Configuration menu
    Copy the full SHA
    40bac68 View commit details
    Browse the repository at this point in the history

Commits on Jan 24, 2020

  1. Merge remote-tracking branch 'origin/master' into update-python3-fix-…

    …auditbeat-and-dashboards
    jsoriano committed Jan 24, 2020
    Configuration menu
    Copy the full SHA
    b09e537 View commit details
    Browse the repository at this point in the history
  2. Use 'python3 -m venv' instead of virtualenv (#15754)

    Switch over to `python3 -m venv` instead of `virtualenv`. It's the recommended way to create virtual Python environments in 3.4 and above.
    
    https://docs.python.org/3/library/venv.html
    
    Remove any direct references to python to always allow
    a specific python binary or version to be used.
    andrewkroh authored and jsoriano committed Jan 24, 2020
    Configuration menu
    Copy the full SHA
    81bb7ef View commit details
    Browse the repository at this point in the history
  3. Fix activemq tests

    jsoriano committed Jan 24, 2020
    Configuration menu
    Copy the full SHA
    f4e0187 View commit details
    Browse the repository at this point in the history
  4. Remove docs build from travis (#15816)

    It is failing with python 3 and we have another more complete build to
    test this in Jenkins.
    jsoriano authored and andrewkroh committed Jan 24, 2020
    Configuration menu
    Copy the full SHA
    01c531c View commit details
    Browse the repository at this point in the history
  5. Merge remote-tracking branch 'jsoriano/update-python3-fix-auditbeat-a…

    …nd-dashboards' into HEAD
    jsoriano committed Jan 24, 2020
    Configuration menu
    Copy the full SHA
    975abe9 View commit details
    Browse the repository at this point in the history
  6. Add missing integration_tests check to metricbeat xpack test (#15779)

    This test was running with the unit test target and failing.
    andrewkroh authored Jan 24, 2020
    Configuration menu
    Copy the full SHA
    66250f0 View commit details
    Browse the repository at this point in the history

Commits on Jan 27, 2020

  1. Configuration menu
    Copy the full SHA
    b34d460 View commit details
    Browse the repository at this point in the history
  2. Python3 Windows and Winlogbeat updates (#15831)

    * Python3 Windows and Winlogbeat updates
    
    This updates the Vagrantfile and addresses a few issues. I installed Python3 on Windows
    via chocolotey and the python MSI and neither provided a `python3` command so I adjusted
    the build tooling to use `python` on Windows.
    
    Another issue I hit was that under Vagrant with the shared filesystem, `pip` would not
    install into the virtual environment. It only will install when moving the PYTHON_ENV
    off of the shared filesystem. So when provisining the Vagrant VM it will now put
    PYTHON_ENV in C:\beats-python-env. Remember this if you need need to do a completely
    clean build on Windows+Vagrant.
    
    There were some encoding issues I found while reading output files containing unicode.
    So I modified the libbeat's beat.py to specify `utf_8` encoding when opening output files.
    I was seeing errors like:
    
    ```
    ======================================================================
    ERROR: eventlogging - UTF-16 characters
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "C:\Gopath\src\github.com\elastic\beats\winlogbeat\tests\system\test_eventlogging.py", line 187, in test_utf16_characters
        evts = self.read_events(config={
      File "C:\Gopath\src\github.com\elastic\beats\winlogbeat\tests\system\winlogbeat.py", line 110, in read_events
        return self.read_output()
      File "C:\Gopath\src\github.com\elastic\beats\winlogbeat\tests\system\../../../libbeat/tests/system\beat\beat.py", line 260, in read_output
        for line in f:
      File "C:\Python38\lib\encodings\cp1252.py", line 23, in decode
        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
    UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 277: character maps to <undefined>
    ```
    
    I bumped the Pillow version in the pip requirements because the newer version provides a
    precompiled wheel for Python 3 on Windows. This avoids having to compiling it. I bumped
    the Docker versions while debugging and just left them at the latest version since nothing broke.
    
    I tested Winlogbeat and Metricbeat's `mage pythonUnitTest` on Windows 2019 and all tests passed.
    andrewkroh authored Jan 27, 2020
    Configuration menu
    Copy the full SHA
    7a72c55 View commit details
    Browse the repository at this point in the history

Commits on Jan 28, 2020

  1. Try to fix flakiness of appsearch system tests (#15878)

    Use the health check of the service for the docker health check,
    and check the status code of the response.
    
    Print nosetests output on builds.
    jsoriano authored Jan 28, 2020
    Configuration menu
    Copy the full SHA
    cc6d798 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    32a680c View commit details
    Browse the repository at this point in the history
  3. Use JSON string for dictionary example (#15898)

    Some versions of python cannot guarantee order of dictionaries, so same
    dictionary can generate different documentation strings. Use a JSON
    string so its representation doesn't depend on how python encodes it.
    
    Also, fix versions in python-env for root directory.
    jsoriano authored Jan 28, 2020
    Configuration menu
    Copy the full SHA
    ae546c7 View commit details
    Browse the repository at this point in the history

Commits on Jan 30, 2020

  1. Configuration menu
    Copy the full SHA
    c6fdaf0 View commit details
    Browse the repository at this point in the history

Commits on Jan 31, 2020

  1. Configuration menu
    Copy the full SHA
    fcd87dc View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    91f7ea8 View commit details
    Browse the repository at this point in the history

Commits on Feb 11, 2020

  1. Use mage target instead of nosetests on Windows jenkins CI (#16141)

    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.
    jsoriano authored Feb 11, 2020
    Configuration menu
    Copy the full SHA
    1d2252d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ee61137 View commit details
    Browse the repository at this point in the history

Commits on Feb 12, 2020

  1. Configuration menu
    Copy the full SHA
    dd503e6 View commit details
    Browse the repository at this point in the history
  2. Skip monitoring flaky test (#16248)

    Skip tests frequently failing in python 3 branch.
    #16247
    jsoriano authored Feb 12, 2020
    Configuration menu
    Copy the full SHA
    1d311e4 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e24232b View commit details
    Browse the repository at this point in the history
  4. Typo in packetbeat script

    jsoriano committed Feb 12, 2020
    Configuration menu
    Copy the full SHA
    87155e8 View commit details
    Browse the repository at this point in the history

Commits on Feb 15, 2020

  1. Configuration menu
    Copy the full SHA
    bd6d8cf View commit details
    Browse the repository at this point in the history