Skip to content

Commit

Permalink
Merge branch 'master' into dima/local-integration-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nLight authored Feb 27, 2019
2 parents 5efc5ee + 71657ac commit 57be6b0
Show file tree
Hide file tree
Showing 39 changed files with 1,387 additions and 53 deletions.
10 changes: 10 additions & 0 deletions locale/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"Authentication Method": "",
"Auto Assigned": "",
"Available Agents": "",
"Available Version": "",
"BACKEND": "",
"Back": "",
"Backends": "",
Expand Down Expand Up @@ -148,6 +149,7 @@
"Certified packages are verified by Mesosphere for interoperability with DC/OS.": "",
"Change": "",
"Changing the settings may lead to errors. Please check with your identity provider before making changes. All fields are required.": "",
"Checking for new version": "",
"Choose BRIDGE, HOST, or USER networking. Refer to the <0>ports documentation</0> for more information.": "",
"Choose a group": "",
"Choose a user": "",
Expand Down Expand Up @@ -577,6 +579,7 @@
"Networking": "",
"Networks": "",
"Never": "",
"New": "",
"New Group": "",
"New Job": "",
"New Secret": "",
Expand Down Expand Up @@ -679,6 +682,7 @@
"Recent Resource Offers{offerCount}": "",
"Recommended": "",
"Recovering": "",
"Refresh page to load": "",
"Region": "",
"Regions": "",
"Registered": "",
Expand Down Expand Up @@ -712,6 +716,8 @@
"Role": "",
"Rollback": "",
"Rollback & Delete": "",
"Rollback Failed!": "",
"Rolling back...": "",
"Rotates the Mesos master and agent log files to prevent filling the disk.": "",
"Run": "",
"Run History": "",
Expand Down Expand Up @@ -807,6 +813,7 @@
"Specify where your app will run.": "",
"Staged at": "",
"Staging": "",
"Start Update": "",
"Started": "",
"Started After Last Scaling": "",
"Started At": "",
Expand Down Expand Up @@ -939,8 +946,11 @@
"Unreachable": "",
"Unscheduled": "",
"Unspecified": "",
"Update Complete": "",
"Update Failed!": "",
"Update the number of instances in your service's target configuration using an `options.json` file.": "",
"Updated": "",
"Updating...": "",
"Upgrade": "",
"Upgrade Max Overcapacity": "",
"Upgrade Min Health Capacity": "",
Expand Down
10 changes: 10 additions & 0 deletions locale/zh/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"Authentication Method": "身份验证方法",
"Auto Assigned": "已自动分配",
"Available Agents": "可用代理",
"Available Version": "",
"BACKEND": "后端",
"Back": "",
"Backends": "后端",
Expand Down Expand Up @@ -148,6 +149,7 @@
"Certified packages are verified by Mesosphere for interoperability with DC/OS.": "已认证的包经 Mesosphere 验证,可与 DC/OS 互操作。",
"Change": "更改",
"Changing the settings may lead to errors. Please check with your identity provider before making changes. All fields are required.": "更改设置可能会导致错误。请在进行更改前与您的身份提供商核实。所有字段均为必填字段。",
"Checking for new version": "",
"Choose BRIDGE, HOST, or USER networking. Refer to the <0>ports documentation</0> for more information.": "选择 BRIDGE、HOST 或 USER 网络。请参阅 <0>端口文档,</0> 以获取更多信息。",
"Choose a group": "选择组",
"Choose a user": "选择用户",
Expand Down Expand Up @@ -577,6 +579,7 @@
"Networking": "网络",
"Networks": "网络",
"Never": "从不",
"New": "",
"New Group": "新组",
"New Job": "新作业",
"New Secret": "新密钥",
Expand Down Expand Up @@ -679,6 +682,7 @@
"Recent Resource Offers{offerCount}": "最近的 Resource Offer{offerCount}",
"Recommended": "已推荐",
"Recovering": "正在恢复",
"Refresh page to load": "",
"Region": "区域",
"Regions": "区域",
"Registered": "已注册",
Expand Down Expand Up @@ -712,6 +716,8 @@
"Role": "角色",
"Rollback": "回滚",
"Rollback & Delete": "回滚和删除",
"Rollback Failed!": "",
"Rolling back...": "",
"Rotates the Mesos master and agent log files to prevent filling the disk.": "旋转 Mesos 管理节点和代理日志文件,以防止填充磁盘。",
"Run": "运行",
"Run History": "运行历史",
Expand Down Expand Up @@ -807,6 +813,7 @@
"Specify where your app will run.": "指定应用程序运行的位置。",
"Staged at": "已缓存于",
"Staging": "正在缓存",
"Start Update": "",
"Started": "已开始",
"Started After Last Scaling": "上次缩放后已开始",
"Started At": "已开始于",
Expand Down Expand Up @@ -939,8 +946,11 @@
"Unreachable": "不可达",
"Unscheduled": "未计划",
"Unspecified": "未指定",
"Update Complete": "",
"Update Failed!": "",
"Update the number of instances in your service's target configuration using an `options.json` file.": "使用 `options.json` 文件来更新服务目标配置中的实例数。",
"Updated": "已更新",
"Updating...": "",
"Upgrade": "已升级",
"Upgrade Max Overcapacity": "升级最大超容量",
"Upgrade Min Health Capacity": "升级最小健康容量",
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"@types/react": "16.8.2",
"@types/react-router": "2.0.54",
"@types/recompose": "0.26.1",
"@types/semver": "5.5.0",
"autoprefixer": "6.3.6",
"babel-cli": "6.24.1",
"babel-core": "6.24.1",
Expand Down Expand Up @@ -229,4 +230,4 @@
"jest-webpack-alias": {
"configFile": "./webpack/webpack.dev.js"
}
}
}
4 changes: 3 additions & 1 deletion plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import banner from "./banner/index";
import tracking from "./tracking/index";
import oauth from "./oauth/index";
import intercom from "./intercom/index";
import uiUpdate from "./ui-update/index";

