- 
                Notifications
    You must be signed in to change notification settings 
- Fork 34
Improve testing #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            jackshirazi
  wants to merge
  15
  commits into
  elastic:main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
jackshirazi:improve-testing
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Improve testing #61
Changes from all commits
      Commits
    
    
            Show all changes
          
          
            15 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      85d95a1
              
                Create wait_for_log_entry.bash
              
              
                jackshirazi cdeabcf
              
                Create wait_for_es_transaction.bash
              
              
                jackshirazi a57804b
              
                Create wait_for_es_http_ready.bash
              
              
                jackshirazi 9132e6c
              
                Create endpoint.yml
              
              
                jackshirazi 303b15c
              
                Update endpoint.yml
              
              
                jackshirazi 1457022
              
                Create dummyservice.yml
              
              
                jackshirazi 77ab5c8
              
                Create start.bash
              
              
                jackshirazi 3bba4b1
              
                Update test-app.yaml
              
              
                jackshirazi 7404501
              
                Update Dockerfile
              
              
                jackshirazi 7b23814
              
                Create start.bash
              
              
                jackshirazi 7755eb0
              
                Update test-app.yaml
              
              
                jackshirazi edae173
              
                Update Dockerfile
              
              
                jackshirazi d5b6c43
              
                Update test-app.yaml
              
              
                jackshirazi 13b2fcf
              
                Delete test/operator/elastic-instrumentation.yml
              
              
                jackshirazi 725c41d
              
                Update operator-regression.yml
              
              
                jackshirazi File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              This file was deleted.
      
      Oops, something went wrong.
      
    
  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| FROM node | ||
