kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ewe...@apache.org
Subject [1/2] kafka git commit: KAFKA-3592: System test - configurable paths
Date Fri, 06 May 2016 18:12:56 GMT
Repository: kafka
Updated Branches:
  refs/heads/0.10.0 cda571dfc -> aabf82514


http://git-wip-us.apache.org/repos/asf/kafka/blob/aabf8251/tests/unit/directory_layout/check_project_paths.py
----------------------------------------------------------------------
diff --git a/tests/unit/directory_layout/check_project_paths.py b/tests/unit/directory_layout/check_project_paths.py
new file mode 100644
index 0000000..284e4d5
--- /dev/null
+++ b/tests/unit/directory_layout/check_project_paths.py
@@ -0,0 +1,90 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+from kafkatest.directory_layout.kafka_path import create_path_resolver, KafkaSystemTestPathResolver,
\
+    KAFKA_PATH_RESOLVER_KEY
+from kafkatest.version import V_0_9_0_1, TRUNK, KafkaVersion
+
+
+class DummyContext(object):
+    def __init__(self):
+        self.globals = {}
+
+
+class DummyPathResolver(object):
+    """Dummy class to help check path resolver creation."""
+    def __init__(self, context, project_name):
+        pass
+
+class DummyNode(object):
+    """Fake node object"""
+    pass
+
+class CheckCreatePathResolver(object):
+    def check_create_path_resolver_override(self):
+        """Test override behavior when instantiating a path resolver using our factory function.
+
+        If context.globals has an entry for a path resolver class, use that class instead
of the default.
+        """
+        mock_context = DummyContext()
+        mock_context.globals[KAFKA_PATH_RESOLVER_KEY] = \
+            "unit.directory_layout.check_project_paths.DummyPathResolver"
+
+        resolver = create_path_resolver(mock_context)
+        assert type(resolver) == DummyPathResolver
+
+    def check_create_path_resolver_default(self):
+        """Test default behavior when instantiating a path resolver using our factory function.
+        """
+        resolver = create_path_resolver(DummyContext())
+        assert type(resolver) == KafkaSystemTestPathResolver
+
+    def check_paths(self):
+        """Check expected path resolution without any version specified."""
+        resolver = create_path_resolver(DummyContext())
+
+        assert resolver.home() == "/opt/kafka-trunk"
+        assert resolver.bin() == "/opt/kafka-trunk/bin"
+        assert resolver.script("kafka-run-class.sh") == "/opt/kafka-trunk/bin/kafka-run-class.sh"
+
+    def check_versioned_source_paths(self):
+        """Check expected paths when using versions."""
+        resolver = create_path_resolver(DummyContext())
+
+        assert resolver.home(V_0_9_0_1) == "/opt/kafka-0.9.0.1"
+        assert resolver.bin(V_0_9_0_1) == "/opt/kafka-0.9.0.1/bin"
+        assert resolver.script("kafka-run-class.sh", V_0_9_0_1) == "/opt/kafka-0.9.0.1/bin/kafka-run-class.sh"
+
+    def check_node_or_version_helper(self):
+        """KafkaSystemTestPathResolver has a helper method which can take a node or version,
and returns the version.
+        Check expected behavior here.
+        """
+        resolver = create_path_resolver(DummyContext())
+
+        # Node with no version attribute should resolve to TRUNK
+        node = DummyNode()
+        assert resolver._version(node) == TRUNK
+
+        # Node with version attribute should resolve to the version attribute
+        node.version = V_0_9_0_1
+        assert resolver._version(node) == V_0_9_0_1
+
+        # A KafkaVersion object should resolve to itself
+        assert resolver._version(TRUNK) == TRUNK
+        version = KafkaVersion("999.999.999")
+        assert resolver._version(version) == version
+
+

http://git-wip-us.apache.org/repos/asf/kafka/blob/aabf8251/tests/unit/setup.cfg
----------------------------------------------------------------------
diff --git a/tests/unit/setup.cfg b/tests/unit/setup.cfg
new file mode 100644
index 0000000..e757a99
--- /dev/null
+++ b/tests/unit/setup.cfg
@@ -0,0 +1,23 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# pytest configuration (can also be defined in in tox.ini or pytest.ini file)
+#
+# To ease possible confusion, prefix muckrake *unit* tests with 'check' instead of 'test',
since
+# many muckrake files, classes, and methods have 'test' somewhere in the name
+[pytest]
+python_files=check_*.py
+python_classes=Check
+python_functions=check_*

http://git-wip-us.apache.org/repos/asf/kafka/blob/aabf8251/tests/unit/version/__init__.py
----------------------------------------------------------------------
diff --git a/tests/unit/version/__init__.py b/tests/unit/version/__init__.py
new file mode 100644
index 0000000..e556dc9
--- /dev/null
+++ b/tests/unit/version/__init__.py
@@ -0,0 +1,15 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+

http://git-wip-us.apache.org/repos/asf/kafka/blob/aabf8251/tests/unit/version/check_version.py
----------------------------------------------------------------------
diff --git a/tests/unit/version/check_version.py b/tests/unit/version/check_version.py
new file mode 100644
index 0000000..7b85551
--- /dev/null
+++ b/tests/unit/version/check_version.py
@@ -0,0 +1,33 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from mock import Mock
+
+from kafkatest.version import TRUNK, V_0_8_2_2, get_version
+
+
+class CheckVersion(object):
+    def check_get_version(self):
+        """Check default and override behavior of get_version"""
+        node = None
+        assert get_version(node) == TRUNK
+
+        node = Mock()
+        node.version = None
+        assert get_version(node) == TRUNK
+
+        node = Mock()
+        node.version = V_0_8_2_2
+        assert get_version(node) == V_0_8_2_2
\ No newline at end of file


Mime
View raw message