From be847e755f144e13a9e7ae74358e051dd2deb920 Mon Sep 17 00:00:00 2001
From: Alexey Protsenko <a.protsenko@picodata.io>
Date: Mon, 8 Apr 2024 14:04:07 +0300
Subject: [PATCH] ci: add downstream pipeline for stress tests

Add stage to run stress tests in downstream pipeline for each commit
---
 .gitlab-ci.yml | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b0f3b697cb..3350986f68 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -3,6 +3,7 @@ stages:
   - test
   - pack
   - docker
+  - stress-test
 
 workflow:
   # See https://docs.gitlab.com/ee/ci/jobs/job_control.html#avoid-duplicate-pipelines
@@ -428,3 +429,33 @@ deploy-docker:
         docker --config $CI_PROJECT_DIR/.docker push ${REGISTRY}/${image}:${BASE_IMAGE_LATEST}
         ci-log-section end "deploy-docker-${image}"
       done
+
+# Stages of independent stress testing in downstream pipeline
+
+# We cannot move artefacts to the downstream pipeline, so we need to build and upload them to our repo
+upload-picodata-to-binary:
+  stage: stress-test
+  tags:
+    - picodata-docker
+  image:
+    name: ${BASE_IMAGE}:${BASE_IMAGE_LATEST}
+  variables:
+    VER: $CI_COMMIT_SHORT_SHA
+    GIT_DEPTH: 100
+    GIT_SUBMODULE_STRATEGY: recursive
+  script:
+    - cargo build --locked --release --features webui
+    - mv target/release/picodata target/release/picodata-$VER
+    - curl -v --upload-file target/release/picodata-$VER $RAW_NT_REGISTRY
+
+downstream-stress-test:
+# See https://docs.gitlab.com/ee/ci/pipelines/downstream_pipelines.html
+  stage: stress-test
+  trigger:
+    project: picodata/devops/proxmox/sbroad-nt
+    branch: main
+    strategy: depend
+  variables:
+    VER: $CI_COMMIT_SHORT_SHA
+  needs:
+    - job: upload-picodata-to-binary
-- 
GitLab