Skip to content

Commit

Permalink
feat(aws): display capacity type (spot/ on-demand) in instance inform…
Browse files Browse the repository at this point in the history
…ation (#8688)

spinnaker/spinnaker#5989

Co-authored-by: caseyhebebrand <caseyhebebrand@gmail.com>
  • Loading branch information
pdk27 and caseyhebebrand committed Oct 28, 2020
1 parent a929d3f commit 308fb57
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/scripts/modules/amazon/src/domain/IAmazonInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { IAmazonSecurityGroup } from './IAmazonSecurityGroup';
export interface IAmazonInstance extends IInstance {
imageId?: string;
instanceType?: string;
capacityType?: string;
securityGroups?: IAmazonSecurityGroup[];
subnetId?: string;
targetGroups?: string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const AmazonInstanceInformation = ({ instance }: IAmazonInstanceInformati
account={instance.account}
availabilityZone={instance.availabilityZone}
instanceType={instance.instanceType}
capacityType={instance.capacityType}
launchTime={instance.launchTime}
provider={instance.provider}
region={instance.region}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe('InstanceInformation', () => {
const testInstance = {
...mockInstance,
instanceType: 'm5.large',
capacityType: 'spot',
region: 'us-east-1',
serverGroup: 'test_sg',
};
Expand All @@ -18,6 +19,7 @@ describe('InstanceInformation', () => {
account={testInstance.account}
availabilityZone={testInstance.availabilityZone}
instanceType={testInstance.instanceType}
capacityType={testInstance.capacityType}
launchTime={testInstance.launchTime}
provider={testInstance.provider}
region={testInstance.region}
Expand All @@ -27,11 +29,17 @@ describe('InstanceInformation', () => {
);

const labeledValues = wrapper.find('LabeledValue');
expect(labeledValues.length).toEqual(4);
expect(labeledValues.length).toEqual(5);

expect(wrapper.childAt(0).prop('label')).toEqual('Launched');
expect(wrapper.childAt(1).prop('label')).toEqual('In');
expect(wrapper.childAt(2).prop('label')).toEqual('Type');
expect(wrapper.childAt(3).prop('label')).toEqual('Capacity Type');
expect(wrapper.childAt(4).prop('label')).toEqual('Server Group');

expect(wrapper.childAt(0).prop('value')).toEqual('1970-01-14 22:37:37 PST');
expect(wrapper.childAt(2).prop('value')).toEqual(testInstance.instanceType);
expect(wrapper.childAt(3).prop('label')).toEqual('Server Group');
expect(wrapper.childAt(3).prop('value')).toEqual(testInstance.capacityType);
});

it('should render correct state when attributes are missing', () => {
Expand All @@ -40,6 +48,7 @@ describe('InstanceInformation', () => {
account={testInstance.account}
availabilityZone={undefined}
instanceType={undefined}
capacityType={undefined}
launchTime={undefined}
provider={testInstance.provider}
region={testInstance.region}
Expand All @@ -51,8 +60,11 @@ describe('InstanceInformation', () => {
const labeledValues = wrapper.find('LabeledValue');
expect(labeledValues.length).toEqual(3);

expect(wrapper.childAt(0).prop('label')).toEqual('Launched');
expect(wrapper.childAt(1).prop('label')).toEqual('In');
expect(wrapper.childAt(2).prop('label')).toEqual('Type');

expect(wrapper.childAt(0).prop('value')).toEqual('Unknown');
expect(wrapper.childAt(2).prop('value')).toEqual('Unknown');
expect(wrapper.childAt(2).prop('label')).not.toEqual('Server Group');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface IInstanceInformationProps {
account: string;
availabilityZone: string;
instanceType: string;
capacityType?: string;
launchTime: number;
provider: string;
region: string;
Expand All @@ -19,6 +20,7 @@ export const InstanceInformation = ({
account,
availabilityZone,
instanceType,
capacityType,
launchTime,
provider,
region,
Expand All @@ -37,6 +39,7 @@ export const InstanceInformation = ({
}
/>
{showInstanceType && <LabeledValue label="Type" value={instanceType || 'Unknown'} />}
{showInstanceType && capacityType && <LabeledValue label="Capacity Type" value={capacityType || 'Unknown'} />}
{serverGroup && (
<LabeledValue
label="Server Group"
Expand Down

0 comments on commit 308fb57

Please sign in to comment.