|
| 1 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The ASF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +import org.codehaus.groovy.runtime.IOGroovyMethods |
| 19 | + |
| 20 | +suite("test_calc_cache_file_hash") { |
| 21 | + sql """ use @regression_cluster_name1 """ |
| 22 | + def ttlProperties = """ PROPERTIES("file_cache_ttl_seconds"="180") """ |
| 23 | + String[][] backends = sql """ show backends """ |
| 24 | + String backendId; |
| 25 | + def backendIdToBackendIP = [:] |
| 26 | + def backendIdToBackendHttpPort = [:] |
| 27 | + def backendIdToBackendBrpcPort = [:] |
| 28 | + for (String[] backend in backends) { |
| 29 | + if (backend[9].equals("true") && backend[19].contains("regression_cluster_name1")) { |
| 30 | + backendIdToBackendIP.put(backend[0], backend[1]) |
| 31 | + backendIdToBackendHttpPort.put(backend[0], backend[4]) |
| 32 | + backendIdToBackendBrpcPort.put(backend[0], backend[5]) |
| 33 | + } |
| 34 | + } |
| 35 | + assertEquals(backendIdToBackendIP.size(), 1) |
| 36 | + |
| 37 | + backendId = backendIdToBackendIP.keySet()[0] |
| 38 | + def url = backendIdToBackendIP.get(backendId) + ":" + backendIdToBackendHttpPort.get(backendId) + """/api/file_cache?op=hash&value=0200000000000001bf42c14374fff491ffb7c89a1a65c5bb_0.dat""" |
| 39 | + logger.info("calc cache file hash URL:" + url) |
| 40 | + def httpAction = { check_func -> |
| 41 | + httpTest { |
| 42 | + endpoint "" |
| 43 | + uri url |
| 44 | + op "get" |
| 45 | + body "" |
| 46 | + check check_func |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + httpAction.call() { |
| 51 | + respCode, body -> { |
| 52 | + assertEquals(respCode, 200) |
| 53 | + def map = parseJson(body) |
| 54 | + assertEquals(map.get("hash"), "c6a599f453f67f0949f80ad9990fa3dd") |
| 55 | + } |
| 56 | + } |
| 57 | +} |
0 commit comments