Skip to content

Commit

Permalink
Merge pull request #7231 from chrisburr/fix-diracx-int-tests
Browse files Browse the repository at this point in the history
[8.1] Integration test fixes for DiracX
  • Loading branch information
fstagni authored Oct 9, 2023
2 parents da42574 + bf90cdc commit 4e2fbd9
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 7 deletions.
7 changes: 7 additions & 0 deletions src/DIRAC/Core/scripts/dirac_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ def setLegacyExchangeApiKey(self, optionValue):
DIRAC.gConfig.setOptionValue(cfgInstallPath("LegacyExchangeApiKey"), self.legacyExchangeApiKey)
return DIRAC.S_OK()

def setDiracxUrl(self, optionValue):
self.diracxUrl = optionValue
Script.localCfg.addDefaultEntry("/DiracX/URL", self.diracxUrl)
DIRAC.gConfig.setOptionValue(cfgInstallPath("URL"), self.diracxUrl)
return DIRAC.S_OK()


def _runConfigurationWizard(setups, defaultSetup):
"""The implementation of the configuration wizard"""
Expand Down Expand Up @@ -371,6 +377,7 @@ def runDiracConfigure(params):
Script.registerSwitch(
"K:", "LegacyExchangeApiKey=", "Set the Api Key to talk to DiracX", params.setLegacyExchangeApiKey
)
Script.registerSwitch("", "DiracxUrl=", "Set the URL to talk to DiracX", params.setDiracxUrl)

Script.registerSwitch("W:", "gateway=", "Configure <gateway> as DIRAC Gateway for the site", params.setGateway)

Expand Down
2 changes: 1 addition & 1 deletion src/DIRAC/FrameworkSystem/Service/ProxyManagerHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def export_exchangeProxyForToken(self):

try:
r = requests.get(
f"{diracxUrl}/auth/legacy-exchange",
f"{diracxUrl}/api/auth/legacy-exchange",
params={
"preferred_username": credDict["username"],
"scope": " ".join(scopes),
Expand Down
4 changes: 3 additions & 1 deletion src/DIRAC/FrameworkSystem/Utilities/diracx.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def _get_token(credDict, diracxUrl, /) -> Path:
scopes = [f"vo:{vo}", f"group:{group}"] + [f"property:{prop}" for prop in dirac_properties]

r = requests.get(
f"{diracxUrl}/auth/legacy-exchange",
f"{diracxUrl}/api/auth/legacy-exchange",
params={
"preferred_username": credDict["username"],
"scope": " ".join(scopes),
Expand Down Expand Up @@ -71,6 +71,8 @@ def TheImpersonator(credDict: dict[str, Any]) -> DiracClient:
"""

diracxUrl = gConfig.getValue("/DiracX/URL")
if not diracxUrl:
raise ValueError("Missing mandatory /DiracX/URL configuration")
token_location = _get_token(credDict, diracxUrl)
pref = DiracxPreferences(url=diracxUrl, credentials_path=token_location)

Expand Down
1 change: 1 addition & 0 deletions tests/CI/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ services:
- DIRACX_SERVICE_AUTH_ALLOWED_REDIRECTS=["http://diracx:8000/docs/oauth2-redirect"]
# Obtained with echo 'InsecureChangeMe' | base64 -d | openssl sha256
- DIRACX_LEGACY_EXCHANGE_HASHED_API_KEY=07cddf6948d316ac9d186544dc3120c4c6697d8f994619665985c0a5bf76265a
- DIRACX_SERVICE_JOBS_ENABLED=false
ports:
- 8000:8000
depends_on:
Expand Down
5 changes: 4 additions & 1 deletion tests/CI/exportCSLoop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ git config --global user.name "DIRAC Server CI"
git config --global user.email "dirac-server-ci@invalid"

while true; do
curl -L https://gitlab.cern.ch/chaen/chris-hackaton-cs/-/raw/integration-tests/convert-from-legacy.py |DIRAC_COMPAT_ENABLE_CS_CONVERSION=True /home/dirac/ServerInstallDIR/diracos/bin/python - /home/dirac/ServerInstallDIR/etc/Production.cfg /cs_store/initialRepo/
DIRAC_COMPAT_ENABLE_CS_CONVERSION=x dirac internal legacy cs-sync \
"$DIRACOS/etc/Production.cfg" \
/home/dirac/TestCode/diracx/tests/cli/legacy/cs_sync/convert_integration_test.yaml \
/cs_store/initialRepo/default.yml
git --git-dir=.git -C /cs_store/initialRepo/ commit -am "export $(date)"
if [[ "${1}" == "--once" ]]; then
break
Expand Down
7 changes: 6 additions & 1 deletion tests/Jenkins/dirac_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,12 @@ installSite() {

echo "==> Done installing, now configuring"
source "${SERVERINSTALLDIR}/bashrc"
if ! dirac-configure --cfg "${SERVERINSTALLDIR}/install.cfg" --LegacyExchangeApiKey='diracx:legacy:InsecureChangeMe' "${DEBUG}"; then
configureArgs=()
if [[ -n "${TEST_DIRACX:-}" ]]; then
configureArgs+=("--LegacyExchangeApiKey=diracx:legacy:InsecureChangeMe")
configureArgs+=("--DiracxUrl=${DIRACX_URL}")
fi
if ! dirac-configure --cfg "${SERVERINSTALLDIR}/install.cfg" "${configureArgs[@]}" "${DEBUG}"; then
echo "ERROR: dirac-configure failed" >&2
exit 1
fi
Expand Down
6 changes: 3 additions & 3 deletions tests/Jenkins/utilities.sh
Original file line number Diff line number Diff line change
Expand Up @@ -562,17 +562,17 @@ diracUserAndGroup() {
exit 1
fi

if ! dirac-admin-add-group -G prod -U adminusername,ciuser,trialUser -P Operator,FullDelegation,ProxyManagement,ServiceAdministrator,JobAdministrator,CSAdministrator,AlarmsManagement,FileCatalogManagement,SiteManager,NormalUser,ProductionManagement "${DEBUG}"; then
if ! dirac-admin-add-group -G prod -U adminusername,ciuser,trialUser -P Operator,FullDelegation,ProxyManagement,ServiceAdministrator,JobAdministrator,CSAdministrator,AlarmsManagement,FileCatalogManagement,SiteManager,NormalUser,ProductionManagement VO=vo "${DEBUG}"; then
echo 'ERROR: dirac-admin-add-group failed' >&2
exit 1
fi

if ! dirac-admin-add-group -G jenkins_fcadmin -U adminusername,ciuser,trialUser -P FileCatalogManagement,NormalUser "${DEBUG}"; then
if ! dirac-admin-add-group -G jenkins_fcadmin -U adminusername,ciuser,trialUser -P FileCatalogManagement,NormalUser VO=vo "${DEBUG}"; then
echo 'ERROR: dirac-admin-add-group failed' >&2
exit 1
fi

if ! dirac-admin-add-group -G jenkins_user -U adminusername,ciuser,trialUser -P NormalUser "${DEBUG}"; then
if ! dirac-admin-add-group -G jenkins_user -U adminusername,ciuser,trialUser -P NormalUser VO=vo "${DEBUG}"; then
echo 'ERROR: dirac-admin-add-group failed' >&2
exit 1
fi
Expand Down

0 comments on commit 4e2fbd9

Please sign in to comment.