You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by dm...@apache.org on 2017/10/18 17:25:54 UTC
aurora git commit: Detect and parse Thermos config in Diff output
Repository: aurora
Updated Branches:
refs/heads/master b17420538 -> def6e4338
Detect and parse Thermos config in Diff output
Reviewed at https://reviews.apache.org/r/63092/
Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/def6e433
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/def6e433
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/def6e433
Branch: refs/heads/master
Commit: def6e43381ff11646057e70e4e55cd10e5c4bb76
Parents: b174205
Author: David McLaughlin <da...@dmclaughlin.com>
Authored: Wed Oct 18 10:18:19 2017 -0700
Committer: David McLaughlin <da...@dmclaughlin.com>
Committed: Wed Oct 18 10:18:19 2017 -0700
----------------------------------------------------------------------
ui/src/main/js/components/Diff.js | 14 ++++-
.../main/js/components/__tests__/Diff-test.js | 62 ++++++++++++++++++++
ui/src/main/js/test-utils/TaskBuilders.js | 3 +-
ui/src/main/js/utils/Task.js | 4 ++
ui/src/main/sass/components/_diff.scss | 4 +-
ui/src/main/sass/components/_job-page.scss | 2 +-
6 files changed, 84 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aurora/blob/def6e433/ui/src/main/js/components/Diff.js
----------------------------------------------------------------------
diff --git a/ui/src/main/js/components/Diff.js b/ui/src/main/js/components/Diff.js
index 53ba517..c776016 100644
--- a/ui/src/main/js/components/Diff.js
+++ b/ui/src/main/js/components/Diff.js
@@ -1,8 +1,20 @@
import React from 'react';
import { diffJson } from 'diff';
+import { clone } from 'utils/Common';
+import { isThermos } from 'utils/Task';
+
+function maybeParseThermos(task) {
+ if (isThermos(task)) {
+ const modifiedTask = clone(task);
+ modifiedTask.executorConfig.data = JSON.parse(task.executorConfig.data);
+ return modifiedTask;
+ }
+ return task;
+}
+
export default function Diff({ left, right }) {
- const result = diffJson(left, right);
+ const result = diffJson(maybeParseThermos(left), maybeParseThermos(right));
return (<div className='diff-view'>
{result.map((r, i) => (
<span className={r.added ? 'added' : r.removed ? 'removed' : 'same'} key={i}>
http://git-wip-us.apache.org/repos/asf/aurora/blob/def6e433/ui/src/main/js/components/__tests__/Diff-test.js
----------------------------------------------------------------------
diff --git a/ui/src/main/js/components/__tests__/Diff-test.js b/ui/src/main/js/components/__tests__/Diff-test.js
index 7f91322..68bf1d5 100644
--- a/ui/src/main/js/components/__tests__/Diff-test.js
+++ b/ui/src/main/js/components/__tests__/Diff-test.js
@@ -3,6 +3,8 @@ import { shallow } from 'enzyme';
import Diff from '../Diff';
+import { TaskConfigBuilder } from 'test-utils/TaskBuilders';
+
describe('Diff', () => {
it('Should not add change classes to diff viewer when objects are same', () => {
const el = shallow(<Diff left={{test: true}} right={{test: true}} />);
@@ -15,4 +17,64 @@ describe('Diff', () => {
expect(el.find('span.removed').length).toBe(1);
expect(el.find('span.added').length).toBe(1);
});
+
+ it('Should render a finer grained diff when Thermos executor is used', () => {
+ const left = TaskConfigBuilder.executorConfig({
+ name: 'AuroraExecutor',
+ data: JSON.stringify({
+ one: 1,
+ two: 2,
+ three: 3,
+ nested: {
+ okay: true
+ }
+ })
+ }).build();
+
+ const right = TaskConfigBuilder.executorConfig({
+ name: 'AuroraExecutor',
+ data: JSON.stringify({
+ one: 'one',
+ two: 2,
+ three: 3,
+ nested: {
+ okay: false
+ }
+ })
+ }).build();
+
+ const el = shallow(<Diff left={left} right={right} />);
+ expect(el.find('span.removed').length).toBe(2);
+ expect(el.find('span.added').length).toBe(2);
+ });
+
+ it('Just treats executor config as a string for custom executors', () => {
+ const left = TaskConfigBuilder.executorConfig({
+ name: 'MyExecutor',
+ data: JSON.stringify({
+ one: 1,
+ two: 2,
+ three: 3,
+ nested: {
+ okay: true
+ }
+ })
+ }).build();
+
+ const right = TaskConfigBuilder.executorConfig({
+ name: 'MyExecutor',
+ data: JSON.stringify({
+ one: 'one',
+ two: 2,
+ three: 3,
+ nested: {
+ okay: false
+ }
+ })
+ }).build();
+
+ const el = shallow(<Diff left={left} right={right} />);
+ expect(el.find('span.removed').length).toBe(1);
+ expect(el.find('span.added').length).toBe(1);
+ });
});
http://git-wip-us.apache.org/repos/asf/aurora/blob/def6e433/ui/src/main/js/test-utils/TaskBuilders.js
----------------------------------------------------------------------
diff --git a/ui/src/main/js/test-utils/TaskBuilders.js b/ui/src/main/js/test-utils/TaskBuilders.js
index 8427722..f2b0645 100644
--- a/ui/src/main/js/test-utils/TaskBuilders.js
+++ b/ui/src/main/js/test-utils/TaskBuilders.js
@@ -31,7 +31,8 @@ export const TaskConfigBuilder = createBuilder({
tier: TIER,
resources: [{numCpus: 1}, {ramMb: 1024}, {diskMb: 1024}],
constraints: [],
- requestedPorts: []
+ requestedPorts: [],
+ executorConfig: {data: {}, name: 'TestExecutor'}
});
export const AssignedTaskBuilder = createBuilder({
http://git-wip-us.apache.org/repos/asf/aurora/blob/def6e433/ui/src/main/js/utils/Task.js
----------------------------------------------------------------------
diff --git a/ui/src/main/js/utils/Task.js b/ui/src/main/js/utils/Task.js
index 7da6d10..e3b4a49 100644
--- a/ui/src/main/js/utils/Task.js
+++ b/ui/src/main/js/utils/Task.js
@@ -64,3 +64,7 @@ export function getResource(resources, key) {
export function getResources(resources, key) {
return resources.filter((r) => !isNully(r[key]));
}
+
+export function isThermos(task) {
+ return task && task.executorConfig && task.executorConfig.name === 'AuroraExecutor';
+}
http://git-wip-us.apache.org/repos/asf/aurora/blob/def6e433/ui/src/main/sass/components/_diff.scss
----------------------------------------------------------------------
diff --git a/ui/src/main/sass/components/_diff.scss b/ui/src/main/sass/components/_diff.scss
index f58f7bd..ed45769 100644
--- a/ui/src/main/sass/components/_diff.scss
+++ b/ui/src/main/sass/components/_diff.scss
@@ -32,11 +32,11 @@
}
span.removed {
- background-color: $colors_error_light;
+ background-color: #ffd7dc;
}
span.added {
- background-color: $colors_success_light;
+ background-color: #c8f7d5;
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/aurora/blob/def6e433/ui/src/main/sass/components/_job-page.scss
----------------------------------------------------------------------
diff --git a/ui/src/main/sass/components/_job-page.scss b/ui/src/main/sass/components/_job-page.scss
index bafff88..cd03832 100644
--- a/ui/src/main/sass/components/_job-page.scss
+++ b/ui/src/main/sass/components/_job-page.scss
@@ -63,7 +63,7 @@
margin-right: 20px;
margin-bottom: 20px;
- .tast-constraint {
+ .task-constraint {
display: block;
}
}