|  | ||
| ADD ./app.js . | ||
| ADD ./start.bash . | ||
|  | ||
| ENTRYPOINT [ "node", "app.js" ] | ||
| ENTRYPOINT [ "bash", "start.bash" ] | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #!/bin/bash | ||
| node app.js & | ||
| while : | ||
| do | ||
| sleep 1 | ||
| curl -s http://127.0.0.1:8080/ > /dev/null | ||
| done | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| FROM python:3.9-slim-buster | ||
| FROM python:3.12 | ||
|  | ||
| WORKDIR /app | ||
|  | ||
| COPY . /app | ||
|  | ||
| RUN pip install --no-cache-dir -r requirements.txt | ||
|  | ||
| CMD [ "python3", "-m" , "flask", "run"] | ||
| CMD [ "bash", "/app/start.bash"] | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #!/bin/bash | ||
| python3 -m flask run & | ||
| while : | ||
| do | ||
| sleep 1 | ||
| curl -s http://localhost:5000/ > /dev/null | ||
| done | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: collector | ||
| namespace: banana | ||
| spec: | ||
| clusterIP: None | ||
| ports: | ||
| - port: 4318 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| apiVersion: v1 | ||
| kind: Endpoints | ||
| metadata: | ||
| name: collector | ||
| namespace: banana | ||
| subsets: | ||
| - addresses: | ||
| - ip: REPLACE | ||
| ports: | ||
| - name: collector | ||
| port: 4318 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #!/bin/bash | ||
|  | ||
| set -euxo pipefail | ||
|  | ||
| MAX_WAIT_SECONDS=120 | ||
| URL=$1 | ||
|  | ||
| echo "Waiting up to $MAX_WAIT_SECONDS seconds for the elasticsearch server to be ready by checking $URL" | ||
| count=0 | ||
| while [ $count -lt $MAX_WAIT_SECONDS ] | ||
| do | ||
| count=`expr $count + 1` | ||
| STARTED=$((curl -m 2 "$URL" || true) | (grep build_hash || true) | wc -l) | ||
| if [ $STARTED -ne 0 ] | ||
| then | ||
| exit 0 | ||
| fi | ||
| sleep 1 | ||
| done | ||
| echo "error: the elasticsearch server failed to be ready within $MAX_WAIT_SECONDS seconds" | ||
| curl -v "$URL" | ||
| exit 1 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #!/bin/bash | ||
|  | ||
| set -euxo pipefail | ||
|  | ||
| MAX_WAIT_SECONDS=120 | ||
| URL=$1 | ||
| SERVICE_NAME=$2 | ||
| KUBECTL_COMMAND=$3 | ||
|  | ||
| echo "Waiting up to $MAX_WAIT_SECONDS seconds for the elasticsearch server to show a transaction from $SERVICE_NAME by querying $URL" | ||
| count=0 | ||
| while [ $count -lt $MAX_WAIT_SECONDS ] | ||
| do | ||
| count=`expr $count + 1` | ||
| #curl -m 2 "$URL/traces*/_search" -H "Content-Type: application/json" -d '{"query": {"range": {"@timestamp": {"gte": "now-1h","lte": "now"}}}}' > query.output | ||
| curl -m 2 "$URL/traces*/_search" -H "Content-Type: application/json" -d "{\"query\": {\"bool\": {\"must\": [{\"range\": {\"@timestamp\": {\"gte\": \"now-1h\",\"lte\": \"now\"}}},{\"match\": {\"resource.attributes.service.name\": \"$SERVICE_NAME\"}}]}}}" > query.output | ||
| DETECTED_SERVICE=$(jq '.hits.hits[0]._source.resource.attributes."service.name"' query.output | tr -d '"') | ||
| if [ "x$DETECTED_SERVICE" = "x$SERVICE_NAME" ] | ||
| then | ||
| exit 0 | ||
| fi | ||
| sleep 1 | ||
| done | ||
|  | ||
| echo "error: the elasticsearch server failed to include a transaction with the service name $SERVICE_NAME wihin $MAX_WAIT_SECONDS seconds" | ||
| eval $KUBECTL_COMMAND | ||
| cat query.output | jq | ||
| exit 1 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #!/bin/bash | ||
|  | ||
| set -euxo pipefail | ||
|  | ||
| MAX_WAIT_SECONDS=120 | ||
| LOGNAME=$1 | ||
| SERVICENAME=$2 | ||
| GREP=$3 | ||
|  | ||
| echo "Waiting up to $MAX_WAIT_SECONDS seconds for the $SERVICENAME to be ready" | ||
| count=0 | ||
| while [ $count -lt $MAX_WAIT_SECONDS ] | ||
| do | ||
| count=`expr $count + 1` | ||
| STARTED=$((grep -i "$GREP" $LOGNAME || true) | wc -l) | ||
| if [ $STARTED -ne 0 ] | ||
| then | ||
| exit 0 | ||
| fi | ||
| sleep 1 | ||
| done | ||
| echo "error: the $SERVICENAME failed to be ready within $MAX_WAIT_SECONDS seconds" | ||
| tail -n 100 $LOGNAME | ||
| exit 1 | 
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you provide more information about why this Collector instance is needed? Why not using the Operator's endpoint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The flow of trace data is app->app agent->collector->ES, so it needs a collector. The operator endpoint is for mutating the k8s definitions so that's entirely separate, that's not involved in the flow of traces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be missing something, but if you are using the
values.yamlfile we ship to deploy the Operator, it will deploy a collector in each K8s node with an open OTLP endpoint for traces. Those collectors will have the same processing components that the one you are launching manually.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah gotcha. yes that didn't seem to be working in my tests. It was easier for me to spin up a new collector with the traces config. If you think it's straightforward to have it running so that it sends traces, we can do that, I agree it would be better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the data already has the right shape, then your collector here could just receive data and forward it to ES, if you really want to have it. It doesn't need to use this full config.
Though if it was up to me, I'd just ES itself in the K8s cluster and forward the 9200 port.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The collector does some transforms on the incoming data from the application agents, so I think it needs to be correctly configured for handling incoming trace data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, I would use the collector deployed by the Operator as it is already configured to handle/transform any OTLP traces.
That makes sense to me as well, we will just need to maintain one type of deploying infrastructure (K8s/kind).