|
| 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 | + |
| 19 | +import org.awaitility.Awaitility |
| 20 | + |
| 21 | +import static java.util.concurrent.TimeUnit.SECONDS |
| 22 | + |
| 23 | +// Verify that when fetchRemoteMeta receives a failed GlobListResult (e.g. S3 auth error), |
| 24 | +// the streaming job is correctly PAUSED rather than hanging indefinitely. |
| 25 | +suite("test_streaming_insert_job_fetch_meta_error", "nonConcurrent") { |
| 26 | + def tableName = "test_streaming_insert_job_fetch_meta_error_tbl" |
| 27 | + def jobName = "test_streaming_insert_job_fetch_meta_error_job" |
| 28 | + |
| 29 | + sql """drop table if exists `${tableName}` force""" |
| 30 | + sql """ |
| 31 | + DROP JOB IF EXISTS where jobname = '${jobName}' |
| 32 | + """ |
| 33 | + |
| 34 | + sql """ |
| 35 | + CREATE TABLE IF NOT EXISTS ${tableName} ( |
| 36 | + `c1` int NULL, |
| 37 | + `c2` string NULL, |
| 38 | + `c3` int NULL, |
| 39 | + ) ENGINE=OLAP |
| 40 | + DUPLICATE KEY(`c1`) |
| 41 | + COMMENT 'OLAP' |
| 42 | + DISTRIBUTED BY HASH(`c1`) BUCKETS 3 |
| 43 | + PROPERTIES ("replication_allocation" = "tag.location.default: 1"); |
| 44 | + """ |
| 45 | + |
| 46 | + GetDebugPoint().enableDebugPointForAllFEs("S3SourceOffsetProvider.fetchRemoteMeta.error") |
| 47 | + try { |
| 48 | + sql """ |
| 49 | + CREATE JOB ${jobName} |
| 50 | + ON STREAMING DO INSERT INTO ${tableName} |
| 51 | + SELECT * FROM S3 |
| 52 | + ( |
| 53 | + "uri" = "s3://${s3BucketName}/regression/load/data/example_[0-1].csv", |
| 54 | + "format" = "csv", |
| 55 | + "provider" = "${getS3Provider()}", |
| 56 | + "column_separator" = ",", |
| 57 | + "s3.endpoint" = "${getS3Endpoint()}", |
| 58 | + "s3.region" = "${getS3Region()}", |
| 59 | + "s3.access_key" = "${getS3AK()}", |
| 60 | + "s3.secret_key" = "${getS3SK()}" |
| 61 | + ); |
| 62 | + """ |
| 63 | + |
| 64 | + try { |
| 65 | + Awaitility.await().atMost(120, SECONDS) |
| 66 | + .pollInterval(2, SECONDS).until( |
| 67 | + { |
| 68 | + def jobRes = sql """ select Status from jobs("type"="insert") where Name = '${jobName}' and ExecuteType='STREAMING' """ |
| 69 | + log.info("jobRes: " + jobRes) |
| 70 | + jobRes.size() == 1 && 'PAUSED'.equals(jobRes.get(0).get(0)) |
| 71 | + } |
| 72 | + ) |
| 73 | + } catch (Exception ex) { |
| 74 | + def showjob = sql """select * from jobs("type"="insert") where Name='${jobName}'""" |
| 75 | + def showtask = sql """select * from tasks("type"="insert") where JobName='${jobName}'""" |
| 76 | + log.info("show job: " + showjob) |
| 77 | + log.info("show task: " + showtask) |
| 78 | + throw ex |
| 79 | + } |
| 80 | + |
| 81 | + def jobStatus = sql """select Status, ErrorMsg from jobs("type"="insert") where Name='${jobName}'""" |
| 82 | + assert jobStatus.get(0).get(0) == "PAUSED" |
| 83 | + assert jobStatus.get(0).get(1).contains("Failed to list S3 files") |
| 84 | + |
| 85 | + sql """ |
| 86 | + DROP JOB IF EXISTS where jobname = '${jobName}' |
| 87 | + """ |
| 88 | + |
| 89 | + def jobCountRsp = sql """select count(1) from jobs("type"="insert") where Name='${jobName}'""" |
| 90 | + assert jobCountRsp.get(0).get(0) == 0 |
| 91 | + |
| 92 | + } finally { |
| 93 | + GetDebugPoint().disableDebugPointForAllFEs("S3SourceOffsetProvider.fetchRemoteMeta.error") |
| 94 | + sql """DROP JOB IF EXISTS where jobname = '${jobName}'""" |
| 95 | + } |
| 96 | +} |
0 commit comments