Skip to content

Commit

Permalink
Merge 7264aa1 into deaf600
Browse files Browse the repository at this point in the history
  • Loading branch information
Mwea committed Dec 6, 2018
2 parents deaf600 + 7264aa1 commit 77ada92
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 11 deletions.
10 changes: 10 additions & 0 deletions src/js/components/AppConfigEditFormComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ var AppConfigEditFormComponent = React.createClass({
cpus: "cpus",
mem: "mem",
disk: "disk",
gpus: "gpus",
instances: "instances",
cmd: "cmd"
})
Expand Down Expand Up @@ -358,6 +359,15 @@ var AppConfigEditFormComponent = React.createClass({
<input min="0" step="any" type="number"/>
</FormGroupComponent>
</div>
<div className="col-sm-3">
<FormGroupComponent fieldId="gpus"
label="GPUs (Device)"
errorMessage={this.getErrorMessage("gpus")}
value={state.fields.gpus}
onChange={this.handleFieldUpdate}>
<input min="0" step="1" type="number"/>
</FormGroupComponent>
</div>
<div className="col-sm-3">
<FormGroupComponent fieldId="instances" label="Instances"
errorMessage={this.getErrorMessage("instances")}
Expand Down
2 changes: 2 additions & 0 deletions src/js/components/AppVersionComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ var AppVersionComponent = React.createClass({
{invalidateValue(appVersion.mem, "MiB")}
<dt>Disk Space</dt>
{invalidateValue(appVersion.disk, "MiB")}
<dt>GPUs</dt>
{invalidateValue(appVersion.gpus, "Device")}
<dt>Networks</dt>
{networksNode}
<dt>Port Definitions</dt>
Expand Down
2 changes: 2 additions & 0 deletions src/js/constants/AppConfigDefaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const AppConfigFormDefaultValues = Util.deepFreeze({
cpus: 1,
mem: 128,
disk: 0,
gpus: 0,
instances: 1
});

Expand All @@ -17,6 +18,7 @@ export const AppConfigDefaultValues = Util.deepFreeze({
cpus: 1,
mem: 128,
disk: 0,
gpus: 0,
instances: 1
});

Expand Down
1 change: 1 addition & 0 deletions src/js/constants/AppFormErrorMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const applicationFieldValidationErrors = Util.deepFreeze({
instances: ["Instances must be a non-negative number"],
labels: ["Key cannot be blank"],
mem: ["Memory must be a number greater than or equal to 32"],
gpus: ["GPUs must be a non-negative integer"],
portDefinitions: [
"Port must be a valid port",
"Protocol must be either 'tcp' or 'udp'"
Expand Down
3 changes: 3 additions & 0 deletions src/js/stores/AppFormStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const validationRules = {
"instances": [AppFormValidators.instances],
"labels": [AppFormValidators.labels],
"mem": [AppFormValidators.mem],
"gpus": [AppFormValidators.gpus],
"portDefinitions": [
AppFormValidators.portDefinitionsPortIsValid,
AppFormValidators.portDefinitionsProtocolValidType
Expand Down Expand Up @@ -116,6 +117,7 @@ const resolveFieldIdToAppKeyMap = {
executor: "executor",
labels: "labels",
mem: "mem",
gpus: "gpus",
portDefinitions: "portDefinitions",
uris: "uris",
user: "user"
Expand Down Expand Up @@ -170,6 +172,7 @@ const responseAttributePathToFieldIdMap = {
"healthChecks/{INDEX}/maxConsecutiveFailures",
"/instances": "instances",
"/mem": "mem",
"/gpus": "gpus",
"/portDefinitions": "portDefinitions",
"/portDefinitions({INDEX})/name": "portDefinitions/{INDEX}/name",
"/portDefinitions({INDEX})/port": "portDefinitions/{INDEX}/port",
Expand Down
1 change: 1 addition & 0 deletions src/js/stores/schemes/appScheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const appScheme = {
mem: null,
networks: [],
disk: null,
gpus: null,
portDefinitions: [],
fetch: [],
user: null,
Expand Down
1 change: 1 addition & 0 deletions src/js/stores/transforms/AppFormFieldToModelTransforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const AppFormFieldToModelTransforms = {
},
cpus: (value) => parseFloat(value),
disk: (value) => parseFloat(value),
gpus: (value) => parseInt(value),
constraints: (constraints) => constraints
.split(",")
.filter((constraint) => constraint != null && constraint !== "")
Expand Down
3 changes: 3 additions & 0 deletions src/js/stores/validators/AppFormValidators.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ const AppFormValidators = {
mem: (value) => !Util.isStringAndEmpty(value) &&
!!value.toString().match(/^[0-9\.]+$/) && parseInt(value) >= 32,

gpus: (value) => !Util.isStringAndEmpty(value) &&
!!value.toString().match(/^[0-9]+$/),

ports: (ports) => Util.isStringAndEmpty(ports) ||
ports.split(",")
.every((port) => port.toString().trim().match(/^[0-9]+$/)),
Expand Down
1 change: 1 addition & 0 deletions src/test/fixtures/minimalAppFullConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"cpus": 1,
"mem": 128,
"disk": 0,
"gpus": 0,
"executor": "",
"constraints": [],
"uris": [],
Expand Down
23 changes: 12 additions & 11 deletions src/test/units/AppVersionComponent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe("AppVersionComponent", function () {
"cpus": 0.1,
"mem": 16.0,
"disk": 0.0,
"gpus": 0,
"executor": "",
"constraints": [],
"uris": [],
Expand Down Expand Up @@ -139,37 +140,37 @@ describe("AppVersionComponent", function () {
});

it("has correct backoff factor", function () {
var children = this.rows.at(35).props().children;
var children = this.rows.at(37).props().children;
expect(children[0]).to.equal(1.15);
});

it("has correct backoff", function () {
var children = this.rows.at(37).props().children;
var children = this.rows.at(39).props().children;
expect(children[0]).to.equal(1);
expect(children[2]).to.equal("seconds");
});

it("has correct max launch delay", function () {
var children = this.rows.at(39).props().children;
var children = this.rows.at(41).props().children;
expect(children[0]).to.equal(3600);
expect(children[2]).to.equal("seconds");
});

it("has correct URIs", function () {
expect(this.rows.at(41).text().trim()).to.equal("Unspecified");
expect(this.rows.at(43).text().trim()).to.equal("Unspecified");
});

it("has correct User", function () {
expect(this.rows.at(43).props().children[0]).to.equal("testuser");
expect(this.rows.at(45).props().children[0]).to.equal("testuser");
});

it("has correct args", function () {
expect(this.rows.at(45).text()).to.equal("arg1");
expect(this.rows.at(46).text()).to.equal("arg2");
expect(this.rows.at(47).text()).to.equal("arg1");
expect(this.rows.at(48).text()).to.equal("arg2");
});

it("has correct version", function () {
expect(this.rows.at(48).props().children[0])
expect(this.rows.at(50).props().children[0])
.to.equal("2015-06-29T12:57:02.269Z");
});

Expand Down Expand Up @@ -200,7 +201,7 @@ describe("AppVersionComponent", function () {
this.component = mount(<AppVersionComponent appVersion={this.model} />);
this.table = this.component.find("dl.dl-horizontal");
this.rows = this.table.children();
expect(this.rows.at(41).text().trim()).to.equal("http://localhost/test");
expect(this.rows.at(43).text().trim()).to.equal("http://localhost/test");
});

it("has multiple uris", function () {
Expand All @@ -218,7 +219,7 @@ describe("AppVersionComponent", function () {
this.component = mount(<AppVersionComponent appVersion={this.model} />);
this.table = this.component.find("dl.dl-horizontal");
this.rows = this.table.children();
expect(this.rows.at(41).text().trim()).to.equal("http://localhost/test");
expect(this.rows.at(42).text().trim()).to.equal("http://localhost/test2");
expect(this.rows.at(43).text().trim()).to.equal("http://localhost/test");
expect(this.rows.at(44).text().trim()).to.equal("http://localhost/test2");
});
});

0 comments on commit 77ada92

Please sign in to comment.