Skip to content
This repository has been archived by the owner on Mar 1, 2020. It is now read-only.

We have no control on the environment name length #9

Open
zadigus opened this issue May 10, 2019 · 2 comments
Open

We have no control on the environment name length #9

zadigus opened this issue May 10, 2019 · 2 comments
Assignees
Labels
enhancement New feature or request jelastic
Milestone

Comments

@zadigus
Copy link

zadigus commented May 10, 2019

Various tests on our CI/CD server showed that the environment name shopozor-management-frontend-e2e prevents it from running the e2e tests, i.e. it is not possible to install the e2e manifest even though the installation manifest was successfully installed.

One way to prevent that problem from happening would be to set a maximal length for the frontend environment names in the shopozor ci manifest's settings section. That functionality is, however, not supported yet (ticket 12056).

@zadigus zadigus self-assigned this May 10, 2019
@zadigus zadigus added enhancement New feature or request jelastic labels May 10, 2019
@zadigus zadigus added this to the Release 1.0.0 milestone Aug 7, 2019
@zadigus
Copy link
Author

zadigus commented Aug 7, 2019

Here's how to reproduce the issue:

  1. install the following manifest to generate environment shopozor-management-frontend-e2e.hidora.com:
jpsVersion: 1.3
jpsType: install
application:
  id: shopozor-management-frontend-e2e
  name: shopozor-management-frontend-e2e
  version: 0.0

  env:
    topology:
      nodes:
        - nodeGroup: cp
          image: softozor/shopozor-mgmt-frontend-e2e:latest
          displayName: Application servers
          count: 1
          fixedCloudlets: 4
          cloudlets: 10
      skipNodeEmails: true
  1. use shell script
#!/bin/bash

if [ $# -lt 5 ] ; then
  echo "Usage: $0 hosterUrl appId login password envName [deploy_group = cp] [path-to-manifest = e2e.jps]"
  exit 0
fi

CONTENT_TYPE="Content-Type: application/x-www-form-urlencoded; charset=UTF-8;"
USER_AGENT="Mozilla/4.73 [en] (X11; U; Linux 2.2.15 i686)"

getSession() {
  local login=$1
  local password=$2
  local hosterUrl=$3
  echo "Signing in..." >&2
  local cmd=$(curl -k -H "${CONTENT_TYPE}" -A "${USER_AGENT}"  -X POST \
    -fsS "$hosterUrl/1.0/users/authentication/rest/signin" -d "login=$login&password=$password");
  echo "Signed in" >&2
  echo $(jq '.session' <<< $cmd |  sed 's/\"//g')
}

getEnvs() {
  local session=$1
  echo "Getting environments..." >&2
  local cmd=$(curl -k \
    -H "${CONTENT_TYPE}" \
    -A "${USER_AGENT}" \
    -X POST \
    -fsS ${HOSTER_URL}/1.0/environment/control/rest/getenvs -d "appid=${APPID}&session=${session}")
  echo "Got environments" >&2
  echo $cmd
}

installEnv() {
  local session=$1
  local envName=$2
  local pathToManifest=$3
  local manifest=$(cat $pathToManifest)
  echo "Installing new environment <$envName> from manifest <$pathToManifest>..." >&2
  local cmd=$(curl -k \
    -A "${USER_AGENT}" \
    -H "${CONTENT_TYPE}" \
    -X POST -fsS ${HOSTER_URL}"/1.0/development/scripting/rest/eval" \
    --data "session=${session}&shortdomain=${envName}&envName=${envName}&script=InstallApp&appid=appstore&type=install&charset=UTF-8" --data-urlencode "manifest=$manifest")
  echo "Installation result: $cmd" >&2
  echo "Environment <$envName> installed" >&2
}

HOSTER_URL=$1
APPID=$2

SESSION=$(getSession $3 $4 ${HOSTER_URL})
ENV_NAME=$5
DEPLOY_GROUP=${6:-cp}
MANIFEST=${7:-e2e.jps}

runE2e() {
  ENVS=$(getEnvs $SESSION)

  installEnv $SESSION "${ENV_NAME}" "$MANIFEST"

  exit 0
}

runE2e

and run

./run-e2e.sh "jelasticProviderUrl" "appId" "login" "password" "shopozor-management-frontend-e2e" "cp" "e2e.jps"

where e2e.jps is

jpsVersion: 1.3
jpsType: update
application:
  id: shopozor-management-frontend-e2e
  name: shopozor-management-frontend-e2e
  version: 0.0

  globals:
    NODEJS_HOME: /home/node
  
  onInstall:
    - test

  actions:
    test:
      - cmd [cp]:
        - cd ${globals.NODEJS_HOME}
        - rm -Rf junit-reports cypress/videos cypress/screenshots
        - yarn start:e2e

I get in that case this error:

{
  "result":1704,
  "debug": {
    "cpu": {
      "usage":"3",
      "time":491
    },
    "time":803
  },
  "response":null,
  "source":"hx-core",
  "error":"org.mozilla.javascript.JavaScriptException: Error: checkRights().GetAppPermission: {\"result\":901,\"source\":\"hx-core\",\"error\":\"application [shopozor-management-frontend-e2e] not exist\"}"
}

However, shopozor-management-frontend-e2e does exist. If, instead, I do:

  1. install the following manifest creating environment shopozor-mgmt-frontend-e2e.hidora.com
jpsVersion: 1.3
jpsType: install
application:
  id: shopozor-mgmt-frontend-e2e
  name: shopozor-mgmt-frontend-e2e
  version: 0.0

  env:
    topology:
      nodes:
        - nodeGroup: cp
          image: softozor/shopozor-mgmt-frontend-e2e:latest
          displayName: Application servers
          count: 1
          fixedCloudlets: 4
          cloudlets: 10
      skipNodeEmails: true
  1. run
./run-e2e.sh  "jelasticProviderUrl" "appId" "login" "password" "shopozor-mgmt-frontend-e2e" "cp" "e2e.jps"

where e2e.jps is this time

jpsVersion: 1.3
jpsType: update
application:
  id: shopozor-mgmt-frontend-e2e
  name: shopozor-mgmt-frontend-e2e
  version: 0.0

  globals:
    NODEJS_HOME: /home/node
  
  onInstall:
    - test

  actions:
    test:
      - cmd [cp]:
        - cd ${globals.NODEJS_HOME}
        - rm -Rf junit-reports cypress/videos cypress/screenshots
        - yarn start:e2e

Then everything is fine.

@zadigus
Copy link
Author

zadigus commented Aug 14, 2019

Ticket "JE-49193 - [CS:Install] - incorrect behavior for envName with length=32" is open at Jelastic.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request jelastic
Projects
None yet
Development

No branches or pull requests

1 participant