@@ -138,17 +138,23 @@ config = {
138138 ],
139139 "skip" : False ,
140140 },
141- "davOperations " : {
141+ "davOperations1 " : {
142142 "suites" : [
143143 "apiSpacesDavOperation" ,
144- "apiArchiver" ,
145144 "apiDownloads" ,
146- "apiActivities" ,
147145 "apiAsyncUpload" ,
148146 "apiDepthInfinity" ,
149147 ],
150148 "skip" : False ,
151149 },
150+ "davOperations2" : {
151+ "suites" : [
152+ "apiArchiver" ,
153+ "apiActivities" ,
154+ ],
155+ "skip" : False ,
156+ "k3d" : True ,
157+ },
152158 "groupAndSearch1" : {
153159 "suites" : [
154160 "apiSearch1" ,
@@ -1068,6 +1074,7 @@ def localApiTestPipeline(ctx):
10681074 "collaborationServiceNeeded" : False ,
10691075 "extraCollaborationEnvironment" : {},
10701076 "withRemotePhp" : with_remote_php ,
1077+ "k3d" : False ,
10711078 }
10721079
10731080 if "localApiTests" in config :
@@ -1078,6 +1085,11 @@ def localApiTestPipeline(ctx):
10781085 params [item ] = matrix [item ] if item in matrix else defaults [item ]
10791086 for storage in params ["storages" ]:
10801087 for run_with_remote_php in params ["withRemotePhp" ]:
1088+ run_on_k3d = params ["k3d" ] and ctx .build .event == "cron"
1089+ ocis_url = OCIS_URL
1090+ if run_on_k3d :
1091+ ocis_url = "https://%s" % OCIS_SERVER_NAME
1092+
10811093 pipeline = {
10821094 "kind" : "pipeline" ,
10831095 "type" : "docker" ,
@@ -1090,18 +1102,19 @@ def localApiTestPipeline(ctx):
10901102 restoreBuildArtifactCache (ctx , "ocis-binary-amd64" , "ocis/bin" ) +
10911103 (tikaService () if params ["tikaNeeded" ] else []) +
10921104 (waitForServices ("online-offices" , ["collabora:9980" , "onlyoffice:443" , "fakeoffice:8080" ]) if params ["collaborationServiceNeeded" ] else []) +
1093- ocisServer (storage , extra_server_environment = params ["extraServerEnvironment" ], with_wrapper = True , tika_enabled = params ["tikaNeeded" ], volumes = ([stepVolumeOcisStorage ] if name . startswith ( "cli" ) else [] )) +
1105+ ( waitK3sCluster () + deployOcis () + waitForOcis ( ocis_url = ocis_url ) + ocisServicePods () if run_on_k3d else ocisServer (storage , extra_server_environment = params ["extraServerEnvironment" ], with_wrapper = True , tika_enabled = params ["tikaNeeded" ], volumes = ([stepVolumeOcisStorage ]) )) +
10941106 (waitForClamavService () if params ["antivirusNeeded" ] else []) +
10951107 (waitForEmailService () if params ["emailNeeded" ] else []) +
10961108 (ocisServer (storage , deploy_type = "federation" , extra_server_environment = params ["extraServerEnvironment" ]) if params ["federationServer" ] else []) +
10971109 ((wopiCollaborationService ("fakeoffice" ) + wopiCollaborationService ("collabora" ) + wopiCollaborationService ("onlyoffice" )) if params ["collaborationServiceNeeded" ] else []) +
10981110 (ocisHealthCheck ("wopi" , ["wopi-collabora:9304" , "wopi-onlyoffice:9304" , "wopi-fakeoffice:9304" ]) if params ["collaborationServiceNeeded" ] else []) +
1099- localApiTests (ctx , name , params ["suites" ], storage , params ["extraEnvironment" ], run_with_remote_php ) +
1111+ localApiTests (ctx , name , params ["suites" ], storage , params ["extraEnvironment" ], run_with_remote_php , ocis_url = ocis_url ) +
11001112 apiTestFailureLog () +
1101- generateCoverageFromAPITest (ctx , name ),
1113+ ( generateCoverageFromAPITest (ctx , name ) if not run_on_k3d else [] ),
11021114 "services" : (emailService () if params ["emailNeeded" ] else []) +
11031115 (clamavService () if params ["antivirusNeeded" ] else []) +
1104- ((fakeOffice () + collaboraService () + onlyofficeService ()) if params ["collaborationServiceNeeded" ] else []),
1116+ ((fakeOffice () + collaboraService () + onlyofficeService ()) if params ["collaborationServiceNeeded" ] else []) +
1117+ (k3sCluster () if run_on_k3d else []),
11051118 "depends_on" : getPipelineNames (buildOcisBinaryForTesting (ctx )),
11061119 "trigger" : {
11071120 "ref" : [
@@ -1155,12 +1168,12 @@ def generateCoverageFromAPITest(ctx, name):
11551168 },
11561169 ]
11571170
1158- def localApiTests (ctx , name , suites , storage = "ocis" , extra_environment = {}, with_remote_php = False ):
1171+ def localApiTests (ctx , name , suites , storage = "ocis" , extra_environment = {}, with_remote_php = False , ocis_url = OCIS_URL ):
11591172 test_dir = "%s/tests/acceptance" % dirs ["base" ]
11601173 expected_failures_file = "%s/expected-failures-localAPI-on-%s-storage.md" % (test_dir , storage .upper ())
11611174
11621175 environment = {
1163- "TEST_SERVER_URL" : OCIS_URL ,
1176+ "TEST_SERVER_URL" : ocis_url ,
11641177 "TEST_SERVER_FED_URL" : OCIS_FED_URL ,
11651178 "OCIS_REVA_DATA_ROOT" : "%s" % (dirs ["ocisRevaDataRoot" ] if storage == "owncloud" else "" ),
11661179 "STORAGE_DRIVER" : storage ,
@@ -2617,19 +2630,9 @@ def ocisServer(storage = "ocis", volumes = [], depends_on = [], deploy_type = ""
26172630 "%s/bin/ociswrapper serve --bin %s --url %s --admin-username admin --admin-password admin" % (dirs ["ocisWrapper" ], ocis_bin , environment ["OCIS_URL" ]),
26182631 ]
26192632
2620- wait_for_ocis = waitForServices ("ocis" , [OCIS_DOMAIN ])[0 ]
2621- if not external_idp :
2622- wait_for_ocis = {
2623- "name" : "wait-for-%s" % (container_name ),
2624- "image" : OC_CI_ALPINE ,
2625- "commands" : [
2626- # wait for ocis-server to be ready (5 minutes)
2627- "timeout 300 bash -c 'while [ $(curl -sk -uadmin:admin " +
2628- "%s/graph/v1.0/users/admin " % environment ["OCIS_URL" ] +
2629- "-w %{http_code} -o /dev/null) != 200 ]; do sleep 1; done'" ,
2630- ],
2631- "depends_on" : depends_on ,
2632- }
2633+ wait_for_ocis = waitForOcis (container_name , environment ["OCIS_URL" ], depends_on )
2634+ if external_idp :
2635+ wait_for_ocis = waitForServices ("ocis" , [OCIS_DOMAIN ])
26332636
26342637 commands = [
26352638 "mkdir -p $GOCOVERDIR" ,
@@ -2638,19 +2641,16 @@ def ocisServer(storage = "ocis", volumes = [], depends_on = [], deploy_type = ""
26382641 "cp tests/config/drone/app-registry.yaml /root/.ocis/config/app-registry.yaml" ,
26392642 ] + (build_and_run_commands )
26402643
2641- return [
2642- {
2643- "name" : container_name ,
2644- "image" : OC_CI_GOLANG ,
2645- "detach" : True ,
2646- "environment" : environment ,
2647- "user" : user ,
2648- "commands" : commands ,
2649- "volumes" : volumes ,
2650- "depends_on" : depends_on ,
2651- },
2652- wait_for_ocis ,
2653- ]
2644+ return [{
2645+ "name" : container_name ,
2646+ "image" : OC_CI_GOLANG ,
2647+ "detach" : True ,
2648+ "environment" : environment ,
2649+ "user" : user ,
2650+ "commands" : commands ,
2651+ "volumes" : volumes ,
2652+ "depends_on" : depends_on ,
2653+ }] + wait_for_ocis
26542654
26552655def startOcisService (service = None , name = None , environment = {}, volumes = []):
26562656 """
@@ -3576,6 +3576,19 @@ def k6LoadTests(ctx):
35763576 },
35773577 }]
35783578
3579+ def waitForOcis (name = "ocis" , ocis_url = OCIS_URL , depends_on = []):
3580+ return [{
3581+ "name" : "wait-for-%s" % name ,
3582+ "image" : OC_CI_ALPINE ,
3583+ "commands" : [
3584+ # wait for ocis-server to be ready (5 minutes)
3585+ "timeout 300 bash -c 'while [ $(curl -sk -uadmin:admin " +
3586+ "%s/graph/v1.0/users/admin " % ocis_url +
3587+ "-w %{http_code} -o /dev/null) != 200 ]; do sleep 1; done'" ,
3588+ ],
3589+ "depends_on" : depends_on ,
3590+ }]
3591+
35793592def waitForServices (name , services = []):
35803593 services = "," .join (services )
35813594 return [{
@@ -3754,3 +3767,82 @@ def trivyScan(ctx):
37543767 ],
37553768 },
37563769 }
3770+
3771+ def k3sCluster ():
3772+ return [{
3773+ "name" : OCIS_SERVER_NAME ,
3774+ "image" : "ghcr.io/k3d-io/k3d:5-dind" ,
3775+ "user" : "root" ,
3776+ "privileged" : True ,
3777+ "commands" : [
3778+ "git clone --single-branch --branch main --depth 1 https://github.com/owncloud/ocis-charts.git" ,
3779+ "nohup dockerd-entrypoint.sh &" ,
3780+ "until docker ps 2>&1 > /dev/null; do sleep 1s; done" ,
3781+ # create cluster
3782+ "k3d cluster create drone --api-port %s:33199 " % OCIS_SERVER_NAME +
3783+ "-p '80:80@loadbalancer' -p '443:443@loadbalancer' " +
3784+ "--k3s-arg '--tls-san=k3d@server:*' --k3s-arg '--disable=metrics-server@server:*'" ,
3785+ # wait for services to be ready
3786+ "until kubectl get deployment coredns -n kube-system -o go-template='{{.status.availableReplicas}}' | grep -v -e '<no value>'; do sleep 1s; done" ,
3787+ "until kubectl get deployment traefik -n kube-system -o go-template='{{.status.availableReplicas}}' | grep -v -e '<no value>'; do sleep 1s; done" ,
3788+ "k3d kubeconfig get drone > kubeconfig-$${DRONE_BUILD_NUMBER}.yaml" ,
3789+ "chmod 0600 kubeconfig-$${DRONE_BUILD_NUMBER}.yaml" ,
3790+ "printf '@@@@@@@@@@@@@@@@@@@@@@@\n @@@@ k3d is ready @@@@\n @@@@@@@@@@@@@@@@@@@@@@@\n '" ,
3791+ # add dns rewrite rule
3792+ "kubectl create configmap coredns-custom --namespace kube-system " +
3793+ "--from-literal='rewritehost.override=rewrite name exact %s host.k3d.internal'" % OCIS_SERVER_NAME ,
3794+ "kubectl -n kube-system rollout restart deployment coredns" ,
3795+ # watch events
3796+ "kubectl get events -Aw" ,
3797+ ],
3798+ }]
3799+
3800+ def waitK3sCluster ():
3801+ return [{
3802+ "name" : "wait-cluster" ,
3803+ "image" : "docker.io/bitnami/kubectl:1.31" ,
3804+ "user" : "root" ,
3805+ "commands" : [
3806+ "export KUBECONFIG=kubeconfig-$${DRONE_BUILD_NUMBER}.yaml" ,
3807+ "until test -f $${KUBECONFIG}; do sleep 1s; done" ,
3808+ "kubectl config view" ,
3809+ "kubectl get pods -A" ,
3810+ ],
3811+ }]
3812+
3813+ def deployOcis ():
3814+ return [{
3815+ "name" : "deploy-ocis" ,
3816+ "image" : "owncloudci/golang:latest" ,
3817+ "commands" : [
3818+ "mv %s/tests/config/drone/k3s/values.yaml %s/ocis-charts/charts/ocis/ci/deployment-values.yaml" % (dirs ["base" ], dirs ["base" ]),
3819+ "cp -r %s/tests/config/drone/k3s/authbasic %s/ocis-charts/charts/ocis/templates/" % (dirs ["base" ], dirs ["base" ]),
3820+ "cd %s/ocis-charts" % dirs ["base" ],
3821+ "sed -i '/{{- define \" ocis.basicServiceTemplates\" -}}/a\\ \\ {{- $_ := set .scope \" appNameAuthBasic\" \" authbasic\" -}}' ./charts/ocis/templates/_common/_tplvalues.tpl" ,
3822+ "sed -i '/- name: IDM_ADMIN_PASSWORD/{n;N;N;N;d;}' ./charts/ocis/templates/idm/deployment.yaml" ,
3823+ "sed -i '/- name: IDM_ADMIN_PASSWORD/a\\ \\ \\ n value: \" admin\" ' ./charts/ocis/templates/idm/deployment.yaml" ,
3824+ "sed -i '/- name: PROXY_HTTP_ADDR/i\\ \\ - name: PROXY_ENABLE_BASIC_AUTH\\ \n value: \" true\" ' ./charts/ocis/templates/proxy/deployment.yaml" ,
3825+ "export KUBECONFIG=%s/kubeconfig-$${DRONE_BUILD_NUMBER}.yaml" % dirs ["base" ],
3826+ "make helm-install-atomic" ,
3827+ ],
3828+ "volumes" : [
3829+ {
3830+ "name" : "gopath" ,
3831+ "path" : "/go" ,
3832+ },
3833+ ],
3834+ }]
3835+
3836+ def ocisServicePods ():
3837+ return [{
3838+ "name" : "ocis-pods" ,
3839+ "image" : "ghcr.io/k3d-io/k3d:5-dind" ,
3840+ "user" : "root" ,
3841+ "commands" : [
3842+ "export KUBECONFIG=kubeconfig-$${DRONE_BUILD_NUMBER}.yaml" ,
3843+ "until test -f $${KUBECONFIG}; do sleep 1s; done" ,
3844+ "kubectl get pods -A" ,
3845+ "kubectl get ingress -A" ,
3846+ "kubectl get svc -A" ,
3847+ ],
3848+ }]
0 commit comments