Skip to content

Commit

Permalink
Fix a bunch of unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
malaporte committed Nov 1, 2023
1 parent 0d7dac4 commit 79d316b
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 56 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const client = new Eureka({
},
serviceUrls: {
'us-east-1c': [
'http://ec2-fake-552-627-568-165.compute-1.amazonaws.com:7001/eureka/v2/apps/', 'http://ec2-fake-368-101-182-134.compute-1.amazonaws.com:7001/eureka/v2/apps/'
'http://ec2-fake-552-627-568-165.compute-1.amazonaws.com:7001/eureka/apps/', 'http://ec2-fake-368-101-182-134.compute-1.amazonaws.com:7001/eureka/apps/'
],
'us-east-1d': [...],
'us-east-1e': [...]
Expand All @@ -181,7 +181,7 @@ const client = new Eureka({
eureka: {
serviceUrls: {
default: [
'http://ec2-fake-552-627-568-165.compute-1.amazonaws.com:7001/eureka/v2/apps/', 'http://ec2-fake-368-101-182-134.compute-1.amazonaws.com:7001/eureka/v2/apps/'
'http://ec2-fake-552-627-568-165.compute-1.amazonaws.com:7001/eureka/apps/', 'http://ec2-fake-368-101-182-134.compute-1.amazonaws.com:7001/eureka/apps/'
]
}
},
Expand Down Expand Up @@ -283,7 +283,7 @@ If you are planning on connecting to a eureka service in AWS you will need to ad

### 404 Not Found Errors from Eureka Server

This probably means that the Eureka REST service is located on a different path in your environment. The default is `http://<EUREKA_HOST>/eureka/v2/apps`, but depending on your setup you may need to set `eureka.servicePath` in your configuration to another path. The REST service could be hung under `/eureka/apps/` or possibly `/apps/`.
This probably means that the Eureka REST service is located on a different path in your environment. The default is `http://<EUREKA_HOST>/eureka/apps`, but depending on your setup you may need to set `eureka.servicePath` in your configuration to another path. The REST service could be hung under `/eureka/apps/` or possibly `/apps/`.

### Usage with Spring Cloud

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coveord/eureka-js-client",
"version": "1.0.1",
"version": "1.0.2",
"description": "A JavaScript implementation the Netflix OSS service registry, Eureka.",
"main": "lib/index.js",
"scripts": {
Expand All @@ -14,7 +14,7 @@
"url": "git+https://github.com/coveord/eureka-js-client.git"
},
"publishConfig": {
"registry":"https://npm.pkg.github.com/"
"registry": "https://npm.pkg.github.com/"
},
"keywords": [
"eureka",
Expand Down
74 changes: 37 additions & 37 deletions test/ConfigClusterResolver.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Config Cluster Resolver', () => {

it('should return base Eureka URL using configured host', () => {
resolver.resolveEurekaUrl((err, eurekaUrl) => {
expect(eurekaUrl).to.equal('http://eureka.mydomain.com:9999/eureka/v2/apps/');
expect(eurekaUrl).to.equal('http://eureka.mydomain.com:9999/eureka/apps/');
});
});
});
Expand All @@ -44,9 +44,9 @@ describe('Config Cluster Resolver', () => {
eureka: {
serviceUrls: {
default: [
'http://eureka1.mydomain.com:9999/eureka/v2/apps/',
'http://eureka2.mydomain.com:9999/eureka/v2/apps/',
'http://eureka3.mydomain.com:9999/eureka/v2/apps/',
'http://eureka1.mydomain.com:9999/eureka/apps/',
'http://eureka2.mydomain.com:9999/eureka/apps/',
'http://eureka3.mydomain.com:9999/eureka/apps/',
],
},
},
Expand All @@ -55,16 +55,16 @@ describe('Config Cluster Resolver', () => {

it('should return first Eureka URL from configured serviceUrls', () => {
resolver.resolveEurekaUrl((err, eurekaUrl) => {
expect(eurekaUrl).to.equal('http://eureka1.mydomain.com:9999/eureka/v2/apps/');
expect(eurekaUrl).to.equal('http://eureka1.mydomain.com:9999/eureka/apps/');
});
});

it('should return next Eureka URL from configured serviceUrls', () => {
resolver.resolveEurekaUrl((err, eurekaUrl) => {
expect(eurekaUrl).to.equal('http://eureka2.mydomain.com:9999/eureka/v2/apps/');
expect(eurekaUrl).to.equal('http://eureka2.mydomain.com:9999/eureka/apps/');
// next attempt should still be the next server
resolver.resolveEurekaUrl((errTwo, eurekaUrlTwo) => {
expect(eurekaUrlTwo).to.equal('http://eureka2.mydomain.com:9999/eureka/v2/apps/');
expect(eurekaUrlTwo).to.equal('http://eureka2.mydomain.com:9999/eureka/apps/');
});
}, 1);
});
Expand All @@ -80,19 +80,19 @@ describe('Config Cluster Resolver', () => {
},
serviceUrls: {
'1a': [
'http://1a-eureka1.mydomain.com:9999/eureka/v2/apps/',
'http://1a-eureka2.mydomain.com:9999/eureka/v2/apps/',
'http://1a-eureka3.mydomain.com:9999/eureka/v2/apps/',
'http://1a-eureka1.mydomain.com:9999/eureka/apps/',
'http://1a-eureka2.mydomain.com:9999/eureka/apps/',
'http://1a-eureka3.mydomain.com:9999/eureka/apps/',
],
'1b': [
'http://1b-eureka1.mydomain.com:9999/eureka/v2/apps/',
'http://1b-eureka2.mydomain.com:9999/eureka/v2/apps/',
'http://1b-eureka3.mydomain.com:9999/eureka/v2/apps/',
'http://1b-eureka1.mydomain.com:9999/eureka/apps/',
'http://1b-eureka2.mydomain.com:9999/eureka/apps/',
'http://1b-eureka3.mydomain.com:9999/eureka/apps/',
],
'1c': [
'http://1b-eureka1.mydomain.com:9999/eureka/v2/apps/',
'http://1b-eureka2.mydomain.com:9999/eureka/v2/apps/',
'http://1b-eureka3.mydomain.com:9999/eureka/v2/apps/',
'http://1b-eureka1.mydomain.com:9999/eureka/apps/',
'http://1b-eureka2.mydomain.com:9999/eureka/apps/',
'http://1b-eureka3.mydomain.com:9999/eureka/apps/',
],
},
},
Expand All @@ -101,7 +101,7 @@ describe('Config Cluster Resolver', () => {

it('should return first Eureka URL from configured serviceUrls', () => {
resolver.resolveEurekaUrl((err, eurekaUrl) => {
expect(eurekaUrl).to.equal('http://1a-eureka1.mydomain.com:9999/eureka/v2/apps/');
expect(eurekaUrl).to.equal('http://1a-eureka1.mydomain.com:9999/eureka/apps/');
});
});
});
Expand All @@ -117,19 +117,19 @@ describe('Config Cluster Resolver', () => {
},
serviceUrls: {
'1a': [
'http://1a-eureka1.mydomain.com:9999/eureka/v2/apps/',
'http://1a-eureka2.mydomain.com:9999/eureka/v2/apps/',
'http://1a-eureka3.mydomain.com:9999/eureka/v2/apps/',
'http://1a-eureka1.mydomain.com:9999/eureka/apps/',
'http://1a-eureka2.mydomain.com:9999/eureka/apps/',
'http://1a-eureka3.mydomain.com:9999/eureka/apps/',
],
'1b': [
'http://1b-eureka1.mydomain.com:9999/eureka/v2/apps/',
'http://1b-eureka2.mydomain.com:9999/eureka/v2/apps/',
'http://1b-eureka3.mydomain.com:9999/eureka/v2/apps/',
'http://1b-eureka1.mydomain.com:9999/eureka/apps/',
'http://1b-eureka2.mydomain.com:9999/eureka/apps/',
'http://1b-eureka3.mydomain.com:9999/eureka/apps/',
],
'1c': [
'http://1b-eureka1.mydomain.com:9999/eureka/v2/apps/',
'http://1b-eureka2.mydomain.com:9999/eureka/v2/apps/',
'http://1b-eureka3.mydomain.com:9999/eureka/v2/apps/',
'http://1b-eureka1.mydomain.com:9999/eureka/apps/',
'http://1b-eureka2.mydomain.com:9999/eureka/apps/',
'http://1b-eureka3.mydomain.com:9999/eureka/apps/',
],
},
},
Expand All @@ -138,7 +138,7 @@ describe('Config Cluster Resolver', () => {

it('should return first Eureka URL from configured serviceUrls', () => {
resolver.resolveEurekaUrl((err, eurekaUrl) => {
expect(eurekaUrl).to.equal('http://1b-eureka1.mydomain.com:9999/eureka/v2/apps/');
expect(eurekaUrl).to.equal('http://1b-eureka1.mydomain.com:9999/eureka/apps/');
});
});
});
Expand All @@ -156,19 +156,19 @@ describe('Config Cluster Resolver', () => {
},
serviceUrls: {
'1a': [
'http://1a-eureka1.mydomain.com:9999/eureka/v2/apps/',
'http://1a-eureka2.mydomain.com:9999/eureka/v2/apps/',
'http://1a-eureka3.mydomain.com:9999/eureka/v2/apps/',
'http://1a-eureka1.mydomain.com:9999/eureka/apps/',
'http://1a-eureka2.mydomain.com:9999/eureka/apps/',
'http://1a-eureka3.mydomain.com:9999/eureka/apps/',
],
'1b': [
'http://1b-eureka1.mydomain.com:9999/eureka/v2/apps/',
'http://1b-eureka2.mydomain.com:9999/eureka/v2/apps/',
'http://1b-eureka3.mydomain.com:9999/eureka/v2/apps/',
'http://1b-eureka1.mydomain.com:9999/eureka/apps/',
'http://1b-eureka2.mydomain.com:9999/eureka/apps/',
'http://1b-eureka3.mydomain.com:9999/eureka/apps/',
],
'1c': [
'http://1b-eureka1.mydomain.com:9999/eureka/v2/apps/',
'http://1b-eureka2.mydomain.com:9999/eureka/v2/apps/',
'http://1b-eureka3.mydomain.com:9999/eureka/v2/apps/',
'http://1b-eureka1.mydomain.com:9999/eureka/apps/',
'http://1b-eureka2.mydomain.com:9999/eureka/apps/',
'http://1b-eureka3.mydomain.com:9999/eureka/apps/',
],
},
},
Expand All @@ -179,7 +179,7 @@ describe('Config Cluster Resolver', () => {

it('should return first Eureka URL from configured serviceUrls', () => {
resolver.resolveEurekaUrl((err, eurekaUrl) => {
expect(eurekaUrl).to.equal('http://1a-eureka1.mydomain.com:9999/eureka/v2/apps/');
expect(eurekaUrl).to.equal('http://1a-eureka1.mydomain.com:9999/eureka/apps/');
});
});
});
Expand Down
8 changes: 4 additions & 4 deletions test/DnsClusterResolver.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function makeConfig(overrides = {}) {
},
eureka: {
host: 'eureka.mydomain.com',
servicePath: '/eureka/v2/apps/',
servicePath: '/eureka/apps/',
port: 9999,
maxRetries: 0,
ec2Region: 'my-region',
Expand Down Expand Up @@ -90,15 +90,15 @@ describe('DNS Cluster Resolver', () => {
const resolveHostsStub = sinon.stub(dnsResolver, 'resolveClusterHosts');
resolveHostsStub.yields(null, ['a.mydomain.com', 'b.mydomain.com', 'c.mydomain.com']);
dnsResolver.resolveEurekaUrl((err, eurekaUrl) => {
expect(eurekaUrl).to.equal('http://a.mydomain.com:9999/eureka/v2/apps/');
expect(eurekaUrl).to.equal('http://a.mydomain.com:9999/eureka/apps/');
});
});

it('should return base Eureka URL using next cluster host on retry', () => {
const resolveHostsStub = sinon.stub(dnsResolver, 'resolveClusterHosts');
resolveHostsStub.yields(null, ['a.mydomain.com', 'b.mydomain.com', 'c.mydomain.com']);
dnsResolver.resolveEurekaUrl((err, eurekaUrl) => {
expect(eurekaUrl).to.equal('http://b.mydomain.com:9999/eureka/v2/apps/');
expect(eurekaUrl).to.equal('http://b.mydomain.com:9999/eureka/apps/');
expect(dnsResolver.serverList).to.eql(['b.mydomain.com', 'c.mydomain.com',
'a.mydomain.com']);
}, 1);
Expand Down Expand Up @@ -244,7 +244,7 @@ describe('DNS Cluster Resolver', () => {
eureka: {
preferSameZone: true,
host: 'eureka.mydomain.com',
servicePath: '/eureka/v2/apps/',
servicePath: '/eureka/apps/',
port: 9999,
maxRetries: 0,
ec2Region: 'my-region',
Expand Down
14 changes: 7 additions & 7 deletions test/EurekaClient.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ describe('Eureka client', () => {
},
},
json: true,
baseUrl: 'http://127.0.0.1:9999/eureka/v2/apps/',
baseUrl: 'http://127.0.0.1:9999/eureka/apps/',
uri: 'app',
});

Expand Down Expand Up @@ -442,7 +442,7 @@ describe('Eureka client', () => {
client.deregister(deregisterCb);

expect(request.delete).to.have.been.calledWithMatch({
baseUrl: 'http://127.0.0.1:9999/eureka/v2/apps/',
baseUrl: 'http://127.0.0.1:9999/eureka/apps/',
uri: 'app/myhost',
});

Expand Down Expand Up @@ -485,7 +485,7 @@ describe('Eureka client', () => {
client.renew();

expect(request.put).to.have.been.calledWithMatch({
baseUrl: 'http://127.0.0.1:9999/eureka/v2/apps/',
baseUrl: 'http://127.0.0.1:9999/eureka/apps/',
uri: 'app/myhost',
});
});
Expand All @@ -505,7 +505,7 @@ describe('Eureka client', () => {
client.renew();

expect(request.put).to.have.been.calledWithMatch({
baseUrl: 'http://127.0.0.1:9999/eureka/v2/apps/',
baseUrl: 'http://127.0.0.1:9999/eureka/apps/',
uri: 'app/myhost',
});

Expand All @@ -521,7 +521,7 @@ describe('Eureka client', () => {
},
},
json: true,
baseUrl: 'http://127.0.0.1:9999/eureka/v2/apps/',
baseUrl: 'http://127.0.0.1:9999/eureka/apps/',
uri: 'app',
});
});
Expand Down Expand Up @@ -711,7 +711,7 @@ describe('Eureka client', () => {
client.fetchRegistry(registryCb);

expect(request.get).to.have.been.calledWithMatch({
baseUrl: 'http://127.0.0.1:9999/eureka/v2/apps/',
baseUrl: 'http://127.0.0.1:9999/eureka/apps/',
uri: '',
headers: { Accept: 'application/json' },
});
Expand All @@ -727,7 +727,7 @@ describe('Eureka client', () => {
client.fetchRegistry(registryCb);

expect(request.get).to.have.been.calledWithMatch({
baseUrl: 'http://127.0.0.1:9999/eureka/v2/apps/',
baseUrl: 'http://127.0.0.1:9999/eureka/apps/',
uri: 'delta',
headers: { Accept: 'application/json' },
});
Expand Down
2 changes: 1 addition & 1 deletion test/eureka-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ eureka:
heartbeatInterval: 999
registryFetchInterval: 999
fetchRegistry: false
servicePath: '/eureka/v2/apps/'
servicePath: '/eureka/apps/'
ssl: false
useDns: false
fetchMetadata: false
Expand Down
2 changes: 1 addition & 1 deletion test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Integration Test', () => {
registryFetchInterval: 5000,
fetchRegistry: true,
waitForRegistry: true,
servicePath: '/eureka/v2/apps/',
servicePath: '/eureka/apps/',
ssl: false,
useDns: false,
fetchMetadata: true,
Expand Down

0 comments on commit 79d316b

Please sign in to comment.