Skip to content

Commit

Permalink
Don’t use cached autoconfig client in config tests (#2120)
Browse files Browse the repository at this point in the history
In hdfs_test.ConfigurationTest, calls to hdfs.get_autoconfig_client
return the version cached in the call to setUp. Because this is called
before the config is set by the helpers.with_config decorator, this
means that the tests aren’t actually testing different configurations.

Luckily, get_autoconfig_client takes an optional argument to specify its
cache. When passing a fresh cache, these will actually test what they’re
supposed to. This PR passes a fresh cache to get_autoconfig_client in
each test.
  • Loading branch information
daveFNbuck authored and Tarrasch committed May 21, 2017
1 parent 447489a commit 50ec7fe
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions test/contrib/hdfs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import re
from helpers import unittest
import random
import threading
import pickle

import helpers
Expand All @@ -27,6 +28,9 @@
import luigi.format
from luigi.contrib import hdfs
from luigi import six
from luigi.contrib.hdfs import SnakebiteHdfsClient
from luigi.contrib.hdfs.hadoopcli_clients import HdfsClient
from luigi.contrib.target import CascadingClient
from minicluster import MiniClusterTestCase
from nose.plugins.attrib import attr
import luigi.contrib.hdfs.clients
Expand Down Expand Up @@ -75,17 +79,22 @@ def test_when_not_specified(self):

@helpers.with_config({"hdfs": {"client": "hadoopcli"}})
def test_hadoopcli(self):
client = hdfs.get_autoconfig_client()
client = hdfs.get_autoconfig_client(threading.local())
self.assertTrue(isinstance(client, HdfsClient))
self.tezt_rename_dont_move(client)

@unittest.skipIf(six.PY3, "snakebite doesn't work on Python 3 yet.")
@helpers.with_config({"hdfs": {"client": "snakebite"}})
def test_snakebite(self):
client = hdfs.get_autoconfig_client()
client = hdfs.get_autoconfig_client(threading.local())
self.assertTrue(isinstance(client, SnakebiteHdfsClient))
self.tezt_rename_dont_move(client)

@unittest.skipIf(six.PY3, "snakebite doesn't work on Python 3 yet.")
@helpers.with_config({"hdfs": {"client": "snakebite_with_hadoopcli_fallback"}})
def test_snakebite_with_hadoopcli_fallback(self):
client = hdfs.get_autoconfig_client()
client = hdfs.get_autoconfig_client(threading.local())
self.assertTrue(isinstance(client, CascadingClient))
self.tezt_rename_dont_move(client)


Expand Down

0 comments on commit 50ec7fe

Please sign in to comment.