Skip to content

Commit

Permalink
Merge branch 'fix_test'
Browse files Browse the repository at this point in the history
  • Loading branch information
Kami committed Jan 20, 2022
2 parents 31a917c + fe24893 commit e1d2a25
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 20 deletions.
41 changes: 28 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -821,46 +821,61 @@ jobs:
python_version: "3.5"
tox_target: "py3.5-unit-tests"

unittest-35-osx:
unittest-37-osx:
working_directory: ~/scalyr-agent-2
macos:
xcode: "11.2.1"
xcode: "13.2.1"
environment:
PYTHON: 3.5.6
# Updating homebrew is slow
PYTHON: 3.7.10
# Updating homebrew is slow so we skip it
HOMEBREW_NO_AUTO_UPDATE: 1
steps:
- checkout
- run:
name: install pyenv
name: Install pyenv
shell: bash
command: |
brew install pyenv
- restore_cache:
key: deps-<< pipeline.parameters.cache_version_py_dependencies >>-tox-{{ .Branch }}-3.5-osx-venv-{{ checksum "dev-requirements.txt" }}
name: Restore pyenv cache
key: deps-<< pipeline.parameters.cache_version_py_dependencies >>-xcode-13.2.1-tox-{{ .Branch }}-py-3.7-osx-venv-{{ checksum "dev-requirements.txt" }}-pyenv
- run:
name: Install Python
command: |
pyenv install $PYTHON -s
# For Python < 3.8 we need a workaround so the install doesn't fail
# CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include"
# LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib"
# pyenv install --patch "$PYTHON" < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)
pyenv install "$PYTHON" -s
- save_cache:
name: Save pyenv cache
key: deps-<< pipeline.parameters.cache_version_py_dependencies >>-xcode-13.2.1-tox-{{ .Branch }}-py-3.7-osx-venv-{{ checksum "dev-requirements.txt" }}-pyenv
paths:
- ~/.pyenv
- restore_cache:
name: Restore pip cache
key: deps-<< pipeline.parameters.cache_version_py_dependencies >>-xcode-13.2.1-tox-{{ .Branch }}-py-3.7-osx-venv-{{ checksum "dev-requirements.txt" }}-pip
- run:
name: Install Dependencies
command: |
hash -r
eval "$(pyenv init --path)"
pyenv local $PYTHON
python -m pip install virtualenv
python -m virtualenv venv
./venv/bin/pip install --upgrade pip
./venv/bin/pip install "tox==<< pipeline.parameters.default_tox_version >>"
- run:
name: Run Unit Tests under Python 3.5
name: Run Unit Tests
command: |
pyenv local $PYTHON
source ./venv/bin/activate
tox -epy3.5-unit-tests
tox -epy3.7-unit-tests
- save_cache:
key: deps-<< pipeline.parameters.cache_version_py_dependencies >>-tox-{{ .Branch }}-3.5-osx-venv-{{ checksum "dev-requirements.txt" }}
name: Save pip cache
key: deps-<< pipeline.parameters.cache_version_py_dependencies >>-xcode-13.2.1-tox-{{ .Branch }}-py-3.7-osx-venv-{{ checksum "dev-requirements.txt" }}-pip
paths:
- ~/.cache/pip
- ~/.pyenv
- slack/status:
fail_only: true
only_for_branches: master
Expand Down Expand Up @@ -2261,7 +2276,7 @@ workflows:
context: scalyr-agent
- unittest-35:
context: scalyr-agent
- unittest-35-osx:
- unittest-37-osx:
context: scalyr-agent
- unittest-38-windows:
context: scalyr-agent
Expand Down Expand Up @@ -2408,7 +2423,7 @@ workflows:
context: scalyr-agent
- unittest-35:
context: scalyr-agent
- unittest-35-osx:
- unittest-37-osx:
context: scalyr-agent
- unittest-38-windows:
context: scalyr-agent
Expand Down
9 changes: 4 additions & 5 deletions agent_build/requirement-files/main-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# NOTE: orjson don't include pre-built wheels for ARMv7 for glibc and
# musl.
orjson==3.6.5; python_version >= '3.7' and 'armv7' not in platform_machine
orjson==3.6.1; python_version == '3.6' and 'armv7' not in platform_machine
orjson==2.0.11; python_version == '3.5' and 'armv7' not in platform_machine
# NOTE: orjson doesnt provide pre-built wheels for ARMv7 for glibc and musl.
orjson==3.6.5; python_version >= '3.7' and 'armv7' not in platform_machine and platform_system != 'Darwin'
orjson==3.6.1; python_version == '3.6' and 'armv7' not in platform_machine and platform_system != 'Darwin'
orjson==2.0.11; python_version == '3.5' and 'armv7' not in platform_machine and platform_system != 'Darwin'

requests==2.20.0
9 changes: 7 additions & 2 deletions tests/unit/util/json_util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import unittest
import importlib
import locale
import platform

import six
import mock
Expand All @@ -34,7 +35,7 @@
from scalyr_agent.test_base import ScalyrTestCase
from scalyr_agent.test_base import skipIf

if six.PY3:
if six.PY3 and platform.system() != "Darwin":
reload = importlib.reload
import orjson

Expand Down Expand Up @@ -82,6 +83,7 @@ def test_long(self):
def test_negative_long(self):
self.__test_encode_decode(r"-1234567890123456789", -1234567890123456789)

@skipIf(platform.system() == "Darwin", "Skipping under OSX")
def test_64_bit_int(self):
# NOTE: Latest version of orjson available for Python >= 3.6 can also serialize large
# siigned and unsigned 64 bit ints
Expand Down Expand Up @@ -157,7 +159,7 @@ def __runtest(library):
__runtest(UJSON)
if sys.version_info[:2] > (2, 5):
__runtest(JSON)
if sys.version_info[:2] >= (3, 5):
if sys.version_info[:2] >= (3, 5) and platform.system() != "Darwin":
__runtest(ORJSON)

# do the same check but now with binary string.
Expand Down Expand Up @@ -205,6 +207,7 @@ def test_non_ascii_data_non_utf_locale_coding_default_json_lib(self):
self.assertEqual(loaded, original_data)

@skipIf(six.PY2, "Skipping under Python 2")
@skipIf(platform.system() == "Darwin", "Skipping under OSX")
def test_non_ascii_data_non_utf_locale_coding_orjson(self):
util.set_json_lib("orjson")
original_data = "čććžšđ"
Expand Down Expand Up @@ -244,6 +247,7 @@ def tearDown(self):
del sys.modules[value]

@skipIf(six.PY2, "Skipping under Python 2")
@skipIf(platform.system() == "Darwin", "Skipping under OSX")
def test_correct_default_json_library_is_used_python3(self):
sys.modules["orjson"] = mock.Mock()

Expand Down Expand Up @@ -273,6 +277,7 @@ def test_correct_default_json_library_is_used_python3(self):
self.assertEqual(scalyr_agent.util.get_json_lib(), "json")

@skipIf(six.PY3, "Skipping under Python 3")
@skipIf(platform.system() == "Darwin", "Skipping under OSX")
def test_correct_default_json_library_is_used_python2(self):
# NOTE: orjson is not available on Python 2 so we should not try and use it
sys.modules["orjson"] = mock.Mock()
Expand Down

0 comments on commit e1d2a25

Please sign in to comment.