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

Don't create temp folder if local storage disabled #1212

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
runs-on: ubuntu-20.04
env:
# We use these variables to convert between tox and GHA version literals
py27: 2.7
py35: 3.5
py36: 3.6
py37: 3.7
Expand All @@ -23,7 +22,7 @@ jobs:
# ensures the entire test matrix is run, even if one permutation fails
fail-fast: false
matrix:
python-version: [py27, py35, py36, py37, py38, py39]
python-version: [py35, py36, py37, py38, py39]
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def process_options(options):
)

# storage path
if options.storage_path is None:
if options.enable_local_storage and options.storage_path is None:
TEMPDIR_SUFFIX = options.instrumentation_key or ""
options.storage_path = os.path.join(
tempfile.gettempdir(),
Expand Down
2 changes: 0 additions & 2 deletions contrib/opencensus-ext-azure/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
Expand Down
18 changes: 18 additions & 0 deletions contrib/opencensus-ext-azure/tests/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import os
import unittest

import mock

from opencensus.ext.azure import common


Expand Down Expand Up @@ -108,6 +110,22 @@ def test_process_options_proxies_set_proxies(self):
'{"https": "https://test-proxy.com"}'
)

@mock.patch("opencensus.ext.azure.common.tempfile")
def test_process_options_enable_local_storage(self, mock_tempfile):
options = common.Options()

self.assertTrue(options.enable_local_storage)
self.assertIsNotNone(options.storage_path)
mock_tempfile.gettempdir.assert_called_once()

@mock.patch("opencensus.ext.azure.common.tempfile")
def test_process_options_disable_local_storage(self, mock_tempfile):
options = common.Options(enable_local_storage = False)

self.assertFalse(options.enable_local_storage, False)
self.assertIsNone(options.storage_path)
mock_tempfile.gettempdir.assert_not_called()

def test_parse_connection_string_none(self):
cs = None
result = common.parse_connection_string(cs)
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _install_test_dependencies(session):
session.install('unittest2')


@nox.session(python=['2.7', '3.5', '3.6'])
@nox.session(python=['3.5', '3.6', '3.7', '3.8', '3.9', '3.10'])
def unit(session):
"""Run the unit test suite."""

Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
Expand Down
5 changes: 2 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist =
py{27,35,36,37,38,39}-unit
py{35,36,37,38,39}-unit
py39-bandit
py39-lint
py39-setup
Expand All @@ -18,7 +18,6 @@ deps =
unit,lint: pytest-cov
unit,lint: retrying
unit,lint: unittest2
py27-unit: markupsafe==1.1.1
py35-unit: markupsafe==1.1.1
py3{6,7,8,9}-unit: markupsafe==2.0.1 # https://github.com/pallets/markupsafe/issues/282
bandit: bandit
Expand Down Expand Up @@ -60,7 +59,7 @@ deps =
docs: sphinx >= 1.6.3

commands =
py{27,34,35}-unit: {[constants]unit-base-command} --ignore=contrib/opencensus-ext-stackdriver --ignore=contrib/opencensus-ext-flask --ignore=contrib/opencensus-ext-httpx --ignore=contrib/opencensus-ext-fastapi
py{34,35}-unit: {[constants]unit-base-command} --ignore=contrib/opencensus-ext-stackdriver --ignore=contrib/opencensus-ext-flask --ignore=contrib/opencensus-ext-httpx --ignore=contrib/opencensus-ext-fastapi
py36-unit: {[constants]unit-base-command} --ignore=contrib/opencensus-ext-httpx
py3{7,8,9}-unit: {[constants]unit-base-command}

Expand Down