Update to ADO 5ed9b2130da7f822153531489d802c28986f5d30

This commit is contained in:
Steve Faulkner
2020-05-26 13:53:41 -05:00
parent 36581fb6d9
commit 0494da4162
42 changed files with 1186 additions and 2242 deletions

View File

@@ -1,13 +1,5 @@
import * as ViewModels from "../Contracts/ViewModels";
import ko from "knockout";
import { AddDbUtilities } from "../Shared/AddDatabaseUtility";
import {
CollectionDefaults,
CreateCollectionUtilities,
CreateSqlCollectionUtilities,
Utilities
} from "./AddCollectionUtility";
import { CollectionStub, DatabaseStub, ExplorerStub } from "../Explorer/OpenActionsStubs";
import { CreateCollectionUtilities, CreateSqlCollectionUtilities, Utilities } from "./AddCollectionUtility";
jest.mock("AddDatabaseUtility");
const armEndpoint = "https://management.azure.com";
@@ -159,985 +151,3 @@ describe("Add Collection Utitlity", () => {
});
});
});
describe("Add Collection Utilility", () => {
describe("_getDefaults()", () => {
describe("default storage", () => {
describe("for Benefits subscriptions", () => {
it("should be '100' in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Benefits);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Benefits);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Benefits);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Benefits);
expect(value.storage).toBe("100");
});
});
describe("for EA subscriptions", () => {
it("should be '100' in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.EA);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.EA);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.EA);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.EA);
expect(value.storage).toBe("100");
});
});
describe("for Free subscriptions", () => {
it("should be '100' in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Free);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Free);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Free);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Free);
expect(value.storage).toBe("100");
});
});
describe("for Internal subscriptions", () => {
it("should be '100' in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Internal);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Internal);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Internal);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Internal);
expect(value.storage).toBe("100");
});
});
describe("for PAYG subscriptions", () => {
it("should be '100' in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.PAYG);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.PAYG);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.PAYG);
expect(value.storage).toBe("100");
});
it("should be '100' in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.PAYG);
expect(value.storage).toBe("100");
});
});
});
describe("default throughput for fixed collections", () => {
describe("for Benefits subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.fixed).toBe(400);
});
});
describe("for EA subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.EA);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.EA);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.EA);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.EA);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.EA);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.EA);
expect(value.throughput.fixed).toBe(400);
});
});
describe("for Free subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Free);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Free);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Free);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Free);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Free);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Free);
expect(value.throughput.fixed).toBe(400);
});
});
describe("for Internal subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Internal);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Internal);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Internal);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Internal);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Internal);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Internal);
expect(value.throughput.fixed).toBe(400);
});
});
describe("for PAYG subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.fixed).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.fixed).toBe(400);
});
});
});
describe("default throughput for unlimited collections", () => {
describe("for Benefits subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimited(null)).toBe(400);
});
});
describe("for EA subscriptions", () => {
const explorer5 = new ExplorerStub();
explorer5.databases = ko.observableArray([
new DatabaseStub({
id: ko.observable("db"),
collections: ko.observableArray([
new CollectionStub({
id: ko.observable("1")
}),
new CollectionStub({
id: ko.observable("2")
}),
new CollectionStub({
id: ko.observable("3")
}),
new CollectionStub({
id: ko.observable("4")
}),
new CollectionStub({
id: ko.observable("5")
})
])
})
]);
const explorer6 = new ExplorerStub();
explorer6.databases = ko.observableArray([
new DatabaseStub({
id: ko.observable("db"),
collections: ko.observableArray([
new CollectionStub({
id: ko.observable("1")
}),
new CollectionStub({
id: ko.observable("2")
}),
new CollectionStub({
id: ko.observable("3")
}),
new CollectionStub({
id: ko.observable("4")
}),
new CollectionStub({
id: ko.observable("5")
}),
new CollectionStub({
id: ko.observable("6")
})
])
})
]);
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 10,000 in flight '20190618.1' and database with 5 collections or less", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimited(explorer5)).toBe(10000);
});
it("should be 10,000 in flight '20190618.1' and database with more than 5 collections", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimited(explorer6)).toBe(1000);
});
it("should be 1,000 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimited(null)).toBe(1000);
});
});
describe("for Free subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimited(null)).toBe(400);
});
});
describe("for Internal subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimited(null)).toBe(400);
});
});
describe("for PAYG subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimited(null)).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimited(null)).toBe(400);
});
});
});
describe("min throughput for unlimited collections", () => {
describe("for Benefits subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmin).toBe(400);
});
});
describe("for EA subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmin).toBe(400);
});
});
describe("for Free subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmin).toBe(400);
});
});
describe("for Internal subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmin).toBe(400);
});
});
describe("for PAYG subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmin).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmin).toBe(400);
});
});
});
describe("max throughput for unlimited collections", () => {
describe("for Benefits subscriptions", () => {
it("should be 100,000 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.unlimitedmax).toBe(100000);
});
});
describe("for EA subscriptions", () => {
it("should be 1,000,000 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
it("should be 1,000,000 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
it("should be 1,000,000 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
it("should be 1,000,000 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
it("should be 1,000,000 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
it("should be 1,000,000 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.EA);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
});
describe("for Free subscriptions", () => {
it("should be 100,000 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Free);
expect(value.throughput.unlimitedmax).toBe(100000);
});
});
describe("for Internal subscriptions", () => {
it("should be 100,000 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmax).toBe(100000);
});
it("should be 100,000 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Internal);
expect(value.throughput.unlimitedmax).toBe(100000);
});
});
describe("for PAYG subscriptions", () => {
it("should be 1,000,000 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
it("should be 1,000,000 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
it("should be 1,000,000 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
it("should be 1,000,000 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
it("should be 1,000,000 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
it("should be 1,000,000 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.unlimitedmax).toBe(1000000);
});
});
});
describe("default throughput for shared offers", () => {
describe("for Benefits subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Benefits);
expect(value.throughput.shared).toBe(400);
});
});
describe("for EA subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.EA);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.EA);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.EA);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.EA);
expect(value.throughput.shared).toBe(400);
});
it("should be 20,000 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.EA);
expect(value.throughput.shared).toBe(20000);
});
it("should be 5,000 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.EA);
expect(value.throughput.shared).toBe(5000);
});
});
describe("for Free subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Free);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Free);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Free);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Free);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Free);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Free);
expect(value.throughput.shared).toBe(400);
});
});
describe("for Internal subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.Internal);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.Internal);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.Internal);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.Internal);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.Internal);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.Internal);
expect(value.throughput.shared).toBe(400);
});
});
describe("for PAYG subscriptions", () => {
it("should be 400 in flight '0'", () => {
const value: CollectionDefaults = Utilities._getDefaults("0", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("1", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("2", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '3'", () => {
const value: CollectionDefaults = Utilities._getDefaults("3", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '20190618.1'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.1", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.shared).toBe(400);
});
it("should be 400 in flight '20190618.2'", () => {
const value: CollectionDefaults = Utilities._getDefaults("20190618.2", ViewModels.SubscriptionType.PAYG);
expect(value.throughput.shared).toBe(400);
});
});
});
});
});

