Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 2 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"grids": "WorldCRS84",
"upscaleTiles": 18,
"directoryLayout": "tms",
"gpkgExt": ".gpkg"
"gpkgExt": ".gpkg",
"useHttpGet": true
}
},
"FS": {
Expand Down
3 changes: 2 additions & 1 deletion config/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"grids": "epsg4326dir",
"upscale_tiles": 18,
"type": "s3",
"directory_layout": "tms"
"directory_layout": "tms",
"useHttpGet": true
}
},
"redis": {
Expand Down
1 change: 1 addition & 0 deletions helm/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
11 changes: 6 additions & 5 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand All @@ -111,6 +110,7 @@ env:
grids: WorldCRS84
upscaleTiles: 18
directoryLayout: tms
useHttpGet: true

resources:
enabled: true
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/common/cacheProviders/S3Source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/common/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface IMapProxyConfig {
upscaleTiles: number;
directoryLayout: string;
gpkgExt: string;
useHttpGet: boolean;
};
}

Expand Down Expand Up @@ -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 {
Expand Down
42 changes: 41 additions & 1 deletion tests/unit/layers/models/layersManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<IMapProxyConfig>('mapproxy'),
cache: { ...config.get<IMapProxyConfig>('mapproxy').cache, useHttpGet: true },
};
container.register(SERVICES.MAPPROXY, { useValue: mapproxyConfigWithHttpGet });
const redisConfig = container.resolve<IRedisConfig>(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<IMapProxyConfig>('mapproxy'),
cache: { ...config.get<IMapProxyConfig>('mapproxy').cache, useHttpGet: false },
};
container.register(SERVICES.MAPPROXY, { useValue: mapproxyConfigWithoutHttpGet });
const redisConfig = container.resolve<IRedisConfig>(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', () => {
Expand Down Expand Up @@ -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
Expand Down
Loading