diff --git a/Configuration/src/AspDotNetCore/Simple/Simple.feature b/Configuration/src/AspDotNetCore/Simple/Simple.feature index e45b53d37..d9a4a4b3e 100644 --- a/Configuration/src/AspDotNetCore/Simple/Simple.feature +++ b/Configuration/src/AspDotNetCore/Simple/Simple.feature @@ -6,7 +6,7 @@ Feature: Simple Configuration @netcoreapp2.1 Scenario Outline: Simple Configuration for .Net Core 2.1 - Given you have .NET Core SDK 2.1.300 installed + Given you have at least .NET Core SDK 2.1.300 installed And you have Java 8 installed And you have Apache Maven 3 installed When you run: git clone https://github.com/spring-cloud/spring-cloud-config @@ -28,7 +28,7 @@ Feature: Simple Configuration @net461 Scenario Outline: Simple Configuration for .Net Framework 4.6.1 - Given you have .NET Core SDK 2.1.300 installed + Given you have at least .NET Core SDK 2.1.300 installed And you have Java 8 installed And you have Apache Maven 3 installed When you run: git clone https://github.com/spring-cloud/spring-cloud-config diff --git a/Configuration/src/AspDotNetCore/SimpleCloudFoundry/SimpleCloudFoundry.feature b/Configuration/src/AspDotNetCore/SimpleCloudFoundry/SimpleCloudFoundry.feature index 13f7ad4c5..d560ba881 100644 --- a/Configuration/src/AspDotNetCore/SimpleCloudFoundry/SimpleCloudFoundry.feature +++ b/Configuration/src/AspDotNetCore/SimpleCloudFoundry/SimpleCloudFoundry.feature @@ -6,7 +6,7 @@ Feature: Simple CloudFoundry Configuration @netcoreapp2.1 @win10-x64 Scenario: Simple CloudFoundry Configuration for .Net Core 2.1 (win10-x64) - Given you have .NET Core SDK 2.1.300 installed + Given you have at least .NET Core SDK 2.1.300 installed And you have CloudFoundry service p-config-server installed When you run: cf create-service p-config-server standard myConfigServer -c ./config-server.json And you wait until CloudFoundry service myConfigServer is created @@ -20,7 +20,7 @@ Feature: Simple CloudFoundry Configuration @netcoreapp2.1 @ubuntu.14.04-x64 Scenario: Simple CloudFoundry Configuration for .Net Core 2.1 (ubuntu.14.04-x64) - Given you have .NET Core SDK 2.1.300 installed + Given you have at least .NET Core SDK 2.1.300 installed And you have CloudFoundry service p-config-server installed When you run: cf create-service p-config-server standard myConfigServer -c ./config-server.json And you wait until CloudFoundry service myConfigServer is created @@ -34,7 +34,7 @@ Feature: Simple CloudFoundry Configuration @net461 @win10-x64 Scenario: Simple CloudFoundry Configuration for .Net Framework 4.6.1 (win10-x64) - Given you have .NET Core SDK 2.1.300 installed + Given you have at least .NET Core SDK 2.1.300 installed And you have CloudFoundry service p-config-server installed When you run: cf create-service p-config-server standard myConfigServer -c ./config-server.json And you wait until CloudFoundry service myConfigServer is created diff --git a/Connectors/src/AspDotNetCore/MySql/MySql.feature b/Connectors/src/AspDotNetCore/MySql/MySql.feature index f2681e1a6..91b354c37 100644 --- a/Connectors/src/AspDotNetCore/MySql/MySql.feature +++ b/Connectors/src/AspDotNetCore/MySql/MySql.feature @@ -6,7 +6,7 @@ Feature: MySql Connector @netcoreapp2.1 @win10-x64 Scenario: MySql Connector for .Net Core 2.1 (win10-x64) - Given you have .NET Core SDK 2.1.300 installed + Given you have at least .NET Core SDK 2.1.300 installed And you have CloudFoundry service p-mysql installed When you run: cf create-service p-mysql 100mb myMySqlService And you wait until CloudFoundry service myMySqlService is created @@ -21,7 +21,7 @@ Feature: MySql Connector @netcoreapp2.1 @ubuntu.14.04-x64 Scenario: MySql Connector for .Net Core 2.1 (ubuntu.14.04-x64) - Given you have .NET Core SDK 2.1.300 installed + Given you have at least .NET Core SDK 2.1.300 installed And you have CloudFoundry service p-mysql installed When you run: cf create-service p-mysql 100mb myMySqlService And you wait until CloudFoundry service myMySqlService is created @@ -36,7 +36,7 @@ Feature: MySql Connector @net461 @win10-x64 Scenario: MySql Connector for .Net Framework 4.6.1 (win10-x64) - Given you have .NET Core SDK 2.1 installed + Given you have at least .NET Core SDK 2.1.300 installed And you have CloudFoundry service p-mysql installed When you run: cf create-service p-mysql 100mb myMySqlService And you wait until CloudFoundry service myMySqlService is created diff --git a/Connectors/src/AspDotNetCore/MySqlEFCore/MySqlEFCore.feature b/Connectors/src/AspDotNetCore/MySqlEFCore/MySqlEFCore.feature index 1d2b1e8f9..083ae0c64 100644 --- a/Connectors/src/AspDotNetCore/MySqlEFCore/MySqlEFCore.feature +++ b/Connectors/src/AspDotNetCore/MySqlEFCore/MySqlEFCore.feature @@ -6,7 +6,7 @@ Feature: MySqlEFCore Connector @netcoreapp2.1 @win10-x64 Scenario: MySqlEFCore Connector for .Net Core 2.1 (win10-x64) - Given you have .NET Core SDK 2.1.300 installed + Given you have at least .NET Core SDK 2.1.300 installed And you have CloudFoundry service p-mysql installed When you run: cf create-service p-mysql 100mb myMySqlService And you wait until CloudFoundry service myMySqlService is created @@ -21,7 +21,7 @@ Feature: MySqlEFCore Connector @netcoreapp2.1 @ubuntu.14.04-x64 Scenario: MySqlEFCore Connector for .Net Core 2.1 (ubuntu.14.04-x64) - Given you have .NET Core SDK 2.1.300 installed + Given you have at least .NET Core SDK 2.1.300 installed And you have CloudFoundry service p-mysql installed When you run: cf create-service p-mysql 100mb myMySqlService And you wait until CloudFoundry service myMySqlService is created diff --git a/Connectors/src/AspDotNetCore/PostgreEFCore/PostgreEFCore.feature b/Connectors/src/AspDotNetCore/PostgreEFCore/PostgreEFCore.feature index 1c00fc8f2..1be46fa86 100644 --- a/Connectors/src/AspDotNetCore/PostgreEFCore/PostgreEFCore.feature +++ b/Connectors/src/AspDotNetCore/PostgreEFCore/PostgreEFCore.feature @@ -6,7 +6,7 @@ Feature: PostgreEFCore Connector @netcoreapp2.1 @win10-x64 Scenario: PostgreEFCore Connector for .Net Core 2.1 (win10-x64) - Given you have .NET Core SDK 2.1.300 installed + Given you have at least .NET Core SDK 2.1.300 installed And you have CloudFoundry service EDB-Shared-PostgreSQL installed When you run: cf create-service EDB-Shared-PostgreSQL "Basic PostgreSQL Plan" myPostgres And you wait until CloudFoundry service myPostgres is created @@ -21,7 +21,7 @@ Feature: PostgreEFCore Connector @netcoreapp2.1 @ubuntu.14.04-x64 Scenario: PostgreEFCore Connector for .Net Core 2.1 (ubuntu.14.04-x64) - Given you have .NET Core SDK 2.1.300 installed + Given you have at least .NET Core SDK 2.1.300 installed And you have CloudFoundry service EDB-Shared-PostgreSQL installed When you run: cf create-service EDB-Shared-PostgreSQL "Basic PostgreSQL Plan" myPostgres And you wait until CloudFoundry service myPostgres is created diff --git a/Connectors/src/AspDotNetCore/PostgreSql/PostgreSql.feature b/Connectors/src/AspDotNetCore/PostgreSql/PostgreSql.feature index 317be385d..13bc78e0f 100644 --- a/Connectors/src/AspDotNetCore/PostgreSql/PostgreSql.feature +++ b/Connectors/src/AspDotNetCore/PostgreSql/PostgreSql.feature @@ -6,7 +6,7 @@ Feature: PostgreSql Connector @netcoreapp2.1 @win10-x64 Scenario: PostgreSql Connector for .Net Core 2.1 (win10-x64) - Given you have .NET Core SDK 2.1.300 installed + Given you have at least .NET Core SDK 2.1.300 installed And you have CloudFoundry service EDB-Shared-PostgreSQL installed When you run: cf create-service EDB-Shared-PostgreSQL "Basic PostgreSQL Plan" myPostgres And you wait until CloudFoundry service myPostgres is created @@ -21,7 +21,7 @@ Feature: PostgreSql Connector @netcoreapp2.1 @ubuntu.14.04-x64 Scenario: PostgreSql Connector for .Net Core 2.1 (ubuntu.14.04-x64) - Given you have .NET Core SDK 2.1.300 installed + Given you have at least .NET Core SDK 2.1.300 installed And you have CloudFoundry service EDB-Shared-PostgreSQL installed When you run: cf create-service EDB-Shared-PostgreSQL "Basic PostgreSQL Plan" myPostgres And you wait until CloudFoundry service myPostgres is created diff --git a/Connectors/src/AspDotNetCore/RabbitMQ/RabbitMQ.feature b/Connectors/src/AspDotNetCore/RabbitMQ/RabbitMQ.feature index f0a60e57f..fd0d05633 100644 --- a/Connectors/src/AspDotNetCore/RabbitMQ/RabbitMQ.feature +++ b/Connectors/src/AspDotNetCore/RabbitMQ/RabbitMQ.feature @@ -6,7 +6,7 @@ Feature: RabbitMQ Connector @netcoreapp2.1 @win10-x64 Scenario: Rabbit Connector for .Net Core 2.1 (win10-x64) - Given you have .NET Core SDK 2.1.300 installed + Given you have at least .NET Core SDK 2.1.300 installed And you have CloudFoundry service p-rabbitmq installed When you run: cf create-service p-rabbitmq standard myRabbitMQService And you wait until CloudFoundry service myRabbitMQService is created @@ -21,7 +21,7 @@ Feature: RabbitMQ Connector @netcoreapp2.1 @ubuntu.14.04-x64 Scenario: Rabbit Connector for .Net Core 2.1 (ubuntu.14.04-x64) - Given you have .NET Core SDK 2.1.300 installed + Given you have at least .NET Core SDK 2.1.300 installed And you have CloudFoundry service p-rabbitmq installed When you run: cf create-service p-rabbitmq standard myRabbitMQService And you wait until CloudFoundry service myRabbitMQService is created @@ -36,7 +36,7 @@ Feature: RabbitMQ Connector @net461 @win10-x64 Scenario: Rabbit Connector for .Net Framework 4.6.1 (win10-x64) - Given you have .Net Core SDK 2.1.300 installed + Given you have at least .NET Core SDK 2.1.300 installed And you have CloudFoundry service p-rabbitmq installed When you run: cf create-service p-rabbitmq standard myRabbitMQService And you wait until CloudFoundry service myRabbitMQService is created diff --git a/pyenv.pkgs b/pyenv.pkgs index 5a89a83c9..c3fdd9db8 100644 --- a/pyenv.pkgs +++ b/pyenv.pkgs @@ -13,6 +13,7 @@ jedi==0.12.0 lxml==4.2.1 MechanicalSoup==0.10.0 mock==2.0.0 +nose==1.3.7 parse==1.8.2 parse-type==0.4.2 parso==0.2.0 @@ -24,11 +25,9 @@ psutil==5.4.5 ptyprocess==0.5.2 Pygments==2.2.0 requests==2.18.4 -setuptools==39.1.0 simplegeneric==0.8.1 six==1.11.0 sure==1.4.9 traitlets==4.3.2 urllib3==1.22 wcwidth==0.1.7 -wheel==0.31.0 diff --git a/pylib/version.py b/pylib/version.py new file mode 100644 index 000000000..3bd71e08e --- /dev/null +++ b/pylib/version.py @@ -0,0 +1,75 @@ +class Version: + + def __init__(self, version): + self.version = version + + def __repr__(self): + return self.version + + def __eq__(self, other): + return Comparator().compare(self.version, other.version) == 0 + + def __ne__(self, other): + return not self == other + + def __lt__(self, other): + return Comparator().compare(self.version, other.version) < 0 + + def __le__(self, other): + return Comparator().compare(self.version, other.version) <= 0 + + def __gt__(self, other): + return Comparator().compare(self.version, other.version) > 0 + + def __ge__(self, other): + return Comparator().compare(self.version, other.version) >= 0 + + +class Comparator: + + ''' + A comparator that semantically sorts versions. This comparator considers, + e.g., "10" to be greater than "9", in contrast to a lexical comparison. + + Return: + 0 if version a == version b + <0 if version a < version b + >0 if version a > version b + + Rules: + * version strings are broken into nodes delimited by '.' + * comparison is initially on the first node of each version + * if each node can both be converted to an integer, they are compared as such + * otherwise, the nodes are compared as strings + * if the comparison result of the first nodes is not 0, that result is returned + * else, the first nodes are equal + * if neither version has addition nodes, 0 is returned + * if each version has additional nodes, those nodes are compared as above + * else the version with the no more nodes remaining is considered the lesser version + ''' + def compare(self, a, b): + if a is None or b is None: + raise ValueError('version string cannot be None') + if not(isinstance(a, Version) or isinstance(a, str)) or not(isinstance(b, Version) or isinstance(b, str)): + raise TypeError('version must be an instance of a Version or str') + if not a or not b: + raise ValueError('version string cannot be empty') + def compareNodes(anodes, bnodes): + if len(anodes) == 0 and len(bnodes) == 0: + return 0 + if len(anodes) == 0: + return -1 + if len(bnodes) == 0: + return 1 + anode, bnode = anodes[0], bnodes[0] + try: + anode, bnode = int(anode), int(bnode) + except ValueError: + pass + if anode > bnode: + return 1 + elif anode < bnode: + return -1 + else: + return compareNodes(anodes[1:], bnodes[1:]) + return compareNodes(a.split('.'), b.split('.')) diff --git a/pylib/version_test.py b/pylib/version_test.py new file mode 100644 index 000000000..b9fcf8c3e --- /dev/null +++ b/pylib/version_test.py @@ -0,0 +1,80 @@ +import sure +import unittest +import version + +class VersionTest(unittest.TestCase): + + def testStringRepresentation(self): + myversion = version.Version('1.2.3') + repr(myversion).should.equal('1.2.3') + + def testEqual(self): + a = version.Version('1.2.3') + b = version.Version('1.2.3') + a.should.equal(b) + + def testNotEqual(self): + a = version.Version('1.2.3') + b = version.Version('1.2.4') + a.should_not.equal(b) + + def testGreaterThan(self): + a = version.Version('10') + b = version.Version('9') + (a > b).should.be.true + + def testGreaterThanOrEquals(self): + a = version.Version('10') + b = version.Version('9') + c = version.Version('10') + (a >= b).should.be.true + (a >= c).should.be.true + + def testLessThan(self): + a = version.Version('9') + b = version.Version('10') + (a < b).should.be.true + + def testLessThanOrEqual(self): + a = version.Version('9') + b = version.Version('10') + c = version.Version('9') + (a <= b).should.be.true + (a <= c).should.be.true + +class ComparatorTest(unittest.TestCase): + + def setUp(self): + self.comparator = version.Comparator() + + def testEqual(self): + (self.comparator.compare('1.2.3', '1.2.3') == 0).should.be.true + + def testNumericComparison(self): + (self.comparator.compare('10', '9') > 0).should.be.true + (self.comparator.compare('9', '10') < 0).should.be.true + + def testAlphaComparsion(self): + (self.comparator.compare('z', 'a') > 0).should.be.true + (self.comparator.compare('a', 'z') < 0).should.be.true + + def testAlphaNumberComparison(self): + (self.comparator.compare('a', '1') > 0).should.be.true + (self.comparator.compare('1', 'a') < 0).should.be.true + + def testDifferentNodeLengths(self): + (self.comparator.compare('1.2.3', '1.2') > 0).should.be.true + (self.comparator.compare('1.2', '1.2.3') < 0).should.be.true + + def testValueError(self): + self.assertRaises(ValueError, self.comparator.compare, '1.2.3', '') + self.assertRaises(ValueError, self.comparator.compare, '', '1.2.3') + self.assertRaises(ValueError, self.comparator.compare, '1.2.3', None) + self.assertRaises(ValueError, self.comparator.compare, None, '1.2.3') + + def testTypeError(self): + self.assertRaises(TypeError, self.comparator.compare, '1.2.3', 0) + self.assertRaises(TypeError, self.comparator.compare, 0, '1.2.3') + +if __name__ == '__main__': + unittest.main() diff --git a/steps/tool_steps.py b/steps/tool_steps.py index 635bafc80..2f84b07eb 100644 --- a/steps/tool_steps.py +++ b/steps/tool_steps.py @@ -1,12 +1,14 @@ import command import re +from version import Version -@given(u'you have .NET Core SDK {version} installed') +@given(u'you have at least .NET Core SDK {version} installed') def step_impl(context, version): + expected = Version(version) cmd = command.Command(context, "dotnet --version") cmd.run() - actual = cmd.stdout - actual.should.match(r'{}.*'.format(version)) + actual = Version(cmd.stdout) + (actual >= expected).should.be.true @given(u'you have Java {version} installed') def step_impl(context, version):