diff --git a/source/Stargate-Consul-Tests/ConsulServiceDiscoveryPluginAPITest.class.st b/source/Stargate-Consul-Tests/ConsulServiceDiscoveryPluginAPITest.class.st index b03a717..66227c2 100644 --- a/source/Stargate-Consul-Tests/ConsulServiceDiscoveryPluginAPITest.class.st +++ b/source/Stargate-Consul-Tests/ConsulServiceDiscoveryPluginAPITest.class.st @@ -2,7 +2,8 @@ Class { #name : #ConsulServiceDiscoveryPluginAPITest, #superclass : #OperationalPluginAPITest, #instVars : [ - 'consulAgent' + 'consulAgent', + 'consulAgentPort' ], #category : #'Stargate-Consul-Tests' } @@ -10,7 +11,13 @@ Class { { #category : #private } ConsulServiceDiscoveryPluginAPITest >> consulAgentLocation [ - ^ 'http://localhost:9998' asUrl + ^ 'http://localhost' asUrl port: consulAgentPort +] + +{ #category : #logging } +ConsulServiceDiscoveryPluginAPITest >> isLogging [ + + ^ true ] { #category : #private } @@ -32,6 +39,19 @@ ConsulServiceDiscoveryPluginAPITest >> requiredPermissions [ ^ #() ] +{ #category : #private } +ConsulServiceDiscoveryPluginAPITest >> runCase [ + + | logs | + + logs := + String streamContents: [:stream | + CurrentLogger + value: (LeveledLogger outputTo: stream errorsTo: stream) + during: [super runCase]]. + self logFailure: logs +] + { #category : #private } ConsulServiceDiscoveryPluginAPITest >> serviceDefinitions [ @@ -41,9 +61,10 @@ ConsulServiceDiscoveryPluginAPITest >> serviceDefinitions [ { #category : #tests } ConsulServiceDiscoveryPluginAPITest >> setUp [ + consulAgentPort := self freeListeningTCPPort. consulAgent := FakeConsulAgentAPI configuredBy: - {( #port -> 9998 ). + {( #port -> consulAgentPort ). ( #serverUrl -> self consulAgentLocation ). ( #debugMode -> true )} on: self. diff --git a/source/Stargate-Consul-Tests/ConsulServiceDiscoveryPluginInteractionTest.class.st b/source/Stargate-Consul-Tests/ConsulServiceDiscoveryPluginInteractionTest.class.st index eda7be1..bd61bf3 100644 --- a/source/Stargate-Consul-Tests/ConsulServiceDiscoveryPluginInteractionTest.class.st +++ b/source/Stargate-Consul-Tests/ConsulServiceDiscoveryPluginInteractionTest.class.st @@ -2,7 +2,8 @@ Class { #name : #ConsulServiceDiscoveryPluginInteractionTest, #superclass : #TestCase, #instVars : [ - 'consulAgent' + 'consulAgent', + 'port' ], #category : #'Stargate-Consul-Tests' } @@ -16,24 +17,19 @@ ConsulServiceDiscoveryPluginInteractionTest >> apiServer [ { #category : #accessing } ConsulServiceDiscoveryPluginInteractionTest >> baseUrl [ - ^ 'http://localhost' asUrl port: self port -] - -{ #category : #accessing } -ConsulServiceDiscoveryPluginInteractionTest >> port [ - - ^ 9998 + ^ 'http://localhost' asUrl port: port ] { #category : #running } ConsulServiceDiscoveryPluginInteractionTest >> setUp [ super setUp. + port := self freeListeningTCPPort. consulAgent := FakeConsulAgentAPI configuredBy: - {( #port -> self port ). - ( #serverUrl -> self baseUrl ). - ( #debugMode -> true )} + { #port -> port. + #serverUrl -> self baseUrl. + #debugMode -> true } on: self. consulAgent start ] diff --git a/source/Stargate-Consul/ConsulServiceDefinitionBuilder.class.st b/source/Stargate-Consul/ConsulServiceDefinitionBuilder.class.st index 82a05b9..f34b8dd 100644 --- a/source/Stargate-Consul/ConsulServiceDefinitionBuilder.class.st +++ b/source/Stargate-Consul/ConsulServiceDefinitionBuilder.class.st @@ -45,7 +45,7 @@ ConsulServiceDefinitionBuilder >> addCheck: aConsulAgentCheck [ | checks | - checks := serviceDefinition at: 'Checks' ifAbsentPut: [ OrderedCollection new ]. + checks := serviceDefinition at: #Checks ifAbsentPut: [ OrderedCollection new ]. checks add: aConsulAgentCheck ] @@ -55,14 +55,14 @@ ConsulServiceDefinitionBuilder >> addTag: aString [ | tags | AssertionChecker enforce: [ aString notEmpty ] because: 'A tag cannot be empty'. - tags := serviceDefinition at: 'Tags' ifAbsentPut: [ OrderedCollection new ]. + tags := serviceDefinition at: #Tags ifAbsentPut: [ OrderedCollection new ]. tags add: aString ] { #category : #configuring } -ConsulServiceDefinitionBuilder >> address: aString [ - - serviceDefinition at: 'Address' put: aString +ConsulServiceDefinitionBuilder >> address: aString [ + + serviceDefinition at: #Address put: aString ] { #category : #private } @@ -77,21 +77,21 @@ ConsulServiceDefinitionBuilder >> assertIsValidPort: aPortNumber [ ConsulServiceDefinitionBuilder >> buildNamed: aServiceName [ AssertionChecker enforce: [ aServiceName notEmpty ] because: 'A service name cannot be empty'. - serviceDefinition at: 'Name' put: aServiceName. + serviceDefinition at: #Name put: aServiceName. ^ NeoJSONObject newFrom: serviceDefinition ] { #category : #configuring } ConsulServiceDefinitionBuilder >> enableTagOverride [ - serviceDefinition at: 'EnableTagOverride' put: true + serviceDefinition at: #EnableTagOverride put: true ] { #category : #configuring } ConsulServiceDefinitionBuilder >> identifiedBy: aString [ AssertionChecker enforce: [ aString notEmpty ] because: 'An ID cannot be empty'. - serviceDefinition at: 'ID' put: aString + serviceDefinition at: #ID put: aString ] { #category : #initialization } @@ -104,14 +104,14 @@ ConsulServiceDefinitionBuilder >> initialize [ { #category : #configuring } ConsulServiceDefinitionBuilder >> metadataAt: aKey put: aValue [ - serviceDefinition at: 'Meta' at: aKey put: aValue + serviceDefinition at: #Meta at: aKey put: aValue ] { #category : #configuring } ConsulServiceDefinitionBuilder >> port: anInteger [ self assertIsValidPort: anInteger. - serviceDefinition at: 'Port' put: anInteger + serviceDefinition at: #Port put: anInteger ] { #category : #configuring } @@ -126,7 +126,7 @@ ConsulServiceDefinitionBuilder >> taggedAddressesAt: aTag on: aKey put: aValue [ | taggedAddresses | taggedAddresses := serviceDefinition - at: 'TaggedAddresses' + at: #TaggedAddresses ifAbsentPut: [ serviceDefinition species new ]. taggedAddresses at: aTag at: aKey put: aValue ] diff --git a/source/Stargate-Consul/ConsulServiceDiscoveryPlugin.class.st b/source/Stargate-Consul/ConsulServiceDiscoveryPlugin.class.st index 203aec3..8562702 100644 --- a/source/Stargate-Consul/ConsulServiceDiscoveryPlugin.class.st +++ b/source/Stargate-Consul/ConsulServiceDiscoveryPlugin.class.st @@ -72,7 +72,7 @@ ConsulServiceDiscoveryPlugin >> deregisterFromConsul: serviceDefinition [ deregisterRequest := HttpRequest put: ( self deregistrationUrlFor: serviceDefinition ) - configuredUsing: [ :request | request body json: {} asDictionary ]. + configuredUsing: [ :request | request body json: Dictionary new ]. deregisterRequest applyOn: self newHttpClient ]