module.exports = {
banner,
tracking,
oauth,
intercom
intercom,
"ui-update": uiUpdate
};
10 changes: 10 additions & 0 deletions plugins/ui-update/SDK.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
let SDK;

module.exports = {
getSDK() {
return SDK;
},
setSDK(pluginSDK) {
SDK = pluginSDK;
}
};
139 changes: 139 additions & 0 deletions plugins/ui-update/__tests__/queries-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
const mockDataLayer = jest.fn();
jest.mock("@dcos/data-service", () => ({
graphqlObservable: mockDataLayer
}));

import { marbles } from "rxjs-marbles/jest";
import {
queryCosmosForUIVersions,
queryUIServiceForMetadata
} from "#PLUGINS/ui-update/queries";
import { take } from "rxjs/operators";
import { of } from "rxjs";
import { DEFAULT_UI_METADATA } from "#SRC/js/data/ui-update/UIMetadata";

describe("queries", () => {
beforeEach(() => {
jest.clearAllMocks();
});
describe("#queryCosmosForUIVersions", () => {
it(
"returns package result from query",
marbles(m => {
const queryResp$ = m.cold("--j|", {
j: {
data: {
package: {
name: "dcos-ui",
versions: [
{
version: "2.0.0",
revision: "1"
}
]
}
}
}
});
mockDataLayer.mockReturnValueOnce(queryResp$);

const query$ = queryCosmosForUIVersions();
const result$ = query$.pipe(take(1));
m.expect(result$).toBeObservable(
m.cold("--(j|)", {
j: {
name: "dcos-ui",
versions: [
{
version: "2.0.0",
revision: "1"
}
]
}
})
);
})
);

it("makes a single query to data-layer", () => {
mockDataLayer.mockReturnValueOnce(of({}));

queryCosmosForUIVersions();
expect(mockDataLayer).toHaveBeenCalledTimes(1);
});
});
describe("#queryUIServiceForMetadata", () => {
it(
"returns result from ui-update-service",
marbles(m => {
const queryResp$ = m.cold("--j|", {
j: {
data: {
ui: {
clientBuild: "unit_test+v2.50.1",
packageVersion: "2.50.1",
packageVersionIsDefault: false,
serverBuild: "master+v2.50.1+hfges"
}
}
}
});
mockDataLayer.mockReturnValueOnce(queryResp$);

const query$ = queryUIServiceForMetadata();
const result$ = query$.pipe(take(1));
m.expect(result$).toBeObservable(
m.cold("--(j|)", {
j: {
clientBuild: "unit_test+v2.50.1",
packageVersion: "2.50.1",
packageVersionIsDefault: false,
serverBuild: "master+v2.50.1+hfges"
}
})
);
})
);

it(
"makes a single query to data-layer",
marbles(m => {
const queryResp$ = m.cold("--j|", {
j: {
data: {
ui: {
clientBuild: "unit_test+v2.50.1",
packageVersion: "2.50.1",
packageVersionIsDefault: false,
serverBuild: "master+v2.50.1+hfges"
}
}
}
});
mockDataLayer.mockReturnValueOnce(queryResp$);

queryUIServiceForMetadata();
expect(mockDataLayer).toHaveBeenCalledTimes(1);
})
);

it(
"returns default ui metadata if query errors",
marbles(m => {
const queryResp$ = m.cold("--#", undefined, {
message: "Query Failed",
name: "Error"
});
mockDataLayer.mockReturnValueOnce(queryResp$);

const query$ = queryUIServiceForMetadata();
const result$ = query$.pipe(take(1));
m.expect(result$).toBeObservable(
m.cold("--(j|)", {
j: DEFAULT_UI_METADATA
})
);
})
);
});
});
32 changes: 32 additions & 0 deletions plugins/ui-update/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { graphqlObservable } from "@dcos/data-service";
import gql from "graphql-tag";
import { default as uiServiceSchema } from "#SRC/js/data/ui-update";
import { delay } from "rxjs/operators";

function rollbackUI(delayMs: number = 45000) {
return graphqlObservable<{ resetDCOSUI: string | null }>(
gql`
mutation {
resetDCOSUI
}
`,
uiServiceSchema,
{}
).pipe(delay(delayMs));
}

function updateUI(version: string, delayMs: number = 45000) {
return graphqlObservable<{ updateDCOSUI: string }>(
gql`
mutation {
updateDCOSUI(newVersion: $version)
}
`,
uiServiceSchema,
{
version
}
).pipe(delay(delayMs));
}

export { rollbackUI, updateUI };
Loading

0 comments on commit 57be6b0

Please sign in to comment.