diff --git a/config/custom-environment-variables.json b/config/custom-environment-variables.json index 3ddf2921..70f22b4a 100644 --- a/config/custom-environment-variables.json +++ b/config/custom-environment-variables.json @@ -47,7 +47,11 @@ "__name": "MAPPROXY_CACHE_UPSCALE_TILES", "__format": "number" }, - "directoryLayout": "MAPPROXY_CACHE_DIRECTORY_LAYOUT" + "directoryLayout": "MAPPROXY_CACHE_DIRECTORY_LAYOUT", + "useHttpGet": { + "__name": "MAPPROXY_CACHE_USE_HTTP_GET", + "__format": "boolean" + } } }, "FS": { diff --git a/config/default.json b/config/default.json index 68046446..ec447885 100644 --- a/config/default.json +++ b/config/default.json @@ -31,7 +31,8 @@ "grids": "WorldCRS84", "upscaleTiles": 18, "directoryLayout": "tms", - "gpkgExt": ".gpkg" + "gpkgExt": ".gpkg", + "useHttpGet": true } }, "FS": { diff --git a/config/test.json b/config/test.json index c37c6976..f56a6b80 100644 --- a/config/test.json +++ b/config/test.json @@ -17,7 +17,8 @@ "grids": "epsg4326dir", "upscale_tiles": 18, "type": "s3", - "directory_layout": "tms" + "directory_layout": "tms", + "useHttpGet": true } }, "redis": { diff --git a/helm/templates/configmap.yaml b/helm/templates/configmap.yaml index 9a51e36a..ca7a2fae 100644 --- a/helm/templates/configmap.yaml +++ b/helm/templates/configmap.yaml @@ -27,6 +27,7 @@ data: MAPPROXY_CACHE_GRIDS: {{ quote .Values.env.mapproxyCache.grids }} MAPPROXY_CACHE_UPSCALE_TILES: {{ quote .Values.env.mapproxyCache.upscaleTiles }} MAPPROXY_CACHE_DIRECTORY_LAYOUT: {{ quote .Values.env.mapproxyCache.directoryLayout }} + MAPPROXY_CACHE_USE_HTTP_GET: {{ .Values.env.mapproxyCache.useHttpGet | quote }} REDIS_ENABLED: {{ quote $redis.enabled }} {{ if $redis.enabled }} REDIS_HOST: {{ quote $redis.host }} diff --git a/helm/values.yaml b/helm/values.yaml index cb19db1c..137c1472 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -91,10 +91,9 @@ metrics: tracing: enabled: false url: '' - -# add pod annotations -# example: -# podAnnotations: + # add pod annotations + # example: + # podAnnotations: # annotation1: annotation-value-1 # annotation2: annotation-value-2 podAnnotations: {} @@ -111,6 +110,7 @@ env: grids: WorldCRS84 upscaleTiles: 18 directoryLayout: tms + useHttpGet: true resources: enabled: true @@ -153,7 +153,8 @@ ingress: origin: '*' annotations: {} -local: # for local stand alone deployment, external pvc and secrets should be used for full deployment +local: + # for local stand alone deployment, external pvc and secrets should be used for full deployment fs: createComponents: false storageClass: hostPath diff --git a/src/common/cacheProviders/S3Source.ts b/src/common/cacheProviders/S3Source.ts index a533e588..f4d452b5 100644 --- a/src/common/cacheProviders/S3Source.ts +++ b/src/common/cacheProviders/S3Source.ts @@ -18,6 +18,7 @@ class S3Source implements ICacheProvider { type: sourceCacheType, directory: adjustTilesPath(sourcePath, sourceCacheType), directory_layout: this.mapproxyConfig.cache.directoryLayout, + use_http_get: this.mapproxyConfig.cache.useHttpGet, }; return s3Source; diff --git a/src/common/interfaces.ts b/src/common/interfaces.ts index 393b1097..776dde0b 100644 --- a/src/common/interfaces.ts +++ b/src/common/interfaces.ts @@ -48,6 +48,7 @@ export interface IMapProxyConfig { upscaleTiles: number; directoryLayout: string; gpkgExt: string; + useHttpGet: boolean; }; } @@ -107,6 +108,7 @@ export interface ICacheSource { export interface IS3Source extends ICacheSource { directory: string; directory_layout: string; + use_http_get?: boolean; } export interface IRedisSource extends ICacheSource { diff --git a/tests/unit/layers/models/layersManager.spec.ts b/tests/unit/layers/models/layersManager.spec.ts index b6d70074..1a5666c4 100644 --- a/tests/unit/layers/models/layersManager.spec.ts +++ b/tests/unit/layers/models/layersManager.spec.ts @@ -207,6 +207,46 @@ describe('layersManager', () => { // expectation await expect(action).rejects.toThrow(BadRequestError); }); + + it('should successfully add layer with use_http_get set to true', async () => { + const mapproxyConfigWithHttpGet: IMapProxyConfig = { + ...config.get('mapproxy'), + cache: { ...config.get('mapproxy').cache, useHttpGet: true }, + }; + container.register(SERVICES.MAPPROXY, { useValue: mapproxyConfigWithHttpGet }); + const redisConfig = container.resolve(SERVICES.REDISCONFIG); + configManager = new ConfigsManager(logger, mapproxyConfigWithHttpGet, MockConfigProvider, tracerMock); + layersManager = new LayersManager(logger, mapproxyConfigWithHttpGet, redisConfig, MockConfigProvider, tracerMock, configManager); + jest.spyOn(configManager, 'getConfig').mockResolvedValue(mockData()); + + expect.assertions(3); + await expect(layersManager.addLayer(mockLayerNameIsNotExists)).toResolve(); + + const resultJson = await MockConfigProvider.getJson(); + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + expect(resultJson.caches[mockLayerNameIsNotExists.name].cache.use_http_get).toBe(true); + expect(updateJsonMock).toHaveBeenCalledTimes(1); + }); + + it('should successfully add layer with use_http_get set to false', async () => { + const mapproxyConfigWithoutHttpGet: IMapProxyConfig = { + ...config.get('mapproxy'), + cache: { ...config.get('mapproxy').cache, useHttpGet: false }, + }; + container.register(SERVICES.MAPPROXY, { useValue: mapproxyConfigWithoutHttpGet }); + const redisConfig = container.resolve(SERVICES.REDISCONFIG); + configManager = new ConfigsManager(logger, mapproxyConfigWithoutHttpGet, MockConfigProvider, tracerMock); + layersManager = new LayersManager(logger, mapproxyConfigWithoutHttpGet, redisConfig, MockConfigProvider, tracerMock, configManager); + jest.spyOn(configManager, 'getConfig').mockResolvedValue(mockData()); + + expect.assertions(3); + await expect(layersManager.addLayer(mockLayerNameIsNotExists)).toResolve(); + + const resultJson = await MockConfigProvider.getJson(); + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + expect(resultJson.caches[mockLayerNameIsNotExists.name].cache.use_http_get).toBe(false); + expect(updateJsonMock).toHaveBeenCalledTimes(1); + }); }); describe('#removeLayer', () => { @@ -367,7 +407,7 @@ describe('layersManager', () => { it('should provide s3 cache as source', () => { const cacheType = 's3'; // eslint-disable-next-line @typescript-eslint/naming-convention - const expectedResult = { type: cacheType, directory: mockTilesPath, directory_layout: directoryLayout }; + const expectedResult = { type: cacheType, directory: mockTilesPath, directory_layout: directoryLayout, use_http_get: true }; // mock jest.mock('../../../../src/common/cacheProviders/S3Source'); // action