Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit ab621dc

Browse files
authored
Simplify integration testing (#19)
1 parent 696f656 commit ab621dc

File tree

3 files changed

+66
-3
lines changed

3 files changed

+66
-3
lines changed

Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM ruby:latest
2+
3+
WORKDIR /plugin
4+
5+
ADD . /plugin
6+
7+
RUN gem install bundler && \
8+
gem install fluentd --no-doc && \
9+
fluent-gem build fluent-plugin-azure-storage-append-blob.gemspec && \
10+
fluent-gem install fluent-plugin-azure-storage-append-blob-*.gem
11+
12+
RUN echo "<source>\n\
13+
@type sample\n\
14+
sample {\"hello\":\"world\"}\n\
15+
tag pattern\n\
16+
</source>\n\
17+
<match pattern>\n\
18+
@type azure-storage-append-blob\n\
19+
azure_storage_account \"#{ENV['STORAGE_ACCOUNT']}\"\n\
20+
azure_storage_access_key \"#{ENV['STORAGE_ACCESS_KEY']}\"\n\
21+
azure_storage_sas_token \"#{ENV['STORAGE_SAS_TOKEN']}\"\n\
22+
azure_container fluentd\n\
23+
auto_create_container true\n\
24+
path logs/\n\
25+
azure_object_key_format %{path}%{time_slice}_%{index}.log\n\
26+
time_slice_format %Y%m%d-%H\n\
27+
<buffer tag,time>\n\
28+
@type file\n\
29+
path /var/log/fluent/azurestorageappendblob\n\
30+
timekey 120 # 2 minutes\n\
31+
timekey_wait 60\n\
32+
timekey_use_utc true # use utc\n\
33+
</buffer>\n\
34+
</match>" > /plugin/fluent.conf
35+
36+
ENTRYPOINT ["fluentd", "-c", "fluent.conf"]

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,33 @@ Format of the time used in the file name. Default is '%Y%m%d'. Use '%Y%m%d%H' to
128128
bundle install
129129
bundle exec rake test
130130

131+
132+
### Test Fluentd
133+
134+
1. Create Storage Account and VM with enabled MSI
135+
2. Setup Docker ang Git
136+
3. SSH into VM
137+
4. Download this repo
138+
```
139+
git clone https://github.com/microsoft/fluent-plugin-azure-storage-append-blob.git
140+
cd fluent-plugin-azure-storage-append-blob
141+
```
142+
5. Build Docker image
143+
`docker build -t fluent .`
144+
6. Run Docker image with different set of parameters:
145+
146+
1. `STORAGE_ACCOUNT`: required, name of your storage account
147+
2. `STORAGE_ACCESS_KEY`: storage account access key
148+
3. `STORAGE_SAS_TOKEN`: storage sas token with enough permissions for the plugin
149+
150+
You need to specify `STORAGE_ACCOUNT` and one of auth ways. If you run it from VM with MSI,
151+
just `STORAGE_ACCOUNT` is required. Keep in mind, there is no way to refresh MSI Token, so
152+
ensure you setup proper permissions first.
153+
154+
```bash
155+
docker run -it -e STORAGE_ACCOUNT=<storage> -e STORAGE_ACCESS_KEY=<key> fluent
156+
```
157+
131158
## Contributing
132159

133160
This project welcomes contributions and suggestions. Most contributions require you to agree to a

lib/fluent/plugin/out_azure-storage-append-blob.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def configure(conf)
6363

6464
raise ConfigError, 'azure_container needs to be specified' if @azure_container.nil?
6565

66-
if @azure_storage_access_key.nil? && @azure_storage_sas_token.nil?
66+
if (@azure_storage_access_key.nil? || @azure_storage_access_key.empty?) && (@azure_storage_sas_token.nil? || @azure_storage_sas_token.empty?)
6767
log.info 'Using MSI since neither azure_storage_access_key nor azure_storage_sas_token was provided.'
6868
@use_msi = true
6969
end
@@ -105,9 +105,9 @@ def start
105105
else
106106
@bs_params = { storage_account_name: @azure_storage_account }
107107

108-
if !@azure_storage_access_key.nil?
108+
if !@azure_storage_access_key.nil? && !@azure_storage_access_key.empty?
109109
@bs_params.merge!({ storage_access_key: @azure_storage_access_key })
110-
elsif !@azure_storage_sas_token.nil?
110+
elsif !@azure_storage_sas_token.nil? && !@azure_storage_sas_token.empty?
111111
@bs_params.merge!({ storage_sas_token: @azure_storage_sas_token })
112112
end
113113

0 commit comments

Comments
 (0)