mirror of
https://github.com/owncloud/ocis
synced 2026-04-25 17:25:21 +02:00
test: run tests on kubernetes with ociswrapper
This commit is contained in:
85
.drone.star
85
.drone.star
@@ -99,6 +99,7 @@ config = {
|
||||
"apiLocks",
|
||||
],
|
||||
"skip": False,
|
||||
"k8s": True,
|
||||
},
|
||||
"settingsAndNotification": {
|
||||
"suites": [
|
||||
@@ -127,6 +128,7 @@ config = {
|
||||
"apiGraphUser",
|
||||
],
|
||||
"skip": False,
|
||||
"k8s": True,
|
||||
"withRemotePhp": [True],
|
||||
},
|
||||
"spaces": {
|
||||
@@ -134,29 +136,26 @@ config = {
|
||||
"apiSpaces",
|
||||
],
|
||||
"skip": False,
|
||||
"k8s": True,
|
||||
},
|
||||
"spacesShares": {
|
||||
"suites": [
|
||||
"apiSpacesShares",
|
||||
],
|
||||
"skip": False,
|
||||
"k8s": True,
|
||||
},
|
||||
"davOperations1": {
|
||||
"davOperations": {
|
||||
"suites": [
|
||||
"apiSpacesDavOperation",
|
||||
"apiDownloads",
|
||||
"apiAsyncUpload",
|
||||
"apiDepthInfinity",
|
||||
],
|
||||
"skip": False,
|
||||
},
|
||||
"davOperations2": {
|
||||
"suites": [
|
||||
"apiArchiver",
|
||||
"apiActivities",
|
||||
],
|
||||
"skip": False,
|
||||
"k3d": True,
|
||||
"k8s": True,
|
||||
},
|
||||
"groupAndSearch1": {
|
||||
"suites": [
|
||||
@@ -166,6 +165,7 @@ config = {
|
||||
"apiServiceAvailability",
|
||||
],
|
||||
"skip": False,
|
||||
"k8s": False,
|
||||
},
|
||||
"search2": {
|
||||
"suites": [
|
||||
@@ -174,6 +174,7 @@ config = {
|
||||
],
|
||||
"tikaNeeded": True,
|
||||
"skip": False,
|
||||
"k8s": False,
|
||||
},
|
||||
"sharingNg1": {
|
||||
"suites": [
|
||||
@@ -182,6 +183,7 @@ config = {
|
||||
"apiSharingNgPermissions",
|
||||
],
|
||||
"skip": False,
|
||||
"k8s": True,
|
||||
"withRemotePhp": [True],
|
||||
},
|
||||
"sharingNgAdditionalShareRole": {
|
||||
@@ -189,6 +191,7 @@ config = {
|
||||
"apiSharingNgAdditionalShareRole",
|
||||
],
|
||||
"skip": False,
|
||||
"k8s": True,
|
||||
"withRemotePhp": [True],
|
||||
},
|
||||
"sharingNgShareInvitation": {
|
||||
@@ -1073,7 +1076,7 @@ def localApiTestPipeline(ctx):
|
||||
"collaborationServiceNeeded": False,
|
||||
"extraCollaborationEnvironment": {},
|
||||
"withRemotePhp": with_remote_php,
|
||||
"k3d": False,
|
||||
"k8s": False,
|
||||
}
|
||||
|
||||
if "localApiTests" in config:
|
||||
@@ -1084,9 +1087,9 @@ def localApiTestPipeline(ctx):
|
||||
params[item] = matrix[item] if item in matrix else defaults[item]
|
||||
for storage in params["storages"]:
|
||||
for run_with_remote_php in params["withRemotePhp"]:
|
||||
run_on_k3d = params["k3d"] and ctx.build.event == "cron"
|
||||
run_on_k8s = params["k8s"] and ctx.build.event == "cron"
|
||||
ocis_url = OCIS_URL
|
||||
if run_on_k3d:
|
||||
if run_on_k8s:
|
||||
ocis_url = "https://%s" % OCIS_SERVER_NAME
|
||||
|
||||
pipeline = {
|
||||
@@ -1101,19 +1104,19 @@ def localApiTestPipeline(ctx):
|
||||
restoreBuildArtifactCache(ctx, "ocis-binary-amd64", "ocis/bin") +
|
||||
(tikaService() if params["tikaNeeded"] else []) +
|
||||
(waitForServices("online-offices", ["collabora:9980", "onlyoffice:443", "fakeoffice:8080"]) if params["collaborationServiceNeeded"] else []) +
|
||||
(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]))) +
|
||||
(waitK3sCluster() + deployOcis() + waitForOcis(ocis_url = ocis_url) + ociswrapper() + waitForOciswrapper() if run_on_k8s else ocisServer(storage, extra_server_environment = params["extraServerEnvironment"], with_wrapper = True, tika_enabled = params["tikaNeeded"], volumes = ([stepVolumeOcisStorage]))) +
|
||||
(waitForClamavService() if params["antivirusNeeded"] else []) +
|
||||
(waitForEmailService() if params["emailNeeded"] else []) +
|
||||
(ocisServer(storage, deploy_type = "federation", extra_server_environment = params["extraServerEnvironment"]) if params["federationServer"] else []) +
|
||||
((wopiCollaborationService("fakeoffice") + wopiCollaborationService("collabora") + wopiCollaborationService("onlyoffice")) if params["collaborationServiceNeeded"] else []) +
|
||||
(ocisHealthCheck("wopi", ["wopi-collabora:9304", "wopi-onlyoffice:9304", "wopi-fakeoffice:9304"]) if params["collaborationServiceNeeded"] else []) +
|
||||
localApiTests(ctx, name, params["suites"], storage, params["extraEnvironment"], run_with_remote_php, ocis_url = ocis_url) +
|
||||
localApiTests(name, params["suites"], storage, params["extraEnvironment"], run_with_remote_php, ocis_url = ocis_url, k8s = run_on_k8s) +
|
||||
apiTestFailureLog() +
|
||||
(generateCoverageFromAPITest(ctx, name) if not run_on_k3d else []),
|
||||
(generateCoverageFromAPITest(ctx, name) if not run_on_k8s else []),
|
||||
"services": (emailService() if params["emailNeeded"] else []) +
|
||||
(clamavService() if params["antivirusNeeded"] else []) +
|
||||
((fakeOffice() + collaboraService() + onlyofficeService()) if params["collaborationServiceNeeded"] else []) +
|
||||
(k3sCluster() if run_on_k3d else []),
|
||||
(k3sCluster() if run_on_k8s else []),
|
||||
"depends_on": getPipelineNames(buildOcisBinaryForTesting(ctx)),
|
||||
"trigger": {
|
||||
"ref": [
|
||||
@@ -1167,7 +1170,7 @@ def generateCoverageFromAPITest(ctx, name):
|
||||
},
|
||||
]
|
||||
|
||||
def localApiTests(ctx, name, suites, storage = "ocis", extra_environment = {}, with_remote_php = False, ocis_url = OCIS_URL):
|
||||
def localApiTests(name, suites, storage = "ocis", extra_environment = {}, with_remote_php = False, ocis_url = OCIS_URL, k8s = False):
|
||||
test_dir = "%s/tests/acceptance" % dirs["base"]
|
||||
expected_failures_file = "%s/expected-failures-localAPI-on-%s-storage.md" % (test_dir, storage.upper())
|
||||
|
||||
@@ -1180,9 +1183,10 @@ def localApiTests(ctx, name, suites, storage = "ocis", extra_environment = {}, w
|
||||
"BEHAT_FILTER_TAGS": "~@skip&&~@skipOnGraph&&~@skipOnOcis-%s-Storage" % ("OC" if storage == "owncloud" else "OCIS"),
|
||||
"EXPECTED_FAILURES_FILE": expected_failures_file,
|
||||
"UPLOAD_DELETE_WAIT_TIME": "1" if storage == "owncloud" else 0,
|
||||
"OCIS_WRAPPER_URL": "http://%s:5200" % OCIS_SERVER_NAME,
|
||||
"OCIS_WRAPPER_URL": "http://ociswrapper:5200" if k8s else "http://%s:5200" % OCIS_SERVER_NAME,
|
||||
"WITH_REMOTE_PHP": with_remote_php,
|
||||
"COLLABORATION_SERVICE_URL": "http://wopi-fakeoffice:9300",
|
||||
"K8S": k8s,
|
||||
}
|
||||
|
||||
for item in extra_environment:
|
||||
@@ -1195,6 +1199,7 @@ def localApiTests(ctx, name, suites, storage = "ocis", extra_environment = {}, w
|
||||
"commands": [
|
||||
# merge the expected failures
|
||||
"" if with_remote_php else "cat %s/expected-failures-without-remotephp.md >> %s" % (test_dir, expected_failures_file),
|
||||
"mkdir -p /etc/ocis/",
|
||||
"make -C %s test-acceptance-api" % (dirs["base"]),
|
||||
],
|
||||
"volumes": [stepVolumeOcisStorage],
|
||||
@@ -1368,6 +1373,7 @@ def coreApiTestPipeline(ctx):
|
||||
"antivirusNeeded": False,
|
||||
"tikaNeeded": False,
|
||||
"withRemotePhp": with_remote_php,
|
||||
"k8s": False,
|
||||
}
|
||||
test_dir = "%s/tests/acceptance" % dirs["base"]
|
||||
|
||||
@@ -1383,6 +1389,10 @@ def coreApiTestPipeline(ctx):
|
||||
for run_with_remote_php in params["withRemotePhp"]:
|
||||
filter_tags = "~@skipOnGraph&&~@skipOnOcis-%s-Storage" % ("OC" if storage == "owncloud" else "OCIS")
|
||||
expected_failures_file = "%s/expected-failures-API-on-%s-storage.md" % (test_dir, storage.upper())
|
||||
run_on_k8s = params["k8s"] and ctx.build.event == "cron"
|
||||
ocis_url = OCIS_URL
|
||||
if run_on_k8s:
|
||||
ocis_url = "https://%s" % OCIS_SERVER_NAME
|
||||
pipeline = {
|
||||
"kind": "pipeline",
|
||||
"type": "docker",
|
||||
@@ -1392,22 +1402,17 @@ def coreApiTestPipeline(ctx):
|
||||
"arch": "amd64",
|
||||
},
|
||||
"steps": skipIfUnchanged(ctx, "acceptance-tests") +
|
||||
restoreBuildArtifactCache(ctx, "ocis-binary-amd64", "ocis/bin") +
|
||||
([] if run_on_k8s else restoreBuildArtifactCache(ctx, "ocis-binary-amd64", "ocis/bin")) +
|
||||
(tikaService() if params["tikaNeeded"] else []) +
|
||||
(waitForClamavService() if params["antivirusNeeded"] else []) +
|
||||
(waitForEmailService() if params["emailNeeded"] else []) +
|
||||
ocisServer(
|
||||
storage,
|
||||
extra_server_environment = params["extraServerEnvironment"],
|
||||
with_wrapper = True,
|
||||
tika_enabled = params["tikaNeeded"],
|
||||
) +
|
||||
(waitK3sCluster() + deployOcis() + waitForOcis(ocis_url = ocis_url) + ociswrapper() + waitForOciswrapper() if run_on_k8s else ocisServer(storage, extra_server_environment = params["extraServerEnvironment"], with_wrapper = True, tika_enabled = params["tikaNeeded"], volumes = ([stepVolumeOcisStorage]))) +
|
||||
[
|
||||
{
|
||||
"name": "run-api-tests",
|
||||
"image": OC_CI_PHP % DEFAULT_PHP_VERSION,
|
||||
"environment": {
|
||||
"TEST_SERVER_URL": OCIS_URL,
|
||||
"TEST_SERVER_URL": ocis_url,
|
||||
"OCIS_REVA_DATA_ROOT": "%s" % (dirs["ocisRevaDataRoot"] if storage == "owncloud" else ""),
|
||||
"STORAGE_DRIVER": storage,
|
||||
"BEHAT_FILTER_TAGS": filter_tags,
|
||||
@@ -1415,8 +1420,9 @@ def coreApiTestPipeline(ctx):
|
||||
"ACCEPTANCE_TEST_TYPE": "core-api",
|
||||
"EXPECTED_FAILURES_FILE": expected_failures_file,
|
||||
"UPLOAD_DELETE_WAIT_TIME": "1" if storage == "owncloud" else 0,
|
||||
"OCIS_WRAPPER_URL": "http://%s:5200" % OCIS_SERVER_NAME,
|
||||
"OCIS_WRAPPER_URL": "http://ociswrapper:5200" if run_on_k8s else "http://%s:5200" % OCIS_SERVER_NAME,
|
||||
"WITH_REMOTE_PHP": run_with_remote_php,
|
||||
"k8s": "true" if run_on_k8s else "false",
|
||||
},
|
||||
"commands": [
|
||||
# merge the expected failures
|
||||
@@ -1426,9 +1432,10 @@ def coreApiTestPipeline(ctx):
|
||||
},
|
||||
] +
|
||||
apiTestFailureLog() +
|
||||
generateCoverageFromAPITest(ctx, name),
|
||||
([] if run_on_k8s else generateCoverageFromAPITest(ctx, name)),
|
||||
"services": (emailService() if params["emailNeeded"] else []) +
|
||||
(clamavService() if params["antivirusNeeded"] else []),
|
||||
(clamavService() if params["antivirusNeeded"] else []) +
|
||||
(k3sCluster() if run_on_k8s else []),
|
||||
"depends_on": getPipelineNames(buildOcisBinaryForTesting(ctx)),
|
||||
"trigger": {
|
||||
"ref": [
|
||||
@@ -3795,7 +3802,7 @@ def waitK3sCluster():
|
||||
"user": "root",
|
||||
"commands": [
|
||||
"export KUBECONFIG=kubeconfig-$${DRONE_BUILD_NUMBER}.yaml",
|
||||
"until test -f $${KUBECONFIG}; do sleep 1s; done",
|
||||
"timeout 300 bash -c 'until test -f $${KUBECONFIG}; do sleep 1; done'",
|
||||
"kubectl config view",
|
||||
"kubectl get pods -A",
|
||||
],
|
||||
@@ -3806,6 +3813,7 @@ def deployOcis():
|
||||
"name": "deploy-ocis",
|
||||
"image": "owncloudci/golang:latest",
|
||||
"commands": [
|
||||
"make -C %s build" % dirs["ocisWrapper"],
|
||||
"mv %s/tests/config/drone/k3s/values.yaml %s/ocis-charts/charts/ocis/ci/deployment-values.yaml" % (dirs["base"], dirs["base"]),
|
||||
"cp -r %s/tests/config/drone/k3s/authbasic %s/ocis-charts/charts/ocis/templates/" % (dirs["base"], dirs["base"]),
|
||||
"cd %s/ocis-charts" % dirs["base"],
|
||||
@@ -3813,6 +3821,8 @@ def deployOcis():
|
||||
"sed -i '/- name: IDM_ADMIN_PASSWORD/{n;N;N;N;d;}' ./charts/ocis/templates/idm/deployment.yaml",
|
||||
"sed -i '/- name: IDM_ADMIN_PASSWORD/a\\\\\\n value: \"admin\"' ./charts/ocis/templates/idm/deployment.yaml",
|
||||
"sed -i '/- name: PROXY_HTTP_ADDR/i\\\\ - name: PROXY_ENABLE_BASIC_AUTH\\\n value: \"true\"' ./charts/ocis/templates/proxy/deployment.yaml",
|
||||
"sed -i '/- name: FRONTEND_PASSWORD_POLICY_BANNED_PASSWORDS_LIST/{N;d;}' %s/ocis-charts/charts/ocis/templates/frontend/deployment.yaml" % dirs["base"],
|
||||
"sed -i '/name: SHARING_PASSWORD_POLICY_BANNED_PASSWORDS_LIST/,+1d' %s/ocis-charts/charts/ocis/templates/sharing/deployment.yaml" % dirs["base"],
|
||||
"export KUBECONFIG=%s/kubeconfig-$${DRONE_BUILD_NUMBER}.yaml" % dirs["base"],
|
||||
"make helm-install-atomic",
|
||||
],
|
||||
@@ -3824,9 +3834,9 @@ def deployOcis():
|
||||
],
|
||||
}]
|
||||
|
||||
def ocisServicePods():
|
||||
def ociswrapper():
|
||||
return [{
|
||||
"name": "ocis-pods",
|
||||
"name": "ociswrapper",
|
||||
"image": "ghcr.io/k3d-io/k3d:5-dind",
|
||||
"user": "root",
|
||||
"commands": [
|
||||
@@ -3834,6 +3844,19 @@ def ocisServicePods():
|
||||
"until test -f $${KUBECONFIG}; do sleep 1s; done",
|
||||
"kubectl get pods -A",
|
||||
"kubectl get ingress -A",
|
||||
"kubectl get svc -A",
|
||||
"%s/bin/ociswrapper serve --url https://ocis-server --admin-username admin --admin-password admin --skip-ocis-run" % dirs["ocisWrapper"],
|
||||
],
|
||||
"detach": True,
|
||||
}]
|
||||
|
||||
def waitForOciswrapper(url = "http://ociswrapper:5200", depends_on = []):
|
||||
return [{
|
||||
"name": "wait-for-wrapper",
|
||||
"image": OC_CI_ALPINE,
|
||||
"commands": [
|
||||
"timeout 60 bash -c 'while [ $(curl -sk " +
|
||||
"%s " % url +
|
||||
"-w %{http_code} -o /dev/null) != 404 ]; do sleep 1; done'",
|
||||
],
|
||||
"depends_on": depends_on,
|
||||
}]
|
||||
|
||||
Reference in New Issue
Block a user