View File

@@ -11,7 +11,6 @@ import { MessageHandler } from "../Common/MessageHandler";
import { MessageTypes } from "../Contracts/ExplorerContracts";
import { NotificationConsoleUtils } from "../Utils/NotificationConsoleUtils";
import { ResourceProviderClient } from "../ResourceProvider/ResourceProviderClient";
import { SubscriptionType } from "../Contracts/ViewModels";
export class CreateSqlCollectionUtilities {
public static createSqlCollection(
@@ -243,61 +242,43 @@ export class Utilities {
}
}
public static getDefaultStorage(flight: string, subscriptionType: SubscriptionType): string {
const flightDefaults: string = Utilities._getDefaults(flight, subscriptionType).storage;
return flightDefaults;
}
public static getDefaultThroughput(flight: string, subscriptionType: SubscriptionType): ThroughputDefaults {
const flightDefaults: ThroughputDefaults = Utilities._getDefaults(flight, subscriptionType).throughput;
return flightDefaults;
}
public static getMaxRUForStorageOption(
subscriptionType = SharedConstants.CollectionCreation.DefaultSubscriptionType,
flight = SharedConstants.CollectionCreation.DefaultAddCollectionDefaultFlight,
defaults: ViewModels.CollectionCreationDefaults,
storageOption: string
): number {
if (storageOption === SharedConstants.CollectionCreation.storage10Gb) {
return SharedConstants.CollectionCreation.DefaultCollectionRUs10K;
}
const defaults = Utilities._getDefaults(flight, subscriptionType);
return defaults.throughput.unlimitedmax;
}
public static getMinRUForStorageOption(
subscriptionType = SharedConstants.CollectionCreation.DefaultSubscriptionType,
flight = SharedConstants.CollectionCreation.DefaultAddCollectionDefaultFlight,
defaults: ViewModels.CollectionCreationDefaults,
storageOption: string
): number {
if (storageOption === SharedConstants.CollectionCreation.storage10Gb) {
return SharedConstants.CollectionCreation.DefaultCollectionRUs400;
}
const collectionDefaults = Utilities._getCollectionDefaults(subscriptionType, flight);
return collectionDefaults.throughput.unlimitedmin;
return defaults.throughput.unlimitedmin;
}
public static _getDefaults(flight: string, subscriptionType: SubscriptionType): CollectionDefaults {
return Utilities._getCollectionDefaults(subscriptionType, flight);
}
private static _getCollectionDefaults(
subscriptionType = SharedConstants.CollectionCreation.DefaultSubscriptionType,
flight = SharedConstants.CollectionCreation.DefaultAddCollectionDefaultFlight
): CollectionDefaults {
if (!(flight in Utilities._defaultsMap)) {
flight = SharedConstants.CollectionCreation.DefaultAddCollectionDefaultFlight;
public static getMaxThroughput(
defaults: ViewModels.CollectionCreationDefaults,
container: ViewModels.Explorer
): number {
const throughput = defaults.throughput.unlimited;
if (typeof throughput === "number") {
return throughput;
} else {
return this._exceedsThreshold(throughput.collectionThreshold, container)
? throughput.greatThanThreshold
: throughput.lessThanOrEqualToThreshold;
}
return Utilities._defaultsMap[flight][SubscriptionType[subscriptionType]];
}
private static _exceedsThreshold(container: ViewModels.Explorer): boolean {
const unlimitedThreshold: number = 5;
private static _exceedsThreshold(unlimitedThreshold: number, container: ViewModels.Explorer): boolean {
const databases = (container && container.databases && container.databases()) || [];
return _.any(
databases,
@@ -306,340 +287,9 @@ export class Utilities {
);
}
private static _defaultsMap: { [flight: string]: { [subscriptionType: string]: CollectionDefaults } } = {
"0": {
Benefits: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
Free: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
EA: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
Internal: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
PAYG: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
}
},
"1": {
Benefits: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
Free: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
EA: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
Internal: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
PAYG: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
}
},
"2": {
Benefits: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
Free: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
EA: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
Internal: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
PAYG: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
}
},
"3": {
Benefits: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
Free: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
EA: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
Internal: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
PAYG: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
}
},
"20190618.1": {
Benefits: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
Free: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
EA: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: container =>
Utilities._exceedsThreshold(container)
? SharedConstants.CollectionCreation.DefaultCollectionRUs1000
: SharedConstants.CollectionCreation.DefaultCollectionRUs10K,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs20000
}
},
Internal: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
PAYG: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
}
},
"20190618.2": {
Benefits: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
Free: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
EA: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs1000,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs5000
}
},
Internal: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs100K,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
},
PAYG: {
storage: SharedConstants.CollectionCreation.storage100Gb,
throughput: {
fixed: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimited: () => SharedConstants.CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: SharedConstants.CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: SharedConstants.CollectionCreation.DefaultCollectionRUs400,
shared: SharedConstants.CollectionCreation.DefaultCollectionRUs400
}
}
}
};
private static _getAzureTableUri(params: DataModels.CreateDatabaseAndCollectionRequest): string {
return `subscriptions/${CosmosClient.subscriptionId()}/resourceGroups/${CosmosClient.resourceGroup()}/providers/Microsoft.DocumentDB/databaseAccounts/${
CosmosClient.databaseAccount().name
}/tables/${params.collectionId}`;
}
}
export interface CollectionDefaults {
storage: string;
throughput: ThroughputDefaults;
}
export interface ThroughputDefaults {
fixed: number;
unlimited: (explorer: ViewModels.Explorer) => number;
unlimitedmax: number;
unlimitedmin: number;
shared: number;
}

