3
3
*/
4
4
import { describe , expect , jest , test } from '@jest/globals' ;
5
5
import COS from '../index.js' ;
6
- import Beacon from '../demo/common/beacon.min' ;
7
- import ClsClient from '../demo/common/cls.min' ;
6
+ import Beacon from '../demo/common/beacon.min.js ' ;
7
+ import ClsClient from '../demo/common/cls.min.js ' ;
8
8
9
9
// config 替换成自己的桶信息
10
10
var config = {
@@ -6953,4 +6953,204 @@ group('EnableLog', function () {
6953
6953
}
6954
6954
) ;
6955
6955
} ) ;
6956
+ } ) ;
6957
+ group ( 'retry myqcloud.com' , function ( ) {
6958
+ const cos = new COS ( {
6959
+ SecretId : config . SecretId ,
6960
+ SecretKey : config . SecretKey ,
6961
+ AutoSwitchHost : false ,
6962
+ Timeout : 10000 ,
6963
+ } ) ;
6964
+ const config = {
6965
+ Bucket : 'cos-sdk-err-retry-1253960454' ,
6966
+ Region : 'ap-chengdu' ,
6967
+ } ;
6968
+ function getObject ( Key , done , expectErr ) {
6969
+ cos . getObject (
6970
+ {
6971
+ Bucket : config . Bucket ,
6972
+ Region : config . Region ,
6973
+ Key,
6974
+ } ,
6975
+ function ( err , data ) {
6976
+ const isOk = expectErr ? err : ! err ;
6977
+ console . log ( `retry ${ Key } ---res` , err ? 'err' : 'success' , isOk ) ;
6978
+ assert . ok ( isOk ) ;
6979
+ done ( ) ;
6980
+ }
6981
+ ) ;
6982
+ }
6983
+ test ( 'get 200' , function ( done ) {
6984
+ getObject ( '200' , done ) ;
6985
+ } ) ;
6986
+ test ( 'get 200r' , function ( done ) {
6987
+ getObject ( '200r' , done ) ;
6988
+ } ) ;
6989
+ test ( 'get 204' , function ( done ) {
6990
+ getObject ( '204' , done ) ;
6991
+ } ) ;
6992
+ test ( 'get 204r' , function ( done ) {
6993
+ getObject ( '204r' , done ) ;
6994
+ } ) ;
6995
+ test ( 'get 206' , function ( done ) {
6996
+ getObject ( '206' , done ) ;
6997
+ } ) ;
6998
+ test ( 'get 206r' , function ( done ) {
6999
+ getObject ( '206r' , done ) ;
7000
+ } ) ;
7001
+ test ( 'get 301' , function ( done ) {
7002
+ getObject ( '301' , done ) ;
7003
+ } ) ;
7004
+ test ( 'get 301r' , function ( done ) {
7005
+ getObject ( '301r' , done ) ;
7006
+ } ) ;
7007
+ test ( 'get 302' , function ( done ) {
7008
+ getObject ( '302' , done ) ;
7009
+ } ) ;
7010
+ test ( 'get 302r' , function ( done ) {
7011
+ getObject ( '302r' , done ) ;
7012
+ } ) ;
7013
+ test ( 'get 400' , function ( done ) {
7014
+ getObject ( '400' , done , true ) ;
7015
+ } ) ;
7016
+ test ( 'get 400r' , function ( done ) {
7017
+ getObject ( '400r' , done , true ) ;
7018
+ } ) ;
7019
+ test ( 'get 403' , function ( done ) {
7020
+ getObject ( '403' , done , true ) ;
7021
+ } ) ;
7022
+ test ( 'get 403r' , function ( done ) {
7023
+ getObject ( '403r' , done , true ) ;
7024
+ } ) ;
7025
+ test ( 'get 404' , function ( done ) {
7026
+ getObject ( '404' , done , true ) ;
7027
+ } ) ;
7028
+ test ( 'get 404r' , function ( done ) {
7029
+ getObject ( '404r' , done , true ) ;
7030
+ } ) ;
7031
+ test ( 'get 500' , function ( done ) {
7032
+ getObject ( '500' , done ) ;
7033
+ } ) ;
7034
+ test ( 'get 500r' , function ( done ) {
7035
+ getObject ( '500r' , done ) ;
7036
+ } ) ;
7037
+ test ( 'get 503' , function ( done ) {
7038
+ getObject ( '503' , done ) ;
7039
+ } ) ;
7040
+ test ( 'get 503r' , function ( done ) {
7041
+ getObject ( '503r' , done ) ;
7042
+ } ) ;
7043
+ test ( 'get 504' , function ( done ) {
7044
+ getObject ( '504' , done ) ;
7045
+ } ) ;
7046
+ test ( 'get 504r' , function ( done ) {
7047
+ getObject ( '504r' , done ) ;
7048
+ } ) ;
7049
+ test ( 'get shutdown' , function ( done ) {
7050
+ getObject ( 'shutdown' , done ) ;
7051
+ } ) ;
7052
+ test ( 'get timeout' , function ( done ) {
7053
+ getObject ( 'timeout' , done ) ;
7054
+ } ) ;
7055
+ } ) ;
7056
+
7057
+ group ( 'retry tencentcos.cn' , function ( ) {
7058
+ const cos = new COS ( {
7059
+ SecretId : config . SecretId ,
7060
+ SecretKey : config . SecretKey ,
7061
+ AutoSwitchHost : false ,
7062
+ Timeout : 10000 ,
7063
+ Domain : '{Bucket}.cos.{Region}.tencentcos.cn' ,
7064
+ } ) ;
7065
+ const config = {
7066
+ Bucket : 'cos-sdk-err-retry-1253960454' ,
7067
+ Region : 'ap-chengdu' ,
7068
+ } ;
7069
+ function getObject ( Key , done , expectErr ) {
7070
+ cos . getObject (
7071
+ {
7072
+ Bucket : config . Bucket ,
7073
+ Region : config . Region ,
7074
+ Key,
7075
+ } ,
7076
+ function ( err , data ) {
7077
+ const isOk = expectErr ? err : ! err ;
7078
+ console . log ( `retry ${ Key } ---res` , err ? 'err' : 'success' , isOk ) ;
7079
+ assert . ok ( isOk ) ;
7080
+ done ( ) ;
7081
+ }
7082
+ ) ;
7083
+ }
7084
+ test ( 'get 200' , function ( done ) {
7085
+ getObject ( '200' , done ) ;
7086
+ } ) ;
7087
+ test ( 'get 200r' , function ( done ) {
7088
+ getObject ( '200r' , done ) ;
7089
+ } ) ;
7090
+ test ( 'get 204' , function ( done ) {
7091
+ getObject ( '204' , done ) ;
7092
+ } ) ;
7093
+ test ( 'get 204r' , function ( done ) {
7094
+ getObject ( '204r' , done ) ;
7095
+ } ) ;
7096
+ test ( 'get 206' , function ( done ) {
7097
+ getObject ( '206' , done ) ;
7098
+ } ) ;
7099
+ test ( 'get 206r' , function ( done ) {
7100
+ getObject ( '206r' , done ) ;
7101
+ } ) ;
7102
+ test ( 'get 301' , function ( done ) {
7103
+ getObject ( '301' , done ) ;
7104
+ } ) ;
7105
+ test ( 'get 301r' , function ( done ) {
7106
+ getObject ( '301r' , done ) ;
7107
+ } ) ;
7108
+ test ( 'get 302' , function ( done ) {
7109
+ getObject ( '302' , done ) ;
7110
+ } ) ;
7111
+ test ( 'get 302r' , function ( done ) {
7112
+ getObject ( '302r' , done ) ;
7113
+ } ) ;
7114
+ test ( 'get 400' , function ( done ) {
7115
+ getObject ( '400' , done , true ) ;
7116
+ } ) ;
7117
+ test ( 'get 400r' , function ( done ) {
7118
+ getObject ( '400r' , done , true ) ;
7119
+ } ) ;
7120
+ test ( 'get 403' , function ( done ) {
7121
+ getObject ( '403' , done , true ) ;
7122
+ } ) ;
7123
+ test ( 'get 403r' , function ( done ) {
7124
+ getObject ( '403r' , done , true ) ;
7125
+ } ) ;
7126
+ test ( 'get 404' , function ( done ) {
7127
+ getObject ( '404' , done , true ) ;
7128
+ } ) ;
7129
+ test ( 'get 404r' , function ( done ) {
7130
+ getObject ( '404r' , done , true ) ;
7131
+ } ) ;
7132
+ test ( 'get 500' , function ( done ) {
7133
+ getObject ( '500' , done ) ;
7134
+ } ) ;
7135
+ test ( 'get 500r' , function ( done ) {
7136
+ getObject ( '500r' , done ) ;
7137
+ } ) ;
7138
+ test ( 'get 503' , function ( done ) {
7139
+ getObject ( '503' , done ) ;
7140
+ } ) ;
7141
+ test ( 'get 503r' , function ( done ) {
7142
+ getObject ( '503r' , done ) ;
7143
+ } ) ;
7144
+ test ( 'get 504' , function ( done ) {
7145
+ getObject ( '504' , done ) ;
7146
+ } ) ;
7147
+ test ( 'get 504r' , function ( done ) {
7148
+ getObject ( '504r' , done ) ;
7149
+ } ) ;
7150
+ test ( 'get shutdown' , function ( done ) {
7151
+ getObject ( 'shutdown' , done ) ;
7152
+ } ) ;
7153
+ test ( 'get timeout' , function ( done ) {
7154
+ getObject ( 'timeout' , done ) ;
7155
+ } ) ;
6956
7156
} ) ;
0 commit comments