[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-deployment] branch master updated: checking tip money is allocate
From: |
gnunet |
Subject: |
[taler-deployment] branch master updated: checking tip money is allocated |
Date: |
Thu, 01 Jul 2021 15:02:02 +0200 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository deployment.
The following commit(s) were added to refs/heads/master by this push:
new ec3b385 checking tip money is allocated
ec3b385 is described below
commit ec3b3853b9e60567ccbba5fc76dd5a27d292b465
Author: ms <ms@taler.net>
AuthorDate: Thu Jul 1 15:01:57 2021 +0200
checking tip money is allocated
---
buildbot/check_tip_reserve.py | 87 +++++++++++++++++++++++++++++++++++++++++++
buildbot/check_tip_reserve.sh | 7 ++++
buildbot/master.cfg | 37 ++++++++++++++++++
3 files changed, 131 insertions(+)
diff --git a/buildbot/check_tip_reserve.py b/buildbot/check_tip_reserve.py
new file mode 100755
index 0000000..9fa87bd
--- /dev/null
+++ b/buildbot/check_tip_reserve.py
@@ -0,0 +1,87 @@
+#!/usr/bin/env python3
+
+"""
+This script makes sure that the merchant backend instances used by the
+test/demo environment are created.
+
+We assume that the merchant backend is running, and that the "~/activate"
+file has been sourced to provide the right environment variables.
+"""
+
+import requests
+from os import environ
+from sys import exit
+from urllib.parse import urljoin
+from taler.util.amount import Amount
+
+def expect_env(name):
+ val = environ.get(name)
+ if not val:
+ print(f"{name} not defined. Please source the ~/activate file.")
+ exit(1)
+ return val
+
+def wait_merchant_up():
+ # Check it started correctly and it is ready to serve requests.
+ checks = 10
+ url = urljoin(MERCHANT_BACKEND_BASE_URL, "/config")
+ print("Check URL: {}".format(url))
+ while checks > 0:
+
+ try:
+ resp = requests.get(url, timeout=1.5)
+ except Exception:
+ print("Merchant unreachable")
+ sleep(1)
+ checks -= 1
+ continue
+
+ if resp.status_code != 200:
+ sleep(1)
+ checks -= 1
+ continue
+
+ # Ready.
+ print("Merchant is up and running")
+ return True
+
+ if checks == 0:
+ print("Merchant is not correctly serving requests.")
+ return False
+
+
+MERCHANT_BACKEND_BASE_URL = expect_env("TALER_ENV_MERCHANT_BACKEND")
+TALER_ENV_NAME = expect_env("TALER_ENV_NAME")
+TALER_CONFIG_CURRENCY = expect_env("TALER_CONFIG_CURRENCY")
+TALER_ENV_FRONTENDS_APITOKEN = expect_env("TALER_ENV_FRONTENDS_APITOKEN")
+authorization_header = {"Authorization": f"Bearer
{TALER_ENV_FRONTENDS_APITOKEN}"}
+
+def request_tip_reserves():
+ resp = requests.get(
+ urljoin(MERCHANT_BACKEND_BASE_URL,
+ "instances/survey/private/reserves"),
+ headers = authorization_header
+ )
+
+ # Instance exists, we PATCH the auth just in case it changed.
+ if resp.status_code != 200:
+ report("merchant backend failed at providing a list of tip reserves!")
+ sys.exit(1)
+
+ reserves = resp.json().get("reserves")
+
+ if len(reserves) == 0:
+ report("merchant backend has NO tip reserves active!")
+ sys.exit(1)
+
+ total_amount = Amount.parse(reserves[0].get("committed_amount")
+ for item in reserves[1:]:
+ item_amount = Amount.parse(item.get("committed_amount"))
+ total_amount += item_amount
+
+ if total_amount.is_zero():
+ report("tip money reached zero")
+ sys.exit(1)
+
+ # FIXME, eventually, just check the largest amount left through
+ # all the reserves.
diff --git a/buildbot/check_tip_reserve.sh b/buildbot/check_tip_reserve.sh
new file mode 100755
index 0000000..06ffb83
--- /dev/null
+++ b/buildbot/check_tip_reserve.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+# Step for the BUILD_FACTORY running the 'test.taler.net' site.
+set -eu
+
+source "${HOME}/activate"
+./check_tip_reserve.py
diff --git a/buildbot/master.cfg b/buildbot/master.cfg
index 9fbf1e6..005ab7a 100644
--- a/buildbot/master.cfg
+++ b/buildbot/master.cfg
@@ -54,6 +54,23 @@ WORKERS = []
# targets. The status of each build will be pushed to these
# targets. buildbot/reporters/*.py has a variety to choose from,
# like IRC bots.
+
+tipReserveEmails = reporters.MailNotifier(
+ fromaddr="buildbot@taler.net", # to be sent to a dedicate alias
+ sendToInterestedUsers=False,
+ mode=("always"),
+ builders=("check-tips-builder"),
+ extraRecipients=["tips@taler.net"],
+ dumpMailsToLog=True, # debug, to remove
+ messageFormatter=reporters.MessageFormatter(
+ wantSteps=True,
+ wantLogs=True,
+ template="""{% for step in build['steps'] %}
+ {{ step['logs'] }}
+ {% endfor %}""", # usually one step
+ subject="tips availability on demo")
+)
+
SERVICES = []
# The 'builders' list defines the Builders, which tell Buildbot
@@ -757,6 +774,7 @@ SERVICES.append(reporters.MailNotifier(
useTls=True,
extraRecipients=['linkcheck@taler.net']
))
+SERVICES.append(tipReserveEmails)
NIGHTLY_TRIGGERS.append("linkchecker-builder")
@@ -866,6 +884,20 @@ CODECHANGE_TRIGGERS.append("codespell-builder")
# 'demo' deployment are up&running.
WORKERS.append(worker.Worker("demo-worker", "demo-pass"))
+DEMO_CHECK_TIPS_FACTORY = create_factory_with_deployment()
+DEMO_CHECK_TIPS_FACTORY.addStep(
+ ShellCommand(
+ name="demo tip reserves checker",
+ description="Checking that demo allocated tip money",
+ descriptionDone="Demo can tip visitors!.",
+ command=["./check_tip_reserve.sh"],
+ workdir="../../deployment/buildbot",
+ haltOnFailure=True,
+ # Needed to test the 'demo' deployment.
+ env={"DEPLOYMENT": "demo"}
+ )
+)
+
DEMO_SERVICES_INTEGRATIONTEST_FACTORY = create_factory_with_deployment()
DEMO_SERVICES_INTEGRATIONTEST_FACTORY.addStep(
ShellCommand(
@@ -884,6 +916,11 @@ BUILDERS.append(util.BuilderConfig(
workernames="demo-worker",
factory=DEMO_SERVICES_INTEGRATIONTEST_FACTORY
))
+BUILDERS.append(util.BuilderConfig(
+ name="check-tips-builder",
+ workernames="demo-worker",
+ factory=DEMO_CHECK_TIPS_FACTORY
+))
EMAIL_ALERTS.append("demo-services-checker-builder")
# We check demo once per hour.
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-deployment] branch master updated: checking tip money is allocated,
gnunet <=