View File

@@ -51,7 +51,7 @@ describe("Add Database Utitlity", () => {
resourceProviderClientPutAsyncSpy
).toHaveBeenCalledWith(
"subscriptions/a1/resourceGroups/b1/providers/Microsoft.DocumentDB/databaseAccounts/main/gremlinDatabases/a1-db",
"2020-03-01",
"2020-04-01",
{ properties: { options: { throughput: "50000" }, resource: { id: "a1-db" } } }
);
});
@@ -63,7 +63,7 @@ describe("Add Database Utitlity", () => {
resourceProviderClientPutAsyncSpy
).toHaveBeenCalledWith(
"subscriptions/a1/resourceGroups/b1/providers/Microsoft.DocumentDB/databaseAccounts/main/gremlinDatabases/a1-db",
"2020-03-01",
"2020-04-01",
{ properties: { options: { "x-ms-cosmos-offer-autopilot-tier": "1" }, resource: { id: "a1-db" } } }
);
});
@@ -85,7 +85,7 @@ describe("Add Database Utitlity", () => {
resourceProviderClientPutAsyncSpy
).toHaveBeenCalledWith(
"subscriptions/a2/resourceGroups/c1/providers/Microsoft.DocumentDB/databaseAccounts/main/gremlinDatabases/a2-db",
"2020-03-01",
"2020-04-01",
{ properties: { options: {}, resource: { id: "a2-db" } } }
);
});
@@ -111,7 +111,7 @@ describe("Add Database Utitlity", () => {
resourceProviderClientPutAsyncSpy
).toHaveBeenCalledWith(
"subscriptions/a1/resourceGroups/b1/providers/Microsoft.DocumentDB/databaseAccounts/main/sqlDatabases/a1-db",
"2020-03-01",
"2020-04-01",
{ properties: { options: { throughput: "50000" }, resource: { id: "a1-db" } } }
);
});
@@ -123,7 +123,7 @@ describe("Add Database Utitlity", () => {
resourceProviderClientPutAsyncSpy
).toHaveBeenCalledWith(
"subscriptions/a1/resourceGroups/b1/providers/Microsoft.DocumentDB/databaseAccounts/main/sqlDatabases/a1-db",
"2020-03-01",
"2020-04-01",
{ properties: { options: { "x-ms-cosmos-offer-autopilot-tier": "1" }, resource: { id: "a1-db" } } }
);
});
@@ -145,7 +145,7 @@ describe("Add Database Utitlity", () => {
resourceProviderClientPutAsyncSpy
).toHaveBeenCalledWith(
"subscriptions/a2/resourceGroups/c1/providers/Microsoft.DocumentDB/databaseAccounts/main/sqlDatabases/a2-db",
"2020-03-01",
"2020-04-01",
{ properties: { options: {}, resource: { id: "a2-db" } } }
);
});

