Skip to content

Commit

Permalink
Support docker compose (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrproliu committed Jun 14, 2021
1 parent 53ea52f commit ff297d4
Show file tree
Hide file tree
Showing 18 changed files with 927 additions and 116 deletions.
6 changes: 4 additions & 2 deletions commands/cleanup/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/spf13/cobra"

"github.com/apache/skywalking-infra-e2e/internal/constant"
"github.com/apache/skywalking-infra-e2e/internal/logger"
)

var Cleanup = &cobra.Command{
Expand All @@ -52,7 +51,10 @@ func DoCleanupAccordingE2E() error {
return err
}
} else if e2eConfig.Setup.Env == constant.Compose {
logger.Log.Info("env for docker-compose not implemented")
err := cleanup.ComposeCleanUp(&e2eConfig)
if err != nil {
return err
}
} else {
return fmt.Errorf("no such env for cleanup: [%s]. should use kind or compose instead", e2eConfig.Setup.Env)
}
Expand Down
9 changes: 5 additions & 4 deletions commands/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ package setup
import (
"fmt"

"github.com/apache/skywalking-infra-e2e/internal/util"

"github.com/apache/skywalking-infra-e2e/internal/components/setup"
"github.com/apache/skywalking-infra-e2e/internal/config"
"github.com/apache/skywalking-infra-e2e/internal/constant"
"github.com/apache/skywalking-infra-e2e/internal/logger"
"github.com/apache/skywalking-infra-e2e/internal/util"

"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -59,7 +57,10 @@ func DoSetupAccordingE2E() error {
return err
}
} else if e2eConfig.Setup.Env == constant.Compose {
logger.Log.Warn("env for docker-compose not implemented")
err := setup.ComposeSetup(&e2eConfig)
if err != nil {
return err
}
return nil
} else {
return fmt.Errorf("no such env for setup: [%s]. should use kind or compose instead", e2eConfig.Setup.Env)
Expand Down
1 change: 1 addition & 0 deletions dist/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ The text of each license is also included at licenses/LICENSE-[project].txt.
logrus 1.7.0: https://github.com/sirupsen/logrus MIT
go-winio v0.4.16: https://github.com/Microsoft/go-winio MIT
aec v1.0.0: https://github.com/morikuni/aec MIT
testcontainers-go v0.11.0: https://github.com/testcontainers/testcontainers-go MIT

========================================================================
BSD licenses
Expand Down
21 changes: 21 additions & 0 deletions dist/licenses/LICENSE-testcontainers-go.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2017-2019 Gianluca Arbezzano

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
57 changes: 57 additions & 0 deletions examples/compose/base-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

version: '2.1'

services:
oap:
image: apache/skywalking-oap-server:8.5.0-es6
expose:
- 11800
- 12800
- 10051
- 5005
networks:
- e2e
restart: on-failure
environment:
SW_CLUSTER_ZK_HOST_PORT: zk:2181
SW_STORAGE_ES_CLUSTER_NODES: es:9200
SW_JDBC_URL: jdbc:mysql://mysql:3306/swtest
SW_STORAGE_INFLUXDB_URL: http://influxdb:8086
JAVA_OPTS: >-
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
healthcheck:
test: ["CMD", "sh", "-c", "nc -zn 127.0.0.1 11800"]
interval: 5s
timeout: 60s
retries: 120

ui:
image: apache/skywalking-ui:8.5.0
expose:
- 8080
networks:
- e2e
environment:
- SW_OAP_ADDRESS=oap:12800
healthcheck:
test: [ "CMD", "sh", "-c", "nc -zn 127.0.0.1 8080" ]
interval: 5s
timeout: 60s
retries: 120

networks:
e2e:
41 changes: 41 additions & 0 deletions examples/compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

version: '2.1'

services:

oap:
extends:
file: base-compose.yml
service: oap
ports:
- 12800
environment:
SW_STORAGE: h2
SW_SEARCHABLE_ALARM_TAG_KEYS: level,receivers

ui:
extends:
file: base-compose.yml
service: ui
ports:
- 8080
depends_on:
oap:
condition: service_healthy

networks:
e2e:
40 changes: 40 additions & 0 deletions examples/compose/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This file is used to show how to write configuration files and can be used to test.

setup:
env: compose
file: docker-compose.yml
timeout: 1200

cleanup:
# always never success failure
on: always

trigger:
action: http
interval: 3s
times: 5
url: http://127.0.0.1:${ui_8080}/
method: GET

verify:
- actual: ../../test/verify/1.actual.yaml
expected: ../../test/verify/1.expected.yaml
- actual: ../../test/verify/2.actual.yaml
expected: ../../test/verify/2.expected.yaml
- query: swctl --display yaml --base-url=http://${e2e_host_and_port_oap_12800}/graphql service ls
expected: ../../test/verify/3.expected.yaml
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 9 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,18 @@ module github.com/apache/skywalking-infra-e2e
go 1.13

require (
github.com/Microsoft/go-winio v0.4.16 // indirect
github.com/containerd/containerd v1.4.3 // indirect
github.com/docker/docker v20.10.3+incompatible
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/google/go-cmp v0.4.0
github.com/docker/docker v20.10.6+incompatible
github.com/google/go-cmp v0.5.4
github.com/gorilla/mux v1.8.0 // indirect
github.com/imdario/mergo v0.3.11 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/sirupsen/logrus v1.7.0
github.com/spf13/cobra v1.1.1
gopkg.in/yaml.v2 v2.3.0
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
k8s.io/api v0.19.0
k8s.io/apimachinery v0.19.0
k8s.io/cli-runtime v0.19.0
k8s.io/client-go v0.19.0
k8s.io/kubectl v0.19.0
k8s.io/utils v0.0.0-20201110183641-67b214c5f920 // indirect
github.com/testcontainers/testcontainers-go v0.11.0
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.20.7
k8s.io/apimachinery v0.20.7
k8s.io/cli-runtime v0.20.7
k8s.io/client-go v0.20.7
k8s.io/kubectl v0.20.7
sigs.k8s.io/kind v0.9.0
)
Loading

0 comments on commit ff297d4

Please sign in to comment.