Remove AutoPilot v2 (#304)

* Remove AutoPilot v2

* Update DatabaseSettingsTab.ts

* Update DatabaseSettingsTab.ts

* Update src/Explorer/Tabs/DatabaseSettingsTab.ts

Co-authored-by: Laurent Nguyen <laurent.nguyen@microsoft.com>

* Update src/Explorer/Tabs/SettingsTab.ts

* Update src/Explorer/Tabs/DatabaseSettingsTab.ts

Co-authored-by: Laurent Nguyen <laurent.nguyen@microsoft.com>

* Update src/Explorer/Tabs/SettingsTab.ts

* Remove more unused code

* Remove import

Co-authored-by: Laurent Nguyen <laurent.nguyen@microsoft.com>
This commit is contained in:
Steve Faulkner
2020-10-29 11:26:37 -05:00
committed by GitHub
parent 542abf4d3a
commit 79769e9689
29 changed files with 116 additions and 1815 deletions

View File

@@ -1,119 +0,0 @@
import * as AutoPilotUtils from "./AutoPilotUtils";
import * as Constants from "../Common/Constants";
import { AutopilotTier, Offer } from "../Contracts/DataModels";
describe("AutoPilotUtils", () => {
describe("isAutoPilotOfferUpgradedToV3", () => {
const legacyAutopilotOffer = {
tier: 1,
maximumTierThroughput: 20000,
maxThroughput: 20000
};
const v3AutopilotOffer = {
maximumTierThroughput: 20000,
maxThroughput: 20000
};
const v3AutopilotOfferDuringTransitionPhase = {
tier: 0,
maximumTierThroughput: 20000,
maxThroughput: 20000
};
it("should return false if the offer has a tier level and the tier level >= 1", () => {
expect(AutoPilotUtils.isAutoPilotOfferUpgradedToV3(legacyAutopilotOffer)).toEqual(false);
});
it("should return true if the autopilot offer does not have a tier level", () => {
expect(AutoPilotUtils.isAutoPilotOfferUpgradedToV3(v3AutopilotOffer)).toEqual(true);
});
it("should return true if the autopilot offer has a tier level and the tier level is === 0", () => {
expect(AutoPilotUtils.isAutoPilotOfferUpgradedToV3(v3AutopilotOfferDuringTransitionPhase)).toEqual(true);
});
});
describe("isValidAutoPilotOffer", () => {
function getOffer(): Offer {
const commonOffer: Offer = {
_etag: "_etag",
_rid: "_rid",
_self: "_self",
_ts: "_ts",
id: "id",
content: {
offerThroughput: 0,
offerIsRUPerMinuteThroughputEnabled: false,
offerAutopilotSettings: undefined
}
};
return commonOffer;
}
it("offer with autopilot", () => {
let offer = getOffer();
offer.content.offerAutopilotSettings = {
tier: 1
};
const isValid = AutoPilotUtils.isValidV2AutoPilotOffer(offer);
expect(isValid).toBe(true);
});
it("offer without autopilot", () => {
let offer = getOffer();
const isValid = AutoPilotUtils.isValidV2AutoPilotOffer(offer);
expect(isValid).toBe(false);
});
});
describe("isValidAutoPilotTier", () => {
it("invalid input, should return false", () => {
const isValid1 = AutoPilotUtils.isValidAutoPilotTier(0);
expect(isValid1).toBe(false);
const isValid2 = AutoPilotUtils.isValidAutoPilotTier(5);
expect(isValid2).toBe(false);
const isValid3 = AutoPilotUtils.isValidAutoPilotTier(undefined);
expect(isValid3).toBe(false);
});
it("valid input, should return true", () => {
const isValid1 = AutoPilotUtils.isValidAutoPilotTier(1);
expect(isValid1).toBe(true);
const isValid3 = AutoPilotUtils.isValidAutoPilotTier(AutopilotTier.Tier3);
expect(isValid3).toBe(true);
});
});
describe("getAutoPilotTextWithTier", () => {
it("invalid input, should return undefined", () => {
const text1 = AutoPilotUtils.getAutoPilotTextWithTier(0);
expect(text1).toBe(undefined);
const text2 = AutoPilotUtils.getAutoPilotTextWithTier(undefined);
expect(text2).toBe(undefined);
});
it("valid input, should return coreponding text", () => {
const text1 = AutoPilotUtils.getAutoPilotTextWithTier(1);
expect(text1).toBe(Constants.AutoPilot.tier1Text);
const text4 = AutoPilotUtils.getAutoPilotTextWithTier(AutopilotTier.Tier4);
expect(text4).toBe(Constants.AutoPilot.tier4Text);
});
});
describe("getAvailableAutoPilotTiersOptions", () => {
it("invalid input should return all options", () => {
const option1 = AutoPilotUtils.getAvailableAutoPilotTiersOptions(undefined);
expect(option1.length).toBe(4);
const option2 = AutoPilotUtils.getAvailableAutoPilotTiersOptions(5);
expect(option2.length).toBe(4);
});
it("valid input should return all available options", () => {
const option1 = AutoPilotUtils.getAvailableAutoPilotTiersOptions();
expect(option1.length).toBe(4);
const option2 = AutoPilotUtils.getAvailableAutoPilotTiersOptions(AutopilotTier.Tier3);
expect(option2.length).toBe(4);
});
});
});

View File

@@ -1,6 +1,5 @@
import * as Constants from "../Common/Constants";
import { AutoPilotOfferSettings, AutopilotTier, Offer } from "../Contracts/DataModels";
import { DropdownOption } from "../Contracts/ViewModels";
import { AutoPilotOfferSettings, Offer } from "../Contracts/DataModels";
export const manualToAutoscaleDisclaimer = `The starting autoscale max RU/s will be determined by the system, based on the current manual throughput settings and storage of your resource. After autoscale has been enabled, you can change the max RU/s. <a href="${Constants.Urls.autoscaleMigration}">Learn more</a>.`;
@@ -8,24 +7,6 @@ export const minAutoPilotThroughput = 4000;
export const autoPilotIncrementStep = 1000;
const autoPilotTiers: Array<AutopilotTier> = [
AutopilotTier.Tier1,
AutopilotTier.Tier2,
AutopilotTier.Tier3,
AutopilotTier.Tier4
];
const autoPilotTierTextMap = {
[AutopilotTier.Tier1]: Constants.AutoPilot.tier1Text,
[AutopilotTier.Tier2]: Constants.AutoPilot.tier2Text,
[AutopilotTier.Tier3]: Constants.AutoPilot.tier3Text,
[AutopilotTier.Tier4]: Constants.AutoPilot.tier4Text
};
export function isAutoPilotOfferUpgradedToV3(offer: AutoPilotOfferSettings): boolean {
return offer && !offer.tier;
}
export function isValidV3AutoPilotOffer(offer: Offer): boolean {
const maxThroughput =
offer &&
@@ -35,36 +16,6 @@ export function isValidV3AutoPilotOffer(offer: Offer): boolean {
return isValidAutoPilotThroughput(maxThroughput);
}
export function isValidV2AutoPilotOffer(offer: Offer): boolean {
const tier =
offer && offer.content && offer.content.offerAutopilotSettings && offer.content.offerAutopilotSettings.tier;
if (!tier) {
return false;
}
return isValidAutoPilotTier(tier);
}
export function isValidAutoPilotTier(tier: number | AutopilotTier): boolean {
if (autoPilotTiers.indexOf(tier) >= 0) {
return true;
}
return false;
}
export function getAutoPilotTextWithTier(tier: AutopilotTier): string {
return !!autoPilotTierTextMap[tier] ? autoPilotTierTextMap[tier] : undefined;
}
export function getAvailableAutoPilotTiersOptions(
tier: AutopilotTier = AutopilotTier.Tier1
): DropdownOption<AutopilotTier>[] {
if (!isValidAutoPilotTier(tier)) {
tier = AutopilotTier.Tier1;
}
return autoPilotTiers.map((t: AutopilotTier) => ({ value: t, text: getAutoPilotTextWithTier(t) }));
}
export function isValidAutoPilotThroughput(maxThroughput: number): boolean {
if (!maxThroughput) {
return false;
@@ -86,9 +37,6 @@ export function getStorageBasedOnUserInput(throughput: number): number {
return Math.round(throughput && throughput * 0.01);
}
export function getAutoPilotHeaderText(isV2Model: boolean): string {
if (isV2Model) {
return "Throughput (Autopilot)";
}
export function getAutoPilotHeaderText(): string {
return "Throughput (autoscale)";
}

View File

@@ -1,6 +1,5 @@
import * as AutoPilotUtils from "../Utils/AutoPilotUtils";
import * as Constants from "../Shared/Constants";
import { AutopilotTier } from "../Contracts/DataModels";
/**
* Anything that is not a number should return 0
@@ -14,10 +13,7 @@ export function normalizeNumber(number: null | undefined | string | number): num
return Math.floor(Number(number));
}
export function getRuToolTipText(isV2AutoPilot: boolean): string {
if (isV2AutoPilot) {
return "Provisioned throughput is measured in Request Units per second (RU/s). 1 RU corresponds to the throughput of a read of a 1 KB document.";
}
export function getRuToolTipText(): string {
return `Set the throughput — Request Units per second (RU/s) — required for the workload. A read of a 1 KB document uses 1 RU. Select manual if you plan to scale RU/s yourself. Select autoscale to allow the system to scale RU/s based on usage.`;
}
@@ -161,26 +157,6 @@ export function getPricePerRuPm(serverId: string): number {
return Constants.OfferPricing.HourlyPricing.default.Standard.PricePerRUPM;
}
export function getAutoPilotV2SpendHtml(autoPilotTier: AutopilotTier, isDatabaseThroughput: boolean): string {
if (!autoPilotTier) {
return "";
}
const resource: string = isDatabaseThroughput ? "database" : "container";
switch (autoPilotTier) {
case AutopilotTier.Tier1:
return `Your ${resource} throughput will automatically scale between 400 RU/s and 4,000 RU/s based on the workload needs, as long as your storage does not exceed 50GB. If your storage exceeds 50GB, we will upgrade the maximum (and minimum) throughput thresholds to the next available value. For more details, see <a href='${Constants.AutopilotDocumentation.Url}' target='_blank'>documentation</a>.`;
case AutopilotTier.Tier2:
return `Your ${resource} throughput will automatically scale between 2,000 RU/s and 20,000 RU/s based on the workload needs, as long as your storage does not exceed 200GB. If your storage exceeds 200GB, we will upgrade the maximum (and minimum) throughput thresholds to the next available value. For more details, see <a href='${Constants.AutopilotDocumentation.Url}' target='_blank'>documentation</a>.`;
case AutopilotTier.Tier3:
return `Your ${resource} throughput will automatically scale between 10,000 RU/s and 100,000 RU/s based on the workload needs, as long as your storage does not exceed 1TB. If your storage exceeds 1TB, we will upgrade the maximum (and minimum) throughput thresholds to the next available value. For more details, see <a href='${Constants.AutopilotDocumentation.Url}' target='_blank'>documentation</a>.`;
case AutopilotTier.Tier4:
return `Your ${resource} throughput will automatically scale between 50,000 RU/s and 500,000 RU/s based on the workload needs, as long as your storage does not exceed 5TB. If your storage exceeds 5TB, we will upgrade the maximum (and minimum) throughput thresholds to the next available value. For more details, see <a href='${Constants.AutopilotDocumentation.Url}' target='_blank'>documentation</a>.`;
default:
return `Your ${resource} throughput will automatically scale based on the workload needs.`;
}
}
export function getAutoPilotV3SpendHtml(maxAutoPilotThroughputSet: number, isDatabaseThroughput: boolean): string {
if (!maxAutoPilotThroughputSet) {
return "";