Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple configs from cluster #53

Merged
merged 28 commits into from
Jul 1, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e6067d2
fix: each cluster has its own compose cache
varl May 23, 2019
cdec88f
fix: use multipe cluster caches
varl May 23, 2019
de99312
fix: store a cache obj
varl May 23, 2019
ddbe035
fix: use the dirname of the cache loc
varl May 23, 2019
4544cb7
fix: log cache obj
varl May 23, 2019
0f9cc6a
refactor: extra constant for cache config
varl May 27, 2019
baef8a8
fix: shorten the composeProject name after isolation
varl May 27, 2019
a0e0699
fix: simplify command cache handling
varl May 30, 2019
0387b57
test: fix tests
varl May 30, 2019
a22dd5b
docs: fix desc for changed arg
varl May 30, 2019
946c1ea
chore: new yarn.lock file after master was merged in
varl Jun 5, 2019
51d3441
feat: allow cluster configuration to be stored in ~/.config/d2/config.js
varl Jun 6, 2019
e736081
docs: update readme for cluster
varl Jun 6, 2019
a55bbb4
docs: update readme
varl Jun 6, 2019
4935876
docs: fix broken syntax
varl Jun 6, 2019
2d6209c
refactor: break up path and clean up imports
varl Jun 16, 2019
43cbcef
refactor: clean up imports
varl Jun 16, 2019
18c1f6c
docs: add note about config order
varl Jun 16, 2019
6712b6e
chore: add repo config files
varl Jun 16, 2019
4f7d7d2
refactor: address pr comments
varl Jun 18, 2019
88e7702
refactor: prefix docker-compose projects
varl Jun 18, 2019
daa147b
Merge branch 'master' into decouple-configs-from-cluster
varl Jun 21, 2019
eaccd9c
refactor: rearrange noop change
varl Jun 26, 2019
b4d4362
Merge branch 'master' into decouple-configs-from-cluster
varl Jun 27, 2019
06be935
Merge branch 'master' into decouple-configs-from-cluster
varl Jun 27, 2019
53fca03
Merge branch 'master' into decouple-configs-from-cluster
varl Jun 28, 2019
82a19d0
Merge branch 'master' into decouple-configs-from-cluster
varl Jun 29, 2019
2a4ac2b
chore: correct log variable
amcgee Jul 1, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: fix tests
  • Loading branch information
varl committed Jun 16, 2019
commit 0387b57058430f0b99cb7a02dcd4379d0cb90a8f
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"devDependencies": {
"@dhis2/cli-style": "3.3.4",
"husky": "^2.4.1",
"tape": "^4.10.2"
"tape": "^4.10.2",
"tape-await": "^0.1.2"
},
"husky": {
"hooks": {
Expand Down
66 changes: 37 additions & 29 deletions packages/cluster/tests/setup-environment.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
const test = require('tape')
const test = require('tape-await')

const { makeEnvironment, resolveConfiguration } = require('../src/common.js')

const defaults = require('../src/defaults.js')

test('build runtime environment based on defaults', function(t) {
const cache = obj => ({
read: () => JSON.stringify(obj),
write: () => {},
})

test('build runtime environment based on defaults', async function(t) {
t.plan(1)

const argv = {
name: 'dev',
getCache: () => cache(null),
}
const cache = {}
const config = {}

const actual = makeEnvironment(resolveConfiguration(argv, cache, config))
const cfg = await resolveConfiguration(argv)
const actual = makeEnvironment(cfg)

const expected = {
DHIS2_CORE_NAME: 'dev',
Expand All @@ -27,7 +32,7 @@ test('build runtime environment based on defaults', function(t) {
t.deepEqual(actual, expected, 'default environment')
})

test('build runtime environment based on args', function(t) {
test('build runtime environment based on args', async function(t) {
t.plan(1)

const argv = {
Expand All @@ -38,11 +43,11 @@ test('build runtime environment based on args', function(t) {
channel: 'canary',
variant: 'jetty-slackware',
port: 8233,
getCache: () => cache(null),
}
const cache = {}
const config = {}

const actual = makeEnvironment(resolveConfiguration(argv, cache, config))
const cfg = await resolveConfiguration(argv)
const actual = makeEnvironment(cfg)

const expected = {
DHIS2_CORE_NAME: 'dev',
Expand All @@ -56,24 +61,25 @@ test('build runtime environment based on args', function(t) {
t.deepEqual(actual, expected, 'args environment')
})

test('build runtime environment based on mixed args and config', function(t) {
test('build runtime environment based on mixed args and config', async function(t) {
t.plan(1)

const argv = {
name: 'mydev',
customContext: true,
}

const cache = {}

const config = {
dhis2Version: 'master',
port: 8233,
channel: 'dev',
dbVersion: 'dev',
}

const actual = makeEnvironment(resolveConfiguration(argv, cache, config))
const argv = {
name: 'mydev',
customContext: true,
cluster: config,
getCache: () => cache(null),
}

const cfg = await resolveConfiguration(argv)
const actual = makeEnvironment(cfg)

const expected = {
DHIS2_CORE_NAME: 'mydev',
Expand All @@ -87,24 +93,26 @@ test('build runtime environment based on mixed args and config', function(t) {
t.deepEqual(actual, expected, 'args and config environment')
})

test('build runtime environment based on mixed args, cache, config and defaults', function(t) {
test('build runtime environment based on mixed args, cache, config and defaults', async function(t) {
t.plan(1)

const argv = {
name: 'mydev',
}

const cache = {
customContext: true,
image: 'dhis2/core-canary:master-20190523-alpine',
}

const config = {
port: 8233,
dhis2Version: 'dev',
}

const actual = makeEnvironment(resolveConfiguration(argv, cache, config))
const argv = {
name: 'mydev',
cluster: config,
getCache: () =>
cache({
customContext: true,
image: 'dhis2/core-canary:master-20190523-alpine',
}),
}

const cfg = await resolveConfiguration(argv)
const actual = makeEnvironment(cfg)

const expected = {
DHIS2_CORE_NAME: 'mydev',
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4735,6 +4735,11 @@ table@^5.2.3:
slice-ansi "^2.1.0"
string-width "^3.0.0"

tape-await@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/tape-await/-/tape-await-0.1.2.tgz#41f99110a2bc4728732d8bc058278b2fbf3c0bec"
integrity sha512-Gt1bXilp9uRTVj+DecLDs37tP1XwGXfFzWVqQEfW7foO9TNacy+aN5TdT0Kv6LI5t/9l3iOE4nX2hr2SQ4+OSg==

tape@^4.10.2:
version "4.10.2"
resolved "https://registry.yarnpkg.com/tape/-/tape-4.10.2.tgz#129fcf62f86df92687036a52cce7b8ddcaffd7a6"
Expand Down