Skip to content

Commit

Permalink
optimize ci cd pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
BWbwchen committed Jul 27, 2021
1 parent 3f4da72 commit cdf5754
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ deploy-job:
stage: deploy
image: dtzar/helm-kubectl
before_script:
- sed -ie "s/deploy-date-value/$(date)/g" kubernetes/cd.yaml
- sed -ie "s/deploy-date-value/$(date)/g" kubernetes/deploy.yaml
- mkdir -p /root/.kube/ && touch /root/.kube/config
- echo ${KUBERNETES_KUBE_CONFIG} | base64 -d > ${KUBECONFIG}
script:
- kubectl apply -f kubernetes/cd.yaml
- kubectl apply -f kubernetes/deploy.yaml
4 changes: 2 additions & 2 deletions kubernetes/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ metadata:
namespace: shorturl
labels:
app: shorturl
workload.user.cattle.io/workloadselector: deployment-shorturl-shorturl
spec:
progressDeadlineSeconds: 600
replicas: 1
Expand All @@ -23,7 +22,8 @@ spec:
metadata:
labels:
app: shorturl
workload.user.cattle.io/workloadselector: deployment-shorturl-shorturl
annotations:
deploy-date: "deploy-date-value"
spec:
containers:
- name: shorturl
Expand Down
20 changes: 5 additions & 15 deletions performance_test/perf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { check, group, sleep } from 'k6';

export let options = {
stages: [
{ duration: '30s', target: 10 }, // simulate ramp-up of traffic from 1 to 100 users over 5 minutes.
{ duration: '1m', target: 10 }, // stay at 100 users for 10 minutes
{ duration: '30s', target: 0 }, // ramp-down to 0 users
{ duration: '15s', target: 20 }, // simulate ramp-up of traffic from 1 to 100 users over 5 minutes.
{ duration: '1m', target: 20 }, // stay at 100 users for 10 minutes
{ duration: '15s', target: 0 }, // ramp-down to 0 users
]
};

Expand Down Expand Up @@ -34,28 +34,18 @@ export default () => {
}
});

check(createShortURL, {
'Create status': (resp) => resp.status == 200,
});

let shortName = createShortURL.json('short')
history_list.push(shortName)

// get just created url
let getLongURL = http.get(`${BASE_URL}/${shortName}`)
let nowStatus = getLongURL.json('status')
let long = getLongURL.json('url')
check(long, {
'check correctness': (obj) => obj == url
});


// get history random url
let getHistoryLongURL = http.get(`${BASE_URL}/${history_list[getRandomInt(history_list.length)]}`)
let nowHistoryStatus = getHistoryLongURL.json('status')
let longHistory = getHistoryLongURL.json('url')
check(getHistoryLongURL, {
'history random get status check': (resp) => resp.status == 200
});


sleep(0.5);
};

0 comments on commit cdf5754

Please sign in to comment.