View File

@@ -183,6 +183,17 @@ export class CollectionCreation {
public static readonly TablesAPIDefaultDatabase: string = "TablesDB";
}
export const CollectionCreationDefaults = {
storage: CollectionCreation.storage100Gb,
throughput: {
fixed: CollectionCreation.DefaultCollectionRUs400,
unlimited: CollectionCreation.DefaultCollectionRUs400,
unlimitedmax: CollectionCreation.DefaultCollectionRUs1Million,
unlimitedmin: CollectionCreation.DefaultCollectionRUs400,
shared: CollectionCreation.DefaultCollectionRUs400
}
} as const;
export class IndexingPolicies {
public static SharedDatabaseDefault = {
indexingMode: "consistent",

View File

@@ -1,6 +1,8 @@
import { Action, ActionModifiers } from "./TelemetryConstants";
import { MessageHandler } from "../../Common/MessageHandler";
import { MessageTypes } from "../../Contracts/ExplorerContracts";
import { appInsights } from "../appInsights";
import { config } from "../../Config";
/**
* Class that persists telemetry data to the portal tables.
@@ -18,11 +20,7 @@ export default class TelemetryProcessor {
}
});
const appInsights: Microsoft.ApplicationInsights.IAppInsights = (<any>window).appInsights;
if (!appInsights) {
return;
}
appInsights.trackEvent(Action[action], data);
appInsights.trackEvent({ name: Action[action] }, TelemetryProcessor.getData(data));
}
public static traceStart(action: Action, data?: any): number {
@@ -37,10 +35,7 @@ export default class TelemetryProcessor {
}
});
const appInsights: Microsoft.ApplicationInsights.IAppInsights = (<any>window).appInsights;
if (appInsights) {
appInsights.startTrackEvent(Action[action]);
}
appInsights.startTrackEvent(Action[action]);
return timestamp;
}
@@ -55,11 +50,7 @@ export default class TelemetryProcessor {
}
});
const appInsights: Microsoft.ApplicationInsights.IAppInsights = (<any>window).appInsights;
if (!appInsights) {
return;
}
appInsights.stopTrackEvent(Action[action], data);
appInsights.stopTrackEvent(Action[action], TelemetryProcessor.getData(data));
}
public static traceFailure(action: Action, data?: any, timestamp?: number): void {
@@ -73,11 +64,7 @@ export default class TelemetryProcessor {
}
});
const appInsights: Microsoft.ApplicationInsights.IAppInsights = (<any>window).appInsights;
if (!appInsights) {
return;
}
appInsights.stopTrackEvent(Action[action], data);
appInsights.stopTrackEvent(Action[action], TelemetryProcessor.getData(data));
}
public static traceCancel(action: Action, data?: any, timestamp?: number): void {
@@ -91,11 +78,7 @@ export default class TelemetryProcessor {
}
});
const appInsights: Microsoft.ApplicationInsights.IAppInsights = (<any>window).appInsights;
if (!appInsights) {
return;
}
appInsights.stopTrackEvent(Action[action], data);
appInsights.stopTrackEvent(Action[action], TelemetryProcessor.getData(data));
}
public static traceOpen(action: Action, data?: any, timestamp?: number): number {
@@ -109,10 +92,7 @@ export default class TelemetryProcessor {
}
});
const appInsights: Microsoft.ApplicationInsights.IAppInsights = (<any>window).appInsights;
if (appInsights) {
appInsights.startTrackEvent(Action[action]);
}
appInsights.startTrackEvent(Action[action]);
return timestamp;
}
@@ -127,10 +107,14 @@ export default class TelemetryProcessor {
}
});
const appInsights: Microsoft.ApplicationInsights.IAppInsights = (<any>window).appInsights;
if (appInsights) {
appInsights.startTrackEvent(Action[action]);
}
appInsights.startTrackEvent(Action[action]);
return timestamp;
}
private static getData(data?: any): any {
return {
platform: config.platform,
...(data ? data : [])
};
}
}