Skip to content

Commit 1e02dfa

Browse files
authored
Use separate urls for querying and downloading of LS (microsoft#3078)
* Use separate urls for querying and downloading * Fix tests
1 parent 5a3fcc1 commit 1e02dfa

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

src/client/activation/languageServer/languageServerPackageRepository.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import { inject, injectable } from 'inversify';
77
import { AzureBlobStoreNugetRepository } from '../../common/nuget/azureBlobStoreNugetRepository';
88
import { IServiceContainer } from '../../ioc/types';
99

10-
const azureBlobStorageAccount = 'https://pvsc.azureedge.net';
10+
const azureBlobStorageAccount = 'https://pvsc.blob.core.windows.net';
11+
const azureCDNBlobStorageAccount = 'https://pvsc.azureedge.net';
1112

1213
export enum LanguageServerDownloadChannel {
1314
stable = 'stable',
@@ -24,20 +25,20 @@ export enum LanguageServerPackageStorageContainers {
2425
@injectable()
2526
export class StableLanguageServerPackageRepository extends AzureBlobStoreNugetRepository {
2627
constructor(@inject(IServiceContainer) serviceContainer: IServiceContainer) {
27-
super(serviceContainer, azureBlobStorageAccount, LanguageServerPackageStorageContainers.stable);
28+
super(serviceContainer, azureBlobStorageAccount, LanguageServerPackageStorageContainers.stable, azureCDNBlobStorageAccount);
2829
}
2930
}
3031

3132
@injectable()
3233
export class BetaLanguageServerPackageRepository extends AzureBlobStoreNugetRepository {
3334
constructor(@inject(IServiceContainer) serviceContainer: IServiceContainer) {
34-
super(serviceContainer, azureBlobStorageAccount, LanguageServerPackageStorageContainers.beta);
35+
super(serviceContainer, azureBlobStorageAccount, LanguageServerPackageStorageContainers.beta, azureCDNBlobStorageAccount);
3536
}
3637
}
3738

3839
@injectable()
3940
export class DailyLanguageServerPackageRepository extends AzureBlobStoreNugetRepository {
4041
constructor(@inject(IServiceContainer) serviceContainer: IServiceContainer) {
41-
super(serviceContainer, azureBlobStorageAccount, LanguageServerPackageStorageContainers.daily);
42+
super(serviceContainer, azureBlobStorageAccount, LanguageServerPackageStorageContainers.daily, azureCDNBlobStorageAccount);
4243
}
4344
}

src/client/common/nuget/azureBlobStoreNugetRepository.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ import { INugetRepository, INugetService, NugetPackage } from './types';
1515
export class AzureBlobStoreNugetRepository implements INugetRepository {
1616
constructor(@inject(IServiceContainer) private readonly serviceContainer: IServiceContainer,
1717
@unmanaged() protected readonly azureBlobStorageAccount: string,
18-
@unmanaged() protected readonly azureBlobStorageContainer: string) { }
18+
@unmanaged() protected readonly azureBlobStorageContainer: string,
19+
@unmanaged() protected readonly azureCDNBlobStorageAccount: string) { }
1920
public async getPackages(packageName: string): Promise<NugetPackage[]> {
20-
return this.listPackages(this.azureBlobStorageAccount, this.azureBlobStorageContainer, packageName);
21+
return this.listPackages(this.azureBlobStorageAccount, this.azureBlobStorageContainer, packageName, this.azureCDNBlobStorageAccount);
2122
}
2223

2324
@captureTelemetry(PYTHON_LANGUAGE_SERVER_LIST_BLOB_STORE_PACKAGES)
2425
@traceVerbose('Listing Nuget Packages')
25-
public listPackages(azureBlobStorageAccount: string, azureBlobStorageContainer: string, packageName: string) {
26+
protected listPackages(azureBlobStorageAccount: string, azureBlobStorageContainer: string, packageName: string, azureCDNBlobStorageAccount: string) {
2627
// tslint:disable-next-line:no-require-imports
2728
const az = require('azure-storage') as typeof azStorageTypes;
2829
const blobStore = az.createBlobServiceAnonymous(azureBlobStorageAccount);
@@ -39,7 +40,7 @@ export class AzureBlobStoreNugetRepository implements INugetRepository {
3940
resolve(result.entries.map(item => {
4041
return {
4142
package: item.name,
42-
uri: `${azureBlobStorageAccount}/${azureBlobStorageContainer}/${item.name}`,
43+
uri: `${azureCDNBlobStorageAccount}/${azureBlobStorageContainer}/${item.name}`,
4344
version: nugetService.getVersionFromPackageFileName(item.name)
4445
};
4546
}));

src/test/activation/languageServer/languageServerPackageRepository.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ suite('Language Server Download Channels', () => {
3535
}
3636
const instance = new class extends classToCreate {
3737
constructor() { super(serviceContainer.object); }
38-
public get storageAccount() { return this.azureBlobStorageAccount; }
38+
public get storageAccount() { return this.azureCDNBlobStorageAccount; }
3939
public get storageContainer() { return this.azureBlobStorageContainer; }
4040
}();
4141

src/test/activation/languageServer/languageServerPackageService.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import { PlatformService } from '../../../client/common/platform/platformService
2121
import { IPlatformService } from '../../../client/common/platform/types';
2222
import { IServiceContainer } from '../../../client/ioc/types';
2323

24+
const azureBlobStorageAccount = 'https://pvsc.blob.core.windows.net';
25+
const azureCDNBlobStorageAccount = 'https://pvsc.azureedge.net';
26+
2427
suite('Language Server Package Service', () => {
2528
let serviceContainer: typeMoq.IMock<IServiceContainer>;
2629
setup(() => {
@@ -76,7 +79,7 @@ suite('Language Server Package Service', () => {
7679
const platformService = new PlatformService();
7780
serviceContainer.setup(c => c.get(typeMoq.It.isValue(IPlatformService))).returns(() => platformService);
7881
const defaultStorageChannel = LanguageServerPackageStorageContainers.stable;
79-
const nugetRepo = new AzureBlobStoreNugetRepository(serviceContainer.object, 'https://pvsc.azureedge.net', defaultStorageChannel);
82+
const nugetRepo = new AzureBlobStoreNugetRepository(serviceContainer.object, azureBlobStorageAccount, defaultStorageChannel, azureCDNBlobStorageAccount);
8083
serviceContainer.setup(c => c.get(typeMoq.It.isValue(INugetRepository))).returns(() => nugetRepo);
8184
const lsPackageService = new LanguageServerPackageService(serviceContainer.object);
8285
const packageName = lsPackageService.getNugetPackageName();

src/test/common/nuget/azureBobStoreRepository.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import { PlatformService } from '../../../client/common/platform/platformService
1515
import { IPlatformService } from '../../../client/common/platform/types';
1616
import { IServiceContainer } from '../../../client/ioc/types';
1717

18+
const azureBlobStorageAccount = 'https://pvsc.blob.core.windows.net';
19+
const azureCDNBlobStorageAccount = 'https://pvsc.azureedge.net';
20+
1821
suite('Nuget Azure Storage Repository', () => {
1922
let serviceContainer: typeMoq.IMock<IServiceContainer>;
2023
let httpClient: typeMoq.IMock<IHttpClient>;
@@ -29,7 +32,7 @@ suite('Nuget Azure Storage Repository', () => {
2932
serviceContainer.setup(c => c.get(typeMoq.It.isValue(INugetService))).returns(() => nugetService.object);
3033
const defaultStorageChannel = LanguageServerPackageStorageContainers.stable;
3134

32-
repo = new AzureBlobStoreNugetRepository(serviceContainer.object, 'https://pvsc.azureedge.net', defaultStorageChannel);
35+
repo = new AzureBlobStoreNugetRepository(serviceContainer.object, azureBlobStorageAccount, defaultStorageChannel, azureCDNBlobStorageAccount);
3336
});
3437

3538
test('Get all packages', async function () {

0 commit comments

Comments
 (0)