additional_paths: []
category: tutorial-internal
commands:
- command: script
  id: a7b32e3e276c11eea6020e4c6ffda461
  kwargs:
    code: |
      # 事前確認など
      preperation_completed = True

      response = {
          "code": 202 if preperation_completed else 500,
          "body": {
              "xid": xid,
              "xname": xname,
          }
      }

      context.session.set_status(response["code"])
      context.session.finish(response["body"])
  label: Response
- command: script
  id: a7b3e0c2276c11eea6020e4c6ffda461
  kwargs:
    code: |
      import os

      # Params for E2E Test
      username = os.getenv("TEST_ENV_USERNAME")
      password = os.getenv("TEST_ENV_PASSWORD")
      environmentId = os.getenv("QMONUS_JOB_RUNNER_NAMESPACE")[-36:]
      target_env_url = f"https://api-front-{environmentId}.sdk-lab.qmonus.net/"
      body = {
          "scenario": "scenario1",
          "description": "",
          "params": {
              "url": target_env_url,
              "username": username,
              "password": password,
              "api": {
                  "limit_length": "/test/test/test/test/test/test/test",
                  "success_path": "/healthcheck/ref/versions",
                  "fail_path": "/test"
              },
              "link": {
                  "text": "Tutorial page",
                  "url": "https://developer.qmonus.net/document/casval/top"
              }
          },
          "options": {
              "client": "chrome",
              "lang": "en-US",
              "viewport": {
                  "width": 1366,
                  "height": 768,
                  "isMobile": False,
                  "hasTouch": False,
                  "isLandscape": False
              },
              "headless": True,
              "devtools": False,
              "autoSnapshot": False,
              "disableSnapshot": False,
              "debugMode": False,
              "frameSelector": "",
              "slowMo": 10,
              "snapshotQuality": 80,
              "testTimeout": 180000,
              "proxyServer": ""
          },
          "executeOptions": {}
      }

      # Test LocalCreateEmployee
      r = await callout(
          url="http://edwow:8089/v2",
          method="POST",
          body=body)
      assert r.code == 201, "Invalid response code %r" % r.code

      test_id = json.loads(r.body)["id"]
      check_interval_sec = 10
      max_retry_count = 6
      for i in range(max_retry_count):
          r = await callout(
              url=f"http://edwow:8089/v2/status/{test_id}",
              method="GET")
          test_status = json.loads(r.body)["status"]
          if test_status == "failed":
              raise Error(500, 'Internal Server Error')
          elif test_status == "completed":
              break
          await asyncio.sleep(check_interval_sec)
  label: ExecuteTest
connect_timeout: 60
global_variables: {}
method: POST
name: E2ETestInternal
request_timeout: 60
routing_auto_generation_mode: true
routing_options:
  scope: local
spec:
  response:
    normal:
      codes:
      - 200
transaction:
  async: true
  auto_response: false
  enable: true
  xname: ''
update: '2023-07-21T13:12:19.484716+09:00'
uri: /test/internal/e2etest/local/employees
variable_groups: []
